// JScript File

function PopupLib()
{
    var SMALL_POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,scrollbars=1,width=480,height=450';
    var MEDIUM_POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,scrollbars=1,width=640,height=480';
    var LARGE_POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,scrollbars=1,width=800,height=600';
    
    var QUOTE_POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,scrollbars=1,width=320,height=360';
    var PRINT_POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,scrollbars=1';
    var CUSTOM_POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,scrollbars=1';
    
    var HELP_POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,scrollbars=1,resizable=1,width=640,height=480';

    var SMALL_IFRAME_PRINT_POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,scrollbars=0,width=480,height=450';
    var MEDIUM_IFRAME_PRINT_POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,scrollbars=0,width=640,height=480';
    var CUSTOM_IFRAME_PRINT_POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,scrollbars=0';
    
    var MARCOM_LARGE_POPUP_FEATURES = 'location=1,statusbar=1,menubar=1,toolbar=1,scrollbars=1,resizable=1,width=800,height=600';
    
    var GAINLOSS_CUSTOM_POPUP_FEATURES = 'resizable=1,scrollbars=1';

//specialty popups

    this.OpenPopUpPrint = OpenPopUpPrint; 
    function OpenPopUpPrint(item,width,height)
    { 
        return OpenPopUpUrl(item.href, 'SB_PrintPop', CUSTOM_POPUP_FEATURES + ",width=" + width + ",height=" + height);
    }

    this.OpenIframePopUpPrintSmall = OpenIframePopUpPrintSmall; 
    function OpenIframePopUpPrintSmall(item)
    { 
        return OpenPopUpUrl(item.href, 'SB_PrintPop', SMALL_IFRAME_PRINT_POPUP_FEATURES);
    }

    this.OpenIframePopUpPrintMedium = OpenIframePopUpPrintMedium; 
    function OpenIframePopUpPrintMedium(item)
    { 
        return OpenPopUpUrl(item.href, 'SB_PrintPop', MEDIUM_IFRAME_PRINT_POPUP_FEATURES);
    }
        
    this.OpenPopUpCustomIframe = OpenPopUpCustomIframe;
    function OpenPopUpCustomIframe(item,width,height)
    {
        return OpenPopUpUrl(item.href, 'SB_Pop', CUSTOM_IFRAME_PRINT_POPUP_FEATURES + ",width=" + width + ",height=" + height);
    }
    
    this.OpenPopUpCustom = OpenPopUpCustom;
    function OpenPopUpCustom(item,width,height)
    {
        var url = (typeof(item) == "object") ? item.href: item;
        return OpenPopUpUrl(url, 'SB_Pop', CUSTOM_POPUP_FEATURES + ",width=" + width + ",height=" + height);
    }
    
    this.OpenPopUpGainAndLoss = OpenPopUpGainAndLoss;
    function OpenPopUpGainAndLoss(item,width,height)
    {
        var url = (typeof(item) == "object") ? item.href: item;
        return OpenPopUpUrl(url, 'SB_Pop', GAINLOSS_CUSTOM_POPUP_FEATURES + ",width=" + width + ",height=" + height);
    }
    
    this.OpenPopUpFaq = OpenPopUpFaq; 
    function OpenPopUpFaq(item)
    {
        return OpenPopUpUrl(item.href, 'SB_FaqPop', MEDIUM_POPUP_FEATURES);
    }

    this.PopupHelp = PopupHelp; 
    function PopupHelp(item)
    {
        OpenPopUpUrl(item.href, 'SB_FaqPop', HELP_POPUP_FEATURES);
        return false;
    }
       
    this.OpenPopUpFaqUrl = OpenPopUpFaqUrl;
    function OpenPopUpFaqUrl(Url)
    {
        return OpenPopUpUrl(Url, 'SB_FaqPop', MEDIUM_POPUP_FEATURES);
    }
    
    this.OpenPopUpQuote = OpenPopUpQuote; 
    function OpenPopUpQuote(item)
    {
        return OpenPopUpUrl(item.href, 'SB_QuotePop', QUOTE_POPUP_FEATURES);
    }
   
    this.OpenPopUpMarcom = OpenPopUpMarcom; 
    function OpenPopUpMarcom(item)
    {
        var url = (typeof(item) == "object") ? item.href: item;
        return OpenPopUpUrl(url, 'SB_MarcomPop', MARCOM_LARGE_POPUP_FEATURES);
    } 
    
//standard popups

    this.OpenPopUpSmall = OpenPopUpSmall; 
    function OpenPopUpSmall(item)
    {
       var url = (typeof(item) == "object") ? item.href: item;
       return OpenPopUpUrl(url, 'SB_SmallPop', SMALL_POPUP_FEATURES);
    }
    
    this.OpenPopUpMedium = OpenPopUpMedium; 
    function OpenPopUpMedium(item)
    {
       var url = (typeof(item) == "object") ? item.href: item;
       return OpenPopUpUrl(url, 'SB_MedPop', MEDIUM_POPUP_FEATURES);
    }
   
    this.OpenPopUpLarge = OpenPopUpLarge; 
    function OpenPopUpLarge(item)
    {
        var url = (typeof(item) == "object") ? item.href: item;
        return OpenPopUpUrl(url, 'SB_LargePop', LARGE_POPUP_FEATURES);
    }
  
// specialized popup functionality
    
    this.TargetOpener = TargetOpener; 
    function TargetOpener(item)
    {
    	var openerWindow;
    	
    	try
        {
        	var exists = window.opener.document;
        	openerWindow = window.opener;
        	
        	openerWindow.open(item.href,'_self');
        }
        catch (ex)
        {
        	openerWindow = window;
        	openerWindow.open(item.href,'_blank');
        }
        
	openerWindow.focus();
	return false;
    } 
    
    this.TargetParent = TargetParent; 
    function TargetParent(item)
    {
         window.parent.open(item.href,'_self');
         try
         {
         	event.cancelBubble=true;
         	event.returnValue=false;
         }
         catch(e) { }
    }
   
    this.TargetNewWindow = TargetNewWindow; 
    function TargetNewWindow(item)
    {
         window.open(item.href);
         try
         {
         	event.cancelBubble=true;
         	event.returnValue=false;
         }
         catch(e) { }
    }
    
    this.SmartOpener = SmartOpener;
    function SmartOpener(item)
    {
    	try
    	{
    		window.opener.smartOpen(item.href);
    	}
    	catch (ex)
    	{
    		window.open(item.href,'_blank');
    	}
    }
    
	this.GenerateWindowFeatures = GenerateWindowFeatures;
	function GenerateWindowFeatures(location, status, menubar, toolbar, scrollbars, resizable, titlebar, width, height)
	{
		var IsIE = (navigator.userAgent.toString().toLowerCase().indexOf("msie") >=0) ? true : false;
		var features = new Array();		
		if(!location)
			features.push("location=0");
		else
			features.push("location=1");
		
		if(!status)
		    features.push("status=0");
		else
				features.push("status=1");
		  
		if(!menubar)
		    features.push("menubar=0");
		  else
		  	features.push("menubar=1");
	    
    if(toolbar || (!IsIE && location))
    {
    		features.push("toolbar=1");
    }
    else
    {	
    		features.push("toolbar=0");
    } 	
	       
	    if(!scrollbars)
	        features.push("scrollbars=0");
	    else
	    	features.push("scrollbars=1");
	       
	    if(!resizable)
	        features.push("resizable=0");
	    else
	    	features.push("resizable=1");
	       
	    if(!titlebar)
	        features.push("titlebar=0");
	     else
	     	features.push("titlebar=1");
	       
	    if(width != null && width != "")
	        features.push("width="+width);
		
		if(height != null && height != "")
	        features.push("height="+height);
	    
	    var strFeatures = "";
	     
	    for(i = 0; i< features.length; i++)
        {
            strFeatures += features[i]; 
            
            if(i != features.length-1)
                strFeatures += ","; 
        } 

	return strFeatures;
    }

//internal functions

    this.OpenPopUp = OpenPopUp;
    
    function OpenPopUp(item, popUpName, features)
    {
        return OpenPopUpUrl(item.href, popUpName, features);
    }
    
    this.OpenPopUpUrl = OpenPopUpUrl;
    
    function OpenPopUpUrl(Url, popUpName, features)
    {
        var OpenWindow = window.open(Url, popUpName, features);
        return OpenWindow;
    }
}

var popup = new PopupLib();

