sHREF="http://www.thefinancials.com/Advertising.html";
sSRC="http://www.thefinancials.com/banners/BannerOurAdvert_Home.gif";
sALT="This Space Available. Click here to learn about advertising on thefinancials.com.";
sTARGET="_self";
sTEXT="";
sTEXTONLY="";
bAddRandomArg_IMG=true;
bAddRandomArg_LINK=true;
sCounter_FileName="";
sIESite="";
sGroupGlobal=""
sHEIGHT="0";
sWIDTH="0";

//for PIR
function show( id, state ){
	var what = document.getElementById( id );
	what.style.visibility = (state)?'visible':'hidden';
	what.style.display = (state)?'block':'none';
	if( state == true ) { what.style.zIndex = (max_z++); }
}

function GetRandomArg() {

	sGetRandomArg="";
	for (i = 0; i<25; i++) {
   		sGetRandomArg=sGetRandomArg+(Math.round(Math.random()*10));
   	}
 	return sGetRandomArg;	
}

function GetBanner(sSize,sGroup,bOption,sPID,sSiteID,sLoc) {
	sRandomArg=GetRandomArg();

	if (typeof(sSize)=='undefined') {
		sSize="";
	}
	if (typeof(sGroup)=='undefined') {
		sGroup="";
	}
	sGroupGlobal=sGroup;

	if (typeof(bOption)=='undefined') {
		bOption="";
	}
	if (typeof(sPID)=='undefined') {
		sPID="";
	} else {
		sPID=sPID.toUpperCase();
	}
	if (typeof(sSiteID)=='undefined') {
		sSiteID="";
	}
	sSiteID = String(sSiteID);
	if (sSiteID=="") {
		sSiteID="HOME";
	}
	if (sSiteID=="VORTEX") {
		sSiteID="CUR";
	}
	sGroup = String(sGroup);
	if (sGroup=="VORTEX") {
		sGroup="CUR";
	}
	if (typeof(sLoc)=='undefined') {
		sLoc="";
	}
	sSize=sSize.toUpperCase();
	sGroup=sGroup.toUpperCase();
	sSiteID=sSiteID.toUpperCase();
	sLoc=sLoc.toUpperCase();

	switch (sSize) {
	case "L" : 
		//ACM
		sTEXTONLY="<object width='468' height='60' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'>"
		sTEXTONLY = sTEXTONLY+"<param name='movie' value='http://www.thefinancials.com/banners/ACM_468x60_devises.swf?target=_blank&clickTAG=http://www.ac-markets.com/forex/?source=41&kw=fullbanner'/>"
		sTEXTONLY = sTEXTONLY+"<param name='quality' value='best' />"			
		sTEXTONLY = sTEXTONLY+"<a href='http://www.thefinancials.com/CT_ACM_468x60.html' target='_blank'><img src='http://www.thefinancials.com/banners/ACM_468x60_devises.gif' border='0'></a>"
		sTEXTONLY = sTEXTONLY+"</object>"
		sCounter_FileName="http://www.thefinancials.com/banners/acm_count_468x60.gif";
		break;

	case "TALL" : 
		//ACM
		sTEXTONLY="<object width='120' height='600' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'>"
		sTEXTONLY = sTEXTONLY+"<param name='movie' value='http://www.thefinancials.com/banners/ACM_120x600_watch.swf?target=_blank&clickTAG=http://www.ac-markets.com/forex/?source=41&kw=sky'/>"
		sTEXTONLY = sTEXTONLY+"<param name='quality' value='best' />"			
		sTEXTONLY = sTEXTONLY+"<a href='http://www.thefinancials.com/CT_ACM_120x600.html' target='_blank'><img src='http://www.thefinancials.com/banners/ACM_120x600A.gif' border='0'></a>"
		sTEXTONLY = sTEXTONLY+"</object>"
		sCounter_FileName="http://www.thefinancials.com/banners/acm_count_120x600.gif";
		break;

	case "TILE_270" : 
		//ACM
		sTEXTONLY="<object width='270' height='90' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'>"
		sTEXTONLY = sTEXTONLY+"<param name='movie' value='http://www.thefinancials.com/banners/ACM_270x90_devises.swf?target=_blank&clickTAG=http://www.ac-markets.com/forex/?source=41&kw=270x90'/>"
		sTEXTONLY = sTEXTONLY+"<param name='quality' value='best' />"			
		sTEXTONLY = sTEXTONLY+"<a href='http://www.thefinancials.com/CT_ACM_270x90.html' target='_blank'><img src='http://www.thefinancials.com/banners/ACM_270x90.gif' border='0'></a>"
		sTEXTONLY = sTEXTONLY+"</object>"
		sCounter_FileName="http://www.thefinancials.com/banners/acm_count_270x90.gif";
		break;

	case "RECT" : 
		if (sGroup=="HOME_BOTTOM") {
			//COMMODITY CALENDAR
			sHEIGHT="60";
			sWIDTH="468";
			sTARGET="_blank";
			sALT="Visit CommodityCalendar.com";
			sTEXTONLY="";
			sSRC="http://www.thefinancials.com/banners/CC_468x60.gif";	
			sHREF="http://www.thefinancials.com/CT_CC_468x60.html";		
		} else {
			//ACM
			sTEXTONLY="<object width='336' height='280' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'>"
			sTEXTONLY = sTEXTONLY+"<param name='movie' value='http://www.thefinancials.com/banners/ACM_336x280_billboard.swf?target=_blank&clickTAG=http://www.ac-markets.com/forex/?source=41&kw=billboard'/>"
			sTEXTONLY = sTEXTONLY+"<param name='quality' value='best' />"			
			sTEXTONLY = sTEXTONLY+"<a href='http://www.thefinancials.com/CT_ACM_336x280.html' target='_blank'><img src='http://www.thefinancials.com/banners/ACM_336x280A.gif' border='0'></a>"
			sTEXTONLY = sTEXTONLY+"</object>"
			sCounter_FileName="http://www.thefinancials.com/banners/acm_count_336x280.gif";
		}
		break;

	case "M", "TILE" : 
		//SAXO
		sHEIGHT="60";
		sWIDTH="125";
		bAddRandomArg_IMG=false;
		sTARGET="_top";
		sALT="Visit www.SaxoBank.com";
		sSRC="http://adserver.adtech.de/adserv|3.0|663|1493190|0|1483|ADTECH;AdId=1648505;BnId=-1;loc=300;misc=[TIMESTAMP]";
		sHREF="http://www.thefinancials.com/CT_SB_125x60.html";
		sTEXTONLY=""
		sCounter_FileName="SB_counter_S.gif";
		break;

	case "S" : 
		//SAXO
		sHEIGHT="31";
		sWIDTH="88";
		bAddRandomArg_IMG=false;
		sTARGET="_top";
		sALT="Visit www.SaxoBank.com";
		sSRC="http://adserver.adtech.de/adserv|3.0|663|1254229|0|13|ADTECH;AdId=1647917;BnId=-1;loc=300;misc=[TIMESTAMP]";
		sHREF="http://www.thefinancials.com/CT_SB_88x31.html";
		sTEXTONLY=""
		sCounter_FileName="SB_counter_S.gif";
		break;

	case "T" : 
 
		//SAXO
		sHEIGHT="60";
		sWIDTH="125";
		bAddRandomArg_IMG=false;
		sTARGET="_top";
		sALT="Visit www.SaxoBank.com";
		sSRC="http://adserver.adtech.de/adserv|3.0|663|1493190|0|1483|ADTECH;AdId=1648505;BnId=-1;loc=300;misc=[TIMESTAMP]";
		sHREF="http://www.thefinancials.com/CT_SB_125x60.html";
		sTEXTONLY=""
		sCounter_FileName="SB_counter_S.gif";
		break;

	}

	if (sTEXTONLY) {
		sGetBanner=sTEXTONLY;
		if (sCounter_FileName!="") {
			sGetBanner=sGetBanner + "<img border='0' src='" + sCounter_FileName + "?ord=" + sRandomArg + "' width='1' height='1'>";
		}
	} else {
		if (sTEXT) {
			sGetBanner=sTEXT;
		} else {
			sGetBanner="";
		}
		sGetBanner=sGetBanner+"<a target='" + sTARGET + "' href='" + sHREF
		if (bAddRandomArg_LINK) {
			sRandomArg=sRandomArg + "?";
			sGetBanner=sGetBanner+ "?ord=" + sRandomArg 
		}
		sGetBanner=sGetBanner+ "'><img border='0' src='" + sSRC 
		if (bAddRandomArg_IMG) {
			sGetBanner=sGetBanner+"?ord=" + sRandomArg;
		} 
		sGetBanner=sGetBanner + "' alt='" + sALT + "' width='" + sWIDTH + "' height='" + sHEIGHT +"' name='Banner'></a>";
		if (sCounter_FileName!="") {
			sGetBanner=sGetBanner + "<img border='0' src='" + sCounter_FileName + "?ord=" + sRandomArg + "' width='1' height='1'>";
		}
	}
	return sGetBanner;
}

