var srcGEMID1 = getURLParam('GEMID1')
var srcGEMID2 = getURLParam('GEMID2')
var srcGEMIDaff = getURLParam('GEMIDAFF')
var strDomain = ".gemoney.com.au"			// Enter top level domain here

if (srcGEMID1 != "") {
	var expDateID1 = new Date()
	expDateID1.setDate(expDateID1.getDate()+30)
	document.cookie = "Src_GEMID1=" + escape(srcGEMID1) + ";expires=" + expDateID1.toGMTString() + ";path=/ ;domain=" + strDomain
	}

if (srcGEMID2 != "") {
	document.cookie = "Src_GEMID2=" + escape(srcGEMID2) + ";path=/ ;domain=" + strDomain
	}

if (srcGEMIDaff != "") {
	var expDateaff = new Date()
	expDateaff.setDate(expDateaff.getDate()+60)
	document.cookie = "Src_GEMIDAFF=" + escape(srcGEMIDaff) + ";expires=" + expDateaff.toGMTString() + ";path=/ ;domain=" + strDomain
	}

function getURLParam(strParamName){
	var strReturn = "";
	var strHref = window.location.href.toUpperCase();
	
	if ( strHref.indexOf("?") > -1 ){
		var strQueryString = strHref.substr(strHref.indexOf("?"));
		var aQueryString = strQueryString.split("&");
		
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
			if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
				var aParam = aQueryString[iParam].split("=");
				strReturn = aParam[1];
				break;
				}
			}
		}
	return strReturn;
	}
	
function openApplication(product) {
	
	if (screen.height && screen.width) {
		height = screen.height - 80;
	} else {
		height = 520;
	}
	
	if (product == "lowrate") {
		var theURL = "https://apply.gemoney.com.au/eapps/Apply.faces?cardType=lowrate" }

	if (product == "source") {
		var theURL = "https://apply.gemoney.com.au/eapps/Apply.faces?cardType=source" }

	if (product == "myer") {
		var theURL = "https://apply.gemoney.com.au/eapps/Apply.faces?cardType=myer" }	
		
	if (product == "eco") {
		var theURL = "https://apply.gemoney.com.au/eapps/Apply.faces?cardType=eco" }
		
	if (product == "wizard") {
		var theURL = "https://apply.wizard.com.au/eapps/Apply.faces?cardType=wizard" }
	
	if (product == "go") {
		var theURL = "https://apply.gomastercard.com.au/eapps/ApplyRetail.faces?cardType=go" }
	
	var width = "622";
	var screenY = screen.height;
	var screenX = screen.width;
	var topvar = 0;
	var leftvar = (screenX - width) / 2;
 	window.open(theURL,'','resizable=no,scrollbars=yes,toolbar=no,menubar=no,location=no,status=yes,top='+topvar+',left='+leftvar+',width='+width+',height='+height+'');
}


function openPopup(pageName) {
	if (screen.height && screen.width) {
		height = screen.height - 80;
	} else {
		height = 520;
	}
	
	if (pageName == "tellafriend") {
		var theURL = "https://eform.gemoney.com.au/eform/Page.do?eFormName=gemoneyau_eco_tellfriend_eco" }

	if (pageName == "treetellafriend") {
		var theURL = "https://eform.gemoney.com.au/eform/Page.do?eFormName=gemoneyau_eco_tellfriend_tree" }
		
	if (pageName == "treeform") {
		var theURL = "https://eform.gemoney.com.au/eform/Page.do?eFormName=gemoneyau_eco_registration" }
	
	var width = "800";
	var screenY = screen.height;
	var screenX = screen.width;
	var topvar = 0;
	var leftvar = (screenX - width) / 2;
 	window.open(theURL,'','resizable=no,scrollbars=yes,toolbar=no,menubar=no,location=no,status=yes,top='+topvar+',left='+leftvar+',width='+width+',height='+height+'');
}
