﻿//JS
function SendActionIPN(res)
{
    if(res!="0")
    {
        var sc1=document.createElement("script");
        sc1.id="wct_js_ipn";
        sc1.type="text/javascript";
        sc1.src="http://www.ssegames.com/ashx/encrypt.ashx"+res;
        
	    document.getElementsByTagName("head")[0].appendChild(sc1);        
    }
    return;  
}

function CreateJS(param)
{
	var sc=document.createElement("script");
	sc.id="wct_js";
	sc.type="text/javascript";
	sc.src="http://track.yoothy.com/"+param;
	document.getElementsByTagName("head")[0].appendChild(sc);
}

function Browser()
{
	var userinfo=navigator.userAgent.toLowerCase();
	var U_BS  = /(firefox|netscape|opera|chrome|msie|safari).?[\d\.]+/.exec(userinfo);
	this.BS=U_BS[0].replace(" ","/");
	var win_height=window.parent.screen.height;
	var win_width=window.parent.screen.width;
	this.Ration=win_width+"*"+win_height;
}

function OperationSystem()
{
	var userinfos=navigator.userAgent.toLowerCase();
	var U_OS=/(windows) (nt) ([0-9]+)\.([0-9]+)/.exec(userinfos);
	switch(U_OS[0])
	{
		case "windows nt 5.0":
			this.OS="Windwos 2000";
			break;
		case "windows nt 5.1":
			this.OS="Windwos xp";
			break;
		case "windows nt 5.2":
			this.OS="Windows 2003";
			break;
		case "windows nt 6.0":
			this.OS="Windows Vista";
		default:
			this.OS="Mac OS";
			break;
	}
}

function getFromURL()
{
	var fromURL=top.document.referrer;
	var currenturl=window.location.href;
	var temp_fromURL=fromURL.split("/");
	var temp_currenturl=currenturl.split("/");
	if(fromURL=="" || temp_fromURL[2]==temp_currenturl[2]) fromURL="about:blank";
	this._Fromurl=fromURL;
	this._Currenturl=currenturl;
	this._DetailPage=getRegxChar(currenturl,"1");
	return;
}

function getRegxChar(str,type)
{
	switch(type)
	{
		case "1": var temp=str.split("/");var index=parseInt(temp.length-1);if(temp[index]||temp[index]!=""){return temp[index].substring(0,temp[index].lastIndexOf('.'));}return "index";
	}
}

function Main(pagename)
{
	try
	{
		var p= new getFromURL();
		var br=new Browser();
		//var optionsystem= new OperationSystem();
		var FirstEnterPage=p._Currenturl; 
		var FromURL=p._Fromurl; 
		/**************************************/
		var SerialNo = hSerialNo!=null?hSerialNo:"";
		var VisitPageDetail=hPageDetail!=null?hPageDetail:p._DetailPage;
		var MoneyCode = hMoneyCode!=null?hMoneyCode:"USD";
		var VisitBal = hBal!=null&&hBal!=""?hBal:"0";
		var Game = hGame!=null?hGame:"";
		var Server = hServer!=null?hServer:"";
		var VisitVolume = hVolume!=null&&hVolume!=""?hVolume:"0";
		var Payment = hPayment!=null?hPayment:"0";
		var Delivery = hDelivery!=null?hDelivery:"0";
		//var GEOrderID = hGEOrderID!=null?hGEOrderID:"0";
		var Login = hLogin!=null?hLogin:"0";
		var Email = hEmail!=null?hEmail:"0";
		var CharacterName = hCharacterName!=null?hCharacterName:"";
		var WebSite = hWebSite!=null?hWebSite:"0";
		var ItemDescription=hItemDescription!=null?hItemDescription:"0";

		if(pagename!="")
			VisitPageDetail=pagename;
		var CurrentURL=p._Currenturl; 
		//var OpSystem=optionsystem.OS; 
		var IeType=br.BS; 
		//var SysRation=br.Ration;

		if(FromURL=="about:blank"&&CurrentURL.indexOf("gclid=")>0)
		FromURL="http://www.google.com";
		var param="?a="+escape(SerialNo)+
				  "&b="+escape(FromURL)+
				  "&c="+escape(FirstEnterPage)+
				  "&d="+escape(VisitPageDetail)+
				  "&e="+escape(CurrentURL)+
				  //"&f="+escape(OpSystem)+
				  "&g="+escape(IeType)+
				  //"&h="+escape(SysRation)+
				  "&i="+escape(MoneyCode)+
				  "&j="+escape(VisitBal)+
				  "&k="+escape(Game)+
				  "&l="+escape(Server)+
				  "&m="+escape(VisitVolume)+
				  "&n="+escape(Payment)+
				  //"&o="+escape(GEOrderID)+
				  "&p="+escape(Login)+
				  "&q="+escape(Email)+
				  "&r="+escape(CharacterName)+
				  "&s="+escape(WebSite)+
				  "&t="+escape(ItemDescription);
		if(SerialNo!="")
		{

			SendActionIPN(param)
		}	
	}
	catch (e)
	{
		var ce="?a="+hSerialNo+"=about:blank&c=0&e=0&g=0&h=0&i=0&j="+e.message+"&k=0&l=&m=0&n=0&o=0&p=0&q=&r=&s=itemstores&t=";
		SendActionIPN(ce);
	}
	
}
