// JavaScript Document


function sbProfileImageLargerPopup(sImgId)
{
  iImg = new Image;
  iImg.src = sImgId;
  modal = {
    // all are optional (see "/js/dependable.js" for defaults)
    Content : iImg // needs to be defined here... content added by validator
      
  };
  jqDialogAutoPopup(modal)
}

// Ted's function for an on load dialog box that takes arguments

var jqDialogAutoPopupStatus = 0;

function jqDialogAutoPopup(o) 
{
  //default values if not passed
  o.Container = (typeof o.Container == 'undefined') ? '#ProfileImagePopup' : o.Container;
  o.Title = (typeof o.Title == 'undefined') ? '' : o.Title;
  o.Content = (typeof o.Content == 'undefined') ? 'An undefined error has occured' : o.Content;
  o.URL = (typeof o.URL == 'undefined') ? null : o.URL;
  o.Width = (typeof o.Width == 'undefined') ? 482 : o.Width;
  o.ShowEffect = (typeof o.ShowEffect == 'undefined') ? 'scale' : o.ShowEffect;
  o.HideEffect = (typeof o.HideEffect == 'undefined') ? 'scale' : o.HideEffect;
  o.EffectSpeed = (typeof o.EffectSpeed == 'undefined') ? 'fast' : o.EffectSpeed;
  o.ModalBackground = (typeof o.ModalBackground == 'undefined') ? '#ModalBackground' : o.ModalBackground;
  o.ModalColor = (typeof o.ModalColor == 'undefined') ? '#000' : o.ModalColor;
  o.ModalOpacity = (typeof o.ModalOpacity == 'undefined') ? '0.2' : o.ModalOpacity;
	var windowWidth = document.documentElement.clientWidth;
  var windowHeight = document.documentElement.clientHeight;
  //loads popup only if it is disabled
	if(jqDialogAutoPopupStatus==0)
  {
    jQuery(o.ModalBackground).css({
    	"height": windowHeight, 
    	"width": windowWidth,
    	"background": o.ModalColor,
    	"opacity": o.ModalOpacity
    });    
    jQuery(o.ModalBackground).bgiframe();
    jQuery(o.ModalBackground).fadeIn(o.EffectSpeed, function(){
      //display dialog
      jQuery(o.Container).html(o.Content);
      if(o.URL)
      {
        jQuery.ajax({
          url: o.URL,
          success: function(html)
          {
            jQuery(o.Container).html(html);      
          }
        });
      }
    	jQuery(o.Container).dialog({
        autoOpen: false,
        show: o.ShowEffect,
        hide: o.HideEffect,
        title: o.Title,
        width: o.Width,
        modal: true,
        close: function()
          {  
            jQuery(o.ModalBackground).fadeOut(o.EffectSpeed);
            jqDialogAutoPopupStatus = 0;
            try
            { 
              v_varFormFieldThatNeedsfocus.focus();
            } 
            catch(er) {} 
    			},
    		buttons: {
    			"Close": function()
          { 
            jQuery(o.Container).dialog("close"); 
    			}
    		}		
    	});
    	jQuery(o.Container).dialog("open");
    });
    jqDialogAutoPopupStatus = 1;
  }
}