// begin popup code
// Browser Detection
isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
NS4 = (document.layers) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IE4plus = (document.all) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;

IE6 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? true : false;
ver4 = (NS4 || IE4plus) ? true : false;
NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;

IE5plus = IE5 || IE6;
IEMajor = 0;

if (IE4plus)
{
	var start = navigator.appVersion.indexOf("MSIE");
	var end = navigator.appVersion.indexOf(".",start);
	IEMajor = parseInt(navigator.appVersion.substring(start+5,end));
	IE5plus = (IEMajor>=5) ? true : false;
}

// Body onload utility (supports multiple onload functions)
var gSafeOnload = new Array();
function SafeAddOnload(f)
{
	if (IEmac && IE4)  // IE 4.5 blows out on testing window.onload
	{
		window.onload = SafeOnload;
		gSafeOnload[gSafeOnload.length] = f;
	}
	else if  (window.onload)
	{
		if (window.onload != SafeOnload)
		{
			gSafeOnload[0] = window.onload;
			window.onload = SafeOnload;
		}		
		gSafeOnload[gSafeOnload.length] = f;
	}
	else
		window.onload = f;
}
function SafeOnload()
{
	for (var i=0;i<gSafeOnload.length;i++)
		gSafeOnload[i]();
}

function isInt(numIn)
{
	var checknum = parseInt(numIn);
	return !isNaN(checknum);
}

