﻿/***********************
    Open Page Functions
***********************/
function GlobalOpenHelpGoPage(key,warn,popupName)  {
    GlobalOpenHelpPage("/go.aspx?to="+key,warn,popupName);
}


function GlobalOpenHelpPage(url,warn,popupName)  {
    if (popupName==undefined)  {popupName='HelpPopupPage';}
    GlobalOpenPage(url,warn,true,popupName,"height=480px,width=990px,scrollbars=1,location=0,menubar=1,toolbar=0,resizable=1");
}


function GlobalOpenNewGoPage(key,warn,popupName)  {
    GlobalOpenGoPage(key,warn,true,popupName);
}


function GlobalOpenGoPage(key,warn,popup,popupName,popupSettings)  {
    GlobalOpenPage("/go.aspx?to="+key,warn,popup,popupName,popupSettings);
}


function GlobalOpenNewPage(url,warn,popupName)  {
    GlobalOpenPage(url,warn,true,popupName);
}


function GlobalOpenPage(url,warn,popup,popupName,popupSettings)  {

    // Set Defaults for optional parameters
    if (warn==undefined)  {warn=false;}
    if (popup==undefined)  {popup=false;}
    if (popupName==undefined)  {popupName="";}
    if (popupSettings==undefined)  {popupSettings="";}
    
    
    // See if we should warn the user that they are leaving
    // the site and give them a chance to stay.
    if (warn)  {
        if (!GlobalLeavingSiteConfirmed())  {
            return false;
        }
    }
    
    
    // Should this open as a popup or not
    if (popup)  {
        window.open(url,popupName,popupSettings);
    }  else  {
        window.location.href=url;
    }
}


function GlobalOpenGoPageOnMainWindow(key,warn)
{
    GlobalOpenPageOnMainWindow("/go.aspx?to="+key,warn);
}


function GlobalOpenPageOnMainWindow(url,warn)
{		
    // Set Defaults for optional parameters
    if (warn==undefined)  {warn=false;}

    // See if we should warn the user that they are leaving
    // the site and give them a chance to stay.
    if (warn)  {
        if (!GlobalLeavingSiteConfirmed())  {
            return false;
        }
    }
    
    
	if (top.opener) {
		//set focus on the main window and load destination
		top.opener.location.href=url;
		top.opener.focus()	
	} else {
		// Give the main window a name we refer to that when top fails
		var defaultwindow = window.open("", "default");
		if(defaultwindow) {
			defaultwindow.focus();
			defaultwindow.location.href=url;	
		}
		else { window.open (url); }
	}	
}


function GlobalLeavingSiteConfirmed()  {
    return confirm("You are now leaving the Robert W. Baird Web site. We do not endorse nor are responsible for the content of other Web sites. Please read the \"Terms and Conditions\" in the \"Help\" section of our Web site for more information. Do you wish to proceed?");
}


/*
    Utillity Functions
*/

function GlobalPreloadImage(url)
{
	var img = null;
	
	if (document.images)
	{
		img = new Image();
		img.src = sURL;
	}
	return img;
}

