var GlossaryPopup = null;
var TipsTricksPopup = null;
var GenericPopup = null;
var SecurePopup = null;
var LinkPopup = null;
var strBaseUrl;
var strSecureBaseUrl;

strBaseURL = 'http://' + location.hostname + '/';
strSecureBaseURL = 'https://' + location.hostname + '/';

function FormatUrl(pstrIsSecure,pstrURL) {
	if (pstrIsSecure == 'Y')
		return strSecureBaseURL + pstrURL;
	else
		return strBaseURL + pstrURL;
}

function GetURL(pstrIsSecure,pstrURL) {
	return FormatUrl(pstrIsSecure,pstrURL)
}

function DisplayPDF(pstrURL,pstrName,pintWidth,pintHeight){
	window.open(pstrURL,pstrName,"width=" + pintWidth + ",height=" + pintHeight + ",toolbar=0,location=0,directories=0,resizable=1,status=0,menubar=0,scrollbars=1");
}



function GoToLink(pstrIsSecure,pstrURL) {
	if (pstrIsSecure == 'N') {
		pstrURL = strBaseURL + pstrURL
	} else {
		pstrURL = strSecureBaseURL + pstrURL
	}
		location.href = pstrURL
}


function OpenSecurePopup(pstrURL, pstrName, pintwidth, pintheight, pshowMenu) {
	SecurePopup = OpenPopup(FormatUrl('Y',pstrURL), pstrName, pintwidth, pintheight, pshowMenu);
}

function OpenGenericPopup(pstrURL, pstrName, pintwidth, pintheight, pshowMenu) {
	GenericPopup = OpenPopup(FormatUrl('N',pstrURL), pstrName, pintwidth, pintheight, pshowMenu);
}

function OpenGuaranteePopup(pstrURL, pstrName, pintwidth, pintheight, pshowMenu) {
	GuaranteePopup = OpenPopup(FormatUrl('N',pstrURL), pstrName, pintwidth, pintheight, pshowMenu);
}

function OpenRateWatchPopup(pstrFullURL) {
	RatePopup = OpenPopup(pstrFullURL,'RateWatch',530,450,false);
}

function OpenGlossaryPopup(plngTermID) {
	GlossaryPopup = OpenPopup(strBaseURL + 'ResourceCenter/PopupGlossary.asp?GID=' + plngTermID,'Glossary',340,250,false);
}

function OpenTipPopup(plngTipID) {
	TipsTricksPopup = null;
	TipsTricksPopup = window.open(strBaseURL + 'ResourceCenter/PopupTip.asp?TID=' + plngTipID,'Tip',"width=450,height=500,toolbar=0,location=0,directories=0,resizable=1,status=1,menubar=0,scrollbars=1");
}

function OpenLinkPopup(pstrFullURL, pstrName, pintwidth, pintheight) {
	if (LinkPopup != null) {
		if (LinkPopup.closed == false)
			LinkPopup.close()
	}
	LinkPopup = window.open(pstrFullURL,pstrName,"width=" + pintwidth + ",height=" + pintheight + ",toolbar=0,location=0,directories=0,resizable=1,status=1,menubar=1,scrollbars=1");
	return LinkPopup;
}

function OpenPopup(pstrFullURL, pstrName, pintwidth, pintheight, pshowMenu) {
	Popup = null;
	if (pshowMenu) {
		Popup = window.open(pstrFullURL,pstrName,"width=" + pintwidth + ",height=" + pintheight + ",toolbar=0,location=0,directories=0,resizable=0,status=1,menubar=1,scrollbars=1");
	} else {
		Popup = window.open(pstrFullURL,pstrName,"width=" + pintwidth + ",height=" + pintheight + ",toolbar=0,location=0,directories=0,resizable=0,status=1,menubar=0,scrollbars=1");
	}
	//Popup.focus();
	return Popup;
}

function CloseOpenPopups() {

	if(GenericPopup != null) {
		if (GenericPopup.closed == false)
			GenericPopup.close()
	}
	if(SecurePopup != null) {
		if (SecurePopup.closed == false)
			SecurePopup.close()
	}
	if(GlossaryPopup != null) {
		if (GlossaryPopup.closed == false)
			GlossaryPopup.close()
	}
	if(TipsTricksPopup != null) {
		if (TipsTricksPopup.closed == false)
			TipsTricksPopup.close()
	}
	if(LinkPopup != null) {
		if (LinkPopup.closed == false)
			LinkPopup.close()
	}
}