var oInnerH;
var oInnerW;

document.write('<script src="_js\/getStockQuote.js"><\/' + 'script>');

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/* old -- did not work on IE7
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
*/

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}

function chkLyrState(cntry) {
	whichCntry = cntry;
	if (cntry.length>0) MM_swapImage('mainmap','','_images/maps_flags/DFC_global_' + cntry.toUpperCase() + '.gif',1);
	else MM_swapImage('mainmap','','_images/maps_flags/DFC_global.gif',1);
	status = document.getElementById("mainmap").src;
	if (cntry.length>0 && cntry!='undefined' && status.indexOf('_images/maps_flags/DFC_global_' + cntry.toUpperCase() + '.gif') > 0) toggleLayer('countryPopup',cntry,'show')
	//else if (document.getElementById("mainmap").src.indexOf('_images/map.gif') > 0) toggleLayer('countryPopup','','hide')
	else toggleLayer('countryPopup','','hide')
	//setInterval(function(){if (document.getElementById('countryPopup').style.visibility=='hidden' && status.indexOf('_images/map_' + cntry.toLowerCase() + '.gif') > 0)) document.getElementById('mainmap').src = "_images/map.gif; },250)
}

function toggleLayer(lyr,country,viz) {
	var lyrObj = document.getElementById(lyr);
	if (viz=='show'){
		if (st) clearTimeout(st);
		MM_showHideLayers(lyr,'','hide');
		var emailIcon="<img src=_images/email.gif width=14 height=11 align=absmiddle border=0>";
		var videoIcon="<img src=_images/video.gif width=14 height=11 align=absmiddle border=0>";
		var audioIcon="<img src=_images/audio.gif width=14 height=11 align=absmiddle border=0>";
		var formImg="<img src=_images/form.gif width=14 height=11 align=absmiddle border=0>";
		switch (country){
			case "US":		
							document.getElementById("prods").innerHTML="<a href=products.asp#loan>&bull; Cash &rsquo;Til Payday<sup style=font-size:75%>&reg</sup> loans</a><br><a href=products.asp#chkCash>&bull; Check Cashing</a><br><a href=products.asp#pp>&bull; Momentum Prepaid Visa<sup style=font-size:75%>&reg</sup></a><br><a href=products.asp#wu>&bull; Western Union Money Orders/Transfers</a>"
							document.getElementById("storeIcons").innerHTML="<a href=http://www.moneymart.com/MM/default.asp target=_blank><img src=_images/stores/logo_mm_sm.gif border=0>&nbsp;<img src=_images/stores/logo_lm_sm.gif hspace=8 border=0></a><br><a href=http://www.ccsfinancial.com target=_blank><img src=_images/stores/logo_ccs_sm.gif border=0 vspace=1></a><br><a href=http://www.americanpaydayloansinc.com target=_blank><img src=_images/stores/logo_apl_sm.gif border=0 vspace=1></a>";
							var cnt_US_F	= (arrStoreCnt[0]+arrStoreCnt[2]+arrStoreCnt[4]+arrStoreCnt[6]+arrStoreCnt[8]+arrStoreCnt[10]+arrStoreCnt[12]);
							var cnt_US_CO	= (arrStoreCnt[1]+arrStoreCnt[3]+arrStoreCnt[5]+arrStoreCnt[7]+arrStoreCnt[9]+arrStoreCnt[11]+arrStoreCnt[13]);
							if(cnt_US_F >0) {
								document.getElementById("lblFran").innerHTML="Franchised:&nbsp;";
								document.getElementById("franStore").innerHTML="<b>"+cnt_US_F+"</b>";
							} else {
								document.getElementById("lblFran").innerHTML="";
								document.getElementById("franStore").innerHTML="";
							}
							if(cnt_US_CO>0) {
								document.getElementById("lblComp").innerHTML="Company-Owned:&nbsp;";
								document.getElementById("compStore").innerHTML="<b>"+cnt_US_CO+"</b>";
							} else {
								document.getElementById("lblFran").innerHTML="";
								document.getElementById("franStore").innerHTML="";
							}
							document.getElementById("cust").innerHTML="&bull; Avg. Age 18-45<br>&bull; Employed Full Time<br>&bull; $26,000 Avg. Income<br>&bull; 38% of Check Cashers have Bank Accts"
							document.getElementById("franchEmail").href="mailto:franchise@moneymart.ca";
							document.getElementById("franchEmail").innerHTML=emailIcon+"&nbsp;Franchising Team (Money/Loan Mart)";
							document.getElementById("mediaLnk").href="_audios/UScomm.wma";
							document.getElementById("mediaLnk").innerHTML=audioIcon+" Click to hear a " + country + " sample commercial.";
							document.getElementById("countryName").innerHTML="United States of America";
							break
			case "CA":		
							document.getElementById("prods").innerHTML="<a href=products.asp#loan>&bull; Payday loans</a><br><a href=products.asp#chkCash>&bull; Cheque Cashing</a><br><a href=products.asp#pp>&bull; Titanium Prepaid MasterCard<sup style=font-size:75%>&reg</sup></a><br><a href=products.asp#curr>&bull; Currency Exchange</a><br><a href=products.asp#wu>&bull; Western Union Money Orders/Transfers</a>"
							document.getElementById("storeIcons").innerHTML="<a href=http://www.moneymart.ca/default.asp target=_blank><img src=_images/stores/logo_mm_sm.gif border=0></a>";
							var cnt_CA_F	= (arrStoreCnt[14]);
							var cnt_CA_CO	= (arrStoreCnt[15]);
							if(cnt_CA_F >0) {
								document.getElementById("lblFran").innerHTML="Franchised:&nbsp;";
								document.getElementById("franStore").innerHTML="<b>"+cnt_CA_F+"</b>";
							} else {
								document.getElementById("lblFran").innerHTML="";
								document.getElementById("franStore").innerHTML="";
							}
							if(cnt_CA_CO>0) {
								document.getElementById("lblComp").innerHTML="Company-Owned:&nbsp;";
								document.getElementById("compStore").innerHTML="<b>"+cnt_CA_CO+"</b>";
							} else {
								document.getElementById("lblFran").innerHTML="";
								document.getElementById("franStore").innerHTML="";
							}
							document.getElementById("cust").innerHTML="&bull; Avg. Age of 35<br>&bull; Employed Full Time<br>&bull; $24,000 Avg. Income<br>&bull; 66% of Check Cashers have Bank Accounts"
							document.getElementById("franchEmail").href="mailto:franchise@moneymart.ca";
							document.getElementById("franchEmail").innerHTML=emailIcon+"&nbsp;Franchising Team";
							document.getElementById("mediaLnk").href="_videos/CAcomm.wmv";
							document.getElementById("mediaLnk").innerHTML=videoIcon+" Click to watch a " + country + " sample commercial.";
							document.getElementById("countryName").innerHTML="Canada";
							break
			case "UK":		
							document.getElementById("prods").innerHTML="<a href=products.asp#loan>&bull; Cash Advances</a><br><a href=products.asp#chkCash>&bull; Cheque Cashing</a><br><a href=products.asp#pp>&bull; Titanium Prepaid MasterCard<sup style=font-size:75%>&reg</sup></a><br><a href=products.asp#curr>&bull; Currency Exchange</a><br><a href=products.asp#pawn>&bull; Pawn Broking</a><br><a href=products.asp#wu>&bull; Western Union Money Transfers</a>"
							document.getElementById("storeIcons").innerHTML="<a href=http://www.moneyshop.tv/ target=_blank><img src=_images/stores/logo_ms_sm.gif border=0></a>";
							var cnt_UK_F	= (arrStoreCnt[16]+arrStoreCnt[18]+arrStoreCnt[20]+arrStoreCnt[22]);
							var cnt_UK_CO	= (arrStoreCnt[17]+arrStoreCnt[19]+arrStoreCnt[21]+arrStoreCnt[23]);
							if(cnt_UK_F >0) {
								document.getElementById("lblFran").innerHTML="Franchised:&nbsp;";
								document.getElementById("franStore").innerHTML="<b>"+cnt_UK_F+"</b>";
							} else {
								document.getElementById("lblFran").innerHTML="";
								document.getElementById("franStore").innerHTML="";
							}
							if(cnt_UK_CO>0) {
								document.getElementById("lblComp").innerHTML="Company-Owned:&nbsp;";
								document.getElementById("compStore").innerHTML="<b>"+cnt_UK_CO+"</b>";
							} else {
								document.getElementById("lblFran").innerHTML="";
								document.getElementById("franStore").innerHTML="";
							}
							document.getElementById("cust").innerHTML="&bull; Avg. Age < 35<br>&bull; Employed Full Time<br>&bull; Income < $30,000<br>&bull; 80% of Customers have Bank Accounts"
							document.getElementById("franchEmail").href="#";//mailto:courtney.vaughan@dfguk.com";
							document.getElementById("franchEmail").innerHTML="no franchising available";//emailIcon+"&nbsp;Courtney Vaughan";
							document.getElementById("mediaLnk").href="_videos/UK_Gold.wmv";
							document.getElementById("mediaLnk").innerHTML=videoIcon+" Click to watch a " + country + " sample commercial.";
							document.getElementById("countryName").innerHTML="United Kingdom (England, Northern Ireland, Scotland and Wales)";
							break
			case "IRL":		
							document.getElementById("prods").innerHTML="<a href=products.asp#pawn>&bull; Gold and Jewelry buying</a><br><a href=products.asp#chkCash>&bull; Cheque Cashing</a><br><a href=products.asp#curr>&bull; Currency Exchange</a><br><a href=products.asp#wu>&bull; Western Union Money Transfers</a>"
							document.getElementById("storeIcons").innerHTML="<a href=http://www.moneyshop.tv/ target=_blank><img src=_images/stores/logo_ms_sm.gif border=0></a>";
							var cnt_IRL_F	= (arrStoreCnt[24]);
							var cnt_IRL_CO	= (arrStoreCnt[25]);
							if(cnt_IRL_F >0) {
								document.getElementById("lblFran").innerHTML="Franchised:&nbsp;";
								document.getElementById("franStore").innerHTML="<b>"+cnt_IRL_F+"</b>";
							} else {
								document.getElementById("lblFran").innerHTML="";
								document.getElementById("franStore").innerHTML="";
							}
							if(cnt_IRL_CO>0) {
								document.getElementById("lblComp").innerHTML="Company-Owned:&nbsp;";
								document.getElementById("compStore").innerHTML="<b>"+cnt_IRL_CO+"</b>";
							} else {
								document.getElementById("lblFran").innerHTML="";
								document.getElementById("franStore").innerHTML="";
							}
							document.getElementById("cust").innerHTML="&bull; Avg. Age < 35<br>&bull; Employed Full Time<br>&bull; Income < $30,000<br>&bull; 80% of Customers have Bank Accounts"
							document.getElementById("franchEmail").href="#";//mailto:courtney.vaughan@dfguk.com";
							document.getElementById("franchEmail").innerHTML="no franchising available";//emailIcon+"&nbsp;Courtney Vaughan";
							document.getElementById("mediaLnk").href="_videos/UK_Gold.wmv";
							document.getElementById("mediaLnk").innerHTML=videoIcon+" Click to watch a sample commercial.";
							document.getElementById("countryName").innerHTML="Republic of Ireland";
							break
		}
		oInnerH = parseInt(document.getElementById("popupInnerTbl").clientHeight);
		oInnerW = parseInt(document.getElementById("popupInnerTbl").clientWidth);
		setLyrPos();
		MM_showHideLayers(lyr,'','show');
	} else
		MM_showHideLayers(lyr,'','hide');
}