function PUW_Init()
{
	if (gPopupWindow.CheckFrequency())
	{
		setTimeout("gPopupWindow.Show()",gPopupWindow.showDelay);
	}
}

function PUW_Show()
{
	var settings = "width="+this.width+",height="+this.height+",top="+this.top+",left="+this.left+",";
	settings += "scrollbars=" + ((this.scrollbars) ? "yes," : "no,");
	settings += "toolbar=" + ((this.toolbar) ? "yes," : "no,");
	settings += "location=" + ((this.locationbar) ? "yes," : "no,");
	settings += "menubar=" + ((this.menubar) ? "yes," : "no,");
	settings += "status=" + ((this.statusbar) ? "yes," : "no,");
	settings += "resizable=" + ((this.resizable) ? "yes" : "no");
	
	var newWin = window.open(this.url,this.name,settings);
	
	if (! this.ontop)
		window.focus();
}

function PUW_CheckFrequency()
{
	var shouldShow = this.frequency != 0;
	if (this.frequency > 0)
	{
		var allCookies = document.cookie;
		var start = allCookies.indexOf("PUWCount=");
		if (start >= 0)
		{
			var end = allCookies.indexOf(";",start);
			if (end < 0)
				end = allCookies.length;
			var freqStr = allCookies.substring(start+9,end);
			if (isInt(freqStr))
				this.frequency = parseInt(freqStr);
		}

		if (this.frequency>0)
			this.frequency--;
		else
			shouldShow = false;
			
		var exp = new Date();
		exp.setTime(exp.getTime()+this.renew*60*60000);
		document.cookie = "PUWCount="+this.frequency+ "; expires=" + exp.toGMTString();
	}
	
	return shouldShow;
}


function PopupWindow(url,width,height)
{
	this.width = width;
	this.height = height;
	this.top = screen.availHeight/2 - height/2; // center
	this.left = screen.availWidth/2 - width/2; // center
	this.name = "mypopupwin";
	this.url = url;
	this.showDelay = 2000;
	this.frequency = 2; // how many times show per renewal time period
	this.renew = 1; // renew showing every x hours
	this.scrollbars= true;
	this.toolbar= true;
	this.statusbar= true;
	this.resizable = true;
	this.locationbar = true;
	this.menubar = true;
	this.ontop = false;	
	this.Init = PUW_Init;
	this.Show = PUW_Show;
	this.CheckFrequency = PUW_CheckFrequency;
}

function PUWStart()
{
	gPopupWindow.Init();
}

if (sGroupGlobal!="COBRAND") {

	SafeAddOnload(PUWStart);

	gPopupWindow = new PopupWindow("http://www.thefinancials.com/PU_ACM.html", 361, 305);		

	gPopupWindow ="";
	gPopupWindow.toolbar = true;
	gPopupWindow.statusbar = true;
	gPopupWindow.resizable = true;
	gPopupWindow.ontop = false;
	gPopupWindow.scrollbars = true;
	gPopupWindow.frequency = 1
}

// end popup code
