
	/*
		GENERAL POPUP WITH DEFAULT FEATURES
	*/	
	function generalpop(url) {
		if(url=="noclick") return;
	
		if(url=="purchase()")
		{
			purchase();
			return;
		}		
						
		// run a javascript function	
		if(url.substring(0,11).toLowerCase() == "javascript:")
		{			
			eval("try{" + url.substring(11) + "}catch(e){}");
			return;
		}
		
		
		url= url.replace("SITEID",document.CashierForm.siteID.value);		
		url= url.replace("NETWORKID",document.CashierForm.networkID.value);
		url= url.replace("USERID",document.CashierForm.cid.value);
		url= url.replace("SESSIONID",document.CashierForm.sid.value);
		
		
		// if there is a pipe found in the url string - use the string after the comma as the window features
		var a = url.split("|");
		if(a.length > 1)
			wn = window.open(a[0], a[1], a[2]);
		else
			wn = window.open(url, "genpop", "height=600,width=600,top=5,left=5,resizable,scrollbars");
			
		try{wn.focus()}catch(e){};
	}

	/*
		NAVIGATE THE SITE TO A NEW PAGE
	*/	
	function navsite(url) {
		if(url=="noclick") return;
		var p = window.opener;
		
		if(p){
			try{					
				p.document.location.href=url;	
				p.focus();
				}
			catch(e)
				{			
				p = window.open(url, "site");
				p.focus();		
				}				
		}else{
			p = window.open(url, "site");
			try{p.focus()}catch(e){};	
		}		
	}
	
	function register(){		
		var loc;
		var win = window.location.toString();
				
		if (win.indexOf("skin") > 0){			
			loc = "register.php";
		}else{
			loc = "skin/register.php";
		}
		
		var p = window.opener;
		
		if(p){
			try{					
				p.document.location.href = loc;	
				p.focus();
				}
			catch(e)
				{			
				p = window.open(loc, "site");
				p.focus();		
				}				
		}else{
			p = window.open(loc, "site");
			try{p.focus()}catch(e){};	
		}
		
	}

	/*
		CALLED WHEN A PLAYER LOGS DIRECTLY INTO THE GAME
	*/
	function login(u,s,a,c) {		
		with(document.CashierForm){
			playerCurrency.value = c;
			playerAlias.value = a;
			cid.value=u;
			sid.value=s;
		}
	}

	/*
		CALLED WHEN A PLAYER CLICKS THE BANKING BUTTON
	*/	
	function purchase(u,s,a,c) {	
		if (navigator.appName.indexOf("Microsoft") != -1) {
		  wb = window.open("", "AquaPayCashier", "height=576,width=700,top=100,left=100");
		} else {
		  wb = window.open("", "AquaPayCashier", "height=576,width=700,screenY=100,screenX=100");
		}
		document.CashierForm.submit();
		return;
	}
	
	
	/*
		PLAY AN INSTANT GAME
	*/
	
	var igwn;
	function BI(gameID,gameName,realBalance,gameURL,width,height) 
	{		
		/* if there is a problem with all the Instant Games of Eyecon, here are the games which need to be removed */
		/*
		if(gameID == 19 || gameID == 20 || gameID == 16 || gameID == 101 || gameID == 102 || gameID == 103 || gameID == 104 || gameID == 105 || gameID == 108 || gameID == 109 || gameID == 110 || gameID == 111 || gameID == 112 || gameID == 113 || gameID == 114 || gameID == 115 || gameID == 116)
		*/
		if(gameID == 19 || gameID == 20 || gameID == 16)
		{	
			alert("Sorry, this game is currently unavailable.");
			return;
		}
		
		// to put the game in spanish prefix the gameName with es_
		if(gameName.substring(0,3) == "es_")
		{
			var lang = "es";
			gameName = gameName.substring(3);
		}
		else
		{
			var lang = "en";		
		}
		
		gameURL = gameURL.replace("LANGUAGE",lang);	
		gameURL = gameURL.replace("USERID",document.CashierForm.cid.value);
		gameURL = gameURL.replace("SESSIONID",document.CashierForm.sid.value);
		gameURL = gameURL.replace("GAMENAME",gameName);
		gameURL = gameURL.replace("BALANCE",realBalance);
		gameURL = gameURL.replace("CURRENCY",document.CashierForm.playerCurrency.value);
		gameURL = gameURL.replace("NETWORK",document.CashierForm.network.value);
		gameURL = gameURL.replace("NUMERIC_NID",document.CashierForm.networkID.value);
		
		gameURL = gameURL.replace("GAMEID",gameID);
		gameURL = gameURL+"&width=" + width + "&height=" + height;

		var sh = screen.height / 2 - 250;	
		biWH = "width=" + width + ",height=" + height + ",top="+sh+",left=150";
		if (igwn != null) igwn.close();
		igwn = window.open(gameURL,'igw','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,'+biWH);
		try{wn.focus()}
		catch(e){}			
	}
	
	/*
		CALLED WHEN A PLAYER CLICKS THE CLOSE BUTTON
	*/	
	function closeWindow(){
		if (navigator.appName.indexOf("Microsoft") != -1) {
			window.close();
		} else {
			parent.window.close();
		}		
	}
	
	
  function IG(gameID,gameName,provider,width,height) {	
	
	
	
		var gameURL;
		switch(provider){
		case "electro":
			gameURL="http://instants.gib.ccsaint.net/cgi-bin/pmib.fcg?act=stonestart&uid=USERID&guid=SESSIONID&dest=/spg/flash/GAMENAME&nid=NETWORK&gid=GAMEID&vid=1&cur=CURRENCY";
			break;
		case "kaave":
			gameURL="https://www.abgu.com/games/mac/en/mgames.jsp?from=stone&uid=USERID&guid=SESSIONID&gameid=GAMENAME&nid=NETWORK&gid=GAMEID&vid=2&cur=CURRENCY";
			break;
		case "supa":
			gameURL="https://www.web-secure-connect.com/nebo/servlet/NeboAPIServlet?uid=USERID&gameid=GAMENAME&guid=SESSIONID&brand=sto&nid=NETWORK&gid=GAMEID&vid=3&cur=CURRENCY";
			break;
		}
		
		gameURL = gameURL.replace("USERID",document.CashierForm.cid.value);
		gameURL = gameURL.replace("SESSIONID",document.CashierForm.sid.value);
		gameURL = gameURL.replace("GAMENAME",gameName);		
		gameURL = gameURL.replace("CURRENCY",document.CashierForm.playerCurrency.value);
		gameURL = gameURL.replace("NETWORK",document.CashierForm.network.value);
		gameURL = gameURL.replace("GAMEID",gameID);
		var sh = screen.height / 2 - 250;				
		biWH = "width=" + width + ",height=" + height + ",top="+sh+",left=150"+",resizable=no";
		
		wn = window.open(gameURL,'igw','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,'+biWH);
		try{wn.focus()}
		catch(e){}			
		
		
	}