function toggleView(which,whichImg)
{
	which = document.getElementById(which);
	whichImg = document.getElementById(whichImg);
	if (which.style.display=='block')
	{
		which.style.display='none';
		whichImg.src='_images/plus.png';
		if (which.id=='feedSource') document.getElementById('af').style.display='inline';
		//if (which.id=='feedStaging') document.getElementById('ps').style.display='none';
	} 
	else
	{	
		which.style.display='block';
		whichImg.src='_images/minus.png';
		if (which.id=='feedSource') {
			document.getElementById('af').style.display='none';
			document.frmControlPanel.sitename.focus();
		}
		//if (which.id=='feedStaging' && parseInt(document.getElementById('stageCnt').innerText)>0) document.getElementById('ps').style.display='inline';
	}
}

function movedown(){
	if (window.moveupvar) clearTimeout(moveupvar)
	if (parseInt(scrollobj.style.top)>=(contentheight*(-1)+(cntrheight-20))){
		if (document.images["dn"].src!='_images/greenArrowDn.gif') MM_swapImage('dn','','_images/greenArrowDn.gif',1);
		if (document.images["up"].src!='_images/greenArrowUp.gif') MM_swapImage('up','','_images/greenArrowUp.gif',1);
		scrollobj.style.top=parseInt(scrollobj.style.top)-speed+"px";
	} else {
		if (document.images["dn"].src!='_images/grayArrowDn.gif') MM_swapImage('dn','','_images/grayArrowDn.gif',1);
		if (document.images["up"].src!='_images/greenArrowUp.gif') MM_swapImage('up','','_images/greenArrowUp.gif',1);
	}
	movedownvar=setTimeout("movedown()",20)
}

function moveup(){
	if (window.movedownvar) clearTimeout(movedownvar)
	if (parseInt(scrollobj.style.top)<=0){
		if (document.images["up"].src!='_images/greenArrowUp.gif') MM_swapImage('up','','_images/greenArrowUp.gif',1);
		if (document.images["dn"].src!='_images/greenArrowDn.gif') MM_swapImage('dn','','_images/greenArrowDn.gif',1);
		scrollobj.style.top=parseInt(scrollobj.style.top)+speed+"px";
	} else {
		if (document.images["up"].src!='_images/grayArrowUp.gif') MM_swapImage('up','','_images/grayArrowUp.gif',1);
		if (document.images["dn"].src!='_images/greenArrowDn.gif') MM_swapImage('dn','','_images/greenArrowDn.gif',1);
	}
	moveupvar=setTimeout("moveup()",20)
}

function stopscroll(){
	if (window.moveupvar) clearTimeout(moveupvar)
	if (window.movedownvar) clearTimeout(movedownvar)
}

function movetop(){
	stopscroll()
	scrollobj.style.top=0+"px"
}

function getNewsScroll_height(){
	scrollobj=document.getElementById ? document.getElementById("newsScroll") : document.all("newsScroll");
	contentheight=scrollobj.offsetHeight;
}

function openJobs(id){
	var url = "http://www." + id + ".jobs";
	jobWin = window.open(url,'jobby','menubar=yes,resizable=yes,scrollbars=auto');
}

function checkZIP_POST(val)
{
	var regex = new RegExp("^((\\d{5}-\\d{4})|(\\d{5})|([AaBbCcEeGgHhJjKkLlMmNnPpRrSsTtVvXxYy]\\d[A-Za-z]\\s?\\d[A-Za-z]\\d)|([A-PR-UWYZ]{1,2}[0-9]{1,2}[ABEHJMNPRVWXY]?)\\s?([0-9][ABD-HJLNP-UW-Z]{2})|(GIR)\\s?(0AA))$")
	retVal = regex.test(val);
	if (!retVal) {
		alert('The ZIP/Post code you entered [' + val + '] does not match the acceptable format/rules.');
		document.findStore.zipPostcode.value='';
		document.findStore.zipPostcode.focus();
	}
	return retVal;
}

function setLyrPos() {
	//alert(f_clientHeight());
	//alert(f_scrollTop());
	var posx = 0;
	var posy = 0;
	//if (!e) var e = window.event;
	if (document.layers) {
		posx = xMousePos;
		posy = yMousePos;
	}
	else {
		posx = xMousePos + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = yMousePos + document.body.scrollTop + document.documentElement.scrollTop;
	}
	var oLyr = document.getElementById('countryPopup');
	//alert('posX=' + posx + '\tposY=' + posy + '\noInnerH=' + oInnerH + '\toInnerW=' + oInnerW + '\noLyr.top=' + (posx-oInnerH) + '\toLyr.left=' + (posy-oInnerW));
	if (document.all) {
		var topPX = (posy - oInnerH - 8);
		var leftPX= (posx - oInnerW + 60);
	} else {
		var topPX = (posy - oInnerH - 30);
		var leftPX= (posx - oInnerW + 42);
	}
	if (topPX <= 0)
		oLyr.style.top = "0px";
	else
		oLyr.style.top = topPX - f_scrollTop() + "px";
		
	if (leftPX <=0) {
		oLyr.style.left = "0px";
		document.getElementById("popupPointer").style.left=leftPX+"px";
	}
	else {
		oLyr.style.left = leftPX - f_scrollLeft() + "px";
		document.getElementById("popupPointer").style.left="0px";
	}
}

function captureMousePosition(e) {
	//if (document.getElementById("countryPopup").style.visibility=='visible') setLyrPos();
	if (document.layers) {
		xMousePos = e.pageX;
		yMousePos = e.pageY;
		xMousePosMax = window.innerWidth+window.pageXOffset;
		yMousePosMax = window.innerHeight+window.pageYOffset;
	} else if (document.all) {
		xMousePos = window.event.x;//+document.body.scrollLeft;
		yMousePos = window.event.y;//+document.body.scrollTop;
		xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
		yMousePosMax = document.body.clientHeight+document.body.scrollTop;
	} else if (document.getElementById) {
		xMousePos = e.pageX;
		yMousePos = e.pageY;
		xMousePosMax = window.innerWidth+window.pageXOffset;
		yMousePosMax = window.innerHeight+window.pageYOffset;
	}
	//window.status = "xMousePos=" + xMousePos + ", yMousePos=" + yMousePos + ", xMousePosMax=" + xMousePosMax + ", yMousePosMax=" + yMousePosMax;
}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}

function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}

function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}

function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
