﻿	
var judgeMark = 1;
	
function getArg(theStr, theKey)
{
	var result;
  var i = theStr.indexOf(theKey);
  var startindex=i+theKey.length+1;
  if (i==-1)
  {
  	return "";
  }
  var otherstr=theStr.substr(startindex);
  var j = otherstr.indexOf('&');
  if(j>0)
  {
  	result=otherstr.substring(0,j);
  }
  else
  {
  	result=otherstr.substring(0);
  }
  return result;
}

function wmx_GetCookie(sName)
{
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++) {
    var aCrumb = aCookie[i].split("=");
    if (sName == unescape(aCrumb[0])) 
      return unescape(aCrumb[1]);
  }
  return null;
}

function wmx_GetHttpUrl(strUrl)
{
	var nPos = strUrl.indexOf("?");
	if (nPos != -1)
		return (strUrl.substring(0,nPos));
	else
		return (strUrl);
}

function wmx_GetHttpUrlParam(strUrl)
{
	var strResParam = "";
	var nPos = strUrl.indexOf("?");	
	if (nPos != -1)
	{
		var strSrcParam = strUrl.substring(nPos+1,strUrl.length).toLowerCase();
		var oParam = strSrcParam.split('&');
		oParam.sort();
		for (i=0; i<oParam.length; i++)
		{
		   if (strResParam != "")
		      strResParam += "&";
			strResParam += oParam[i];      
		}
	}
	return (strResParam);	
}

var oWmxTracker=function(client,campiagn,baseUrl,wmx_cntracking,wmx_sltracking) 
{
	this.client=client;
	this.campaign=campiagn;
	this.imgContainer=new Array();
	this.baseUrl=baseUrl;
	this.protocol = location.protocol=="https:"?"https:":"http:";
	this.trackUrl=this.protocol+'//'+this.baseUrl+'/web_service/counter/CSTrack.aspx';
	this.wmx_cntracking=wmx_cntracking;
	this.wmx_sltracking=wmx_sltracking;
	this.strUID = (navigator.cookieEnabled ? "W_S_UID" : "-1");
	this.strAccount = wmx_GetCookie("WMX_Account");
	this.wmx_thisURL = document.URL;
	this.wmx_from = document.referrer;
    this.wmx_title = document.title;
	this.navigator=new Object();
	this.navigator.userAgent=navigator.userAgent.substring(0,128);
	this.navigator.screenWidth=screen.width;
	this.navigator.screenHeight=screen.height;
	this.aFieldList=new Array();
}

oWmxTracker.prototype.addFields=function(iFieldID,sValue)
{
	this.aFieldList.push([iFieldID,sValue])
}

oWmxTracker.prototype.ad=function()
{
 if(this.wmx_from==this.wmx_title) return;
 var sAdUrl=this.protocol + "//"+this.baseUrl+"/web_service/counter/ad_total_open.aspx"+"?"+this.client;
 var _this=this;
 if(window.addEventListener)
            addEventListener('load', function(){										  
	_this.createImg(sAdUrl)},false);
        else
            attachEvent('onload',function(){
	_this.createImg(sAdUrl)});
}

oWmxTracker.prototype.track=function()
{
		if (this.wmx_cntracking == "1")
	{
		if(this.wmx_title == "")
		{
			var nIndex = this.wmx_title.indexOf("?");
			if(nIndex != -1) 
			this.wmx_title = this.wmx_title.substring(0, nIndex);
			nIndex = this.wmx_title.indexOf("#");
			if(nIndex != -1) 
			this.wmx_title = this.wmx_title.substring(0, nIndex);
			nIndex = this.wmx_title.lastIndexOf("//");
			if(nIndex != -1)
			this.wmx_title =this.wmx_title.substring(nIndex+2,this.wmx_title.length);
			if(this.wmx_title.substring(this.wmx_title.length-1,this.wmx_title.length)=='/')
			this.wmx_title =this.wmx_title.substring(0,this.wmx_title.length-1);
		}
		this.aFieldList.push(["pname",escape(this.wmx_title)]);
	}
	this.aFieldList.push(["cli",this.client],["uid",this.strUID],[1,this.wmx_thisURL],[2,this.strUID],[3,'W_S_SC'],[4,this.strAccount],[5,'W_S'],[6,'W_S_DATE'],[7,'W_S'],[8,'W_S'],[9,this.wmx_from],[10,'W_S_IP'],[11,this.campaign],[22,this.navigator.userAgent],[23,this.navigator.screenWidth],[24,this.navigator.screenHeight]);
if (this.wmx_sltracking =="1")
	{
	this.aFieldList.push([20,wmx_GetHttpUrl(this.wmx_thisURL)],[21,wmx_GetHttpUrlParam(this.wmx_thisURL)]);
	}
	
	if(judgeMark==1)
  this.createImg(this.formTrackString());
}

oWmxTracker.prototype.formTrackString=function()
{
	var strSrc=this.trackUrl+'?';
	for(var i=0;i<this.aFieldList.length;i++)
	{
		if(i!=0)
		strSrc+='&';
		strSrc+=this.aFieldList[i][0]+'='+encodeURIComponent(this.aFieldList[i][1]);
		}
		strSrc+='&countertracking='+this.wmx_cntracking;
		strSrc+='&sltracking='+this.wmx_sltracking;
		return strSrc;
}

oWmxTracker.prototype.flashTrack=function(bCounter,s12,s13)
{
	this.clearFieldArray("pname");
	this.clearFieldArray(1);
	this.clearFieldArray(12);
	this.clearFieldArray(13);
	if(typeof(bCounter)!='boolean')
	return;
	if(bCounter)
	this.wmx_cntracking=1;
	else
	this.wmx_cntracking=0;
	if(typeof(s12)!='undefined')
	{
	 this.aFieldList.push([12,s12]);
     this.aFieldList.push(["pname",s12]);
	}
	else return;
	if(typeof(s13)!='undefined')
	{
	 this.aFieldList.push([13,s13]);
	 this.aFieldList.push([1,s13]);

	}
	this.createImg(this.formTrackString());
}
	
oWmxTracker.prototype.clearFieldArray=function(fieldId)
{
	for(var i=0;i<this.aFieldList.length;i++)
		{
			if(this.aFieldList[i][0]==fieldId)
				{this.aFieldList.splice(i,1)}
			}
}

oWmxTracker.prototype.eventTrack=function()
{
	for(var i=0;i<arguments.length;i++)
	{
		if(arguments[i][0]>=15 && arguments[i][0]<=19)
		{
		this.clearFieldArray(arguments[i][0]);
		this.aFieldList.push([arguments[i][0],arguments[i][1]]);
		}
	}
	this.createImg(this.formTrackString());
}

oWmxTracker.prototype.createImg=function(sUrl)
{
	var oImg=new Image(1,1);
	oImg.src=sUrl;
	this.imgContainer.push(oImg);
}

if(document.URL.toLowerCase().indexOf("http://intouchmoto.com.cn/default.aspx")==0
||document.URL.toLowerCase().indexOf("http://www.intouchmoto.com.cn/default.aspx")==0)
{
	judgeMark = 2;
	var wmx_gettitle;
	var wmx_getthisURL;
	var LocString=String(window.document.location.href);
	var tabid = getArg(LocString,"tabid");
	
	switch(tabid)
	{
		case "":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/";
			wmx_gettitle   = "摩托罗拉专业用户俱乐部";
			break;
		case "1":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/";
			wmx_gettitle   = "摩托罗拉专业用户俱乐部";
			break;
		case "21":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/forgotpassword.aspx";
			wmx_gettitle   = "忘记密码";
			break;
		case "43":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/register.aspx";
			wmx_gettitle   = "注册";
			break;
		case "56":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/examples.aspx";
			wmx_gettitle   = "应用案例";
			break;
		case "14":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/recentlymove.aspx";
			wmx_gettitle   = "近期活动";
			break;
		case "58":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/specialarea.aspx";
			wmx_gettitle   = "《智慧通信纵览》专区";
			break;
		case "16":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/contactus.aspx";
			wmx_gettitle   = "联系我们";
			break;
		case "13":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/introduce.aspx";
			wmx_gettitle   = "介绍朋友";
			break;
		case "37":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/bbs.aspx";
			wmx_gettitle   = "交流社区";
			break;
		case "46":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/updateprofile.aspx";
			wmx_gettitle   = "修改个人信息";
			break;
		case "4":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/admin_usermanage.aspx";
			wmx_gettitle   = "用户信息管理系统";
			break;
		case "47":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/admin_addcustomer.aspx";
			wmx_gettitle   = "添加新客户";
			break;
		case "48":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/admin_updateprofile1.aspx";
			wmx_gettitle   = "客户信息修改-以客户名称为索引查询";
			break;
		case "51":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/admin_updateprofile2.aspx";
			wmx_gettitle   = "客户信息修改-以产品信息为索引查询";
			break;
		case "52":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/disignreport1.aspx";
			wmx_gettitle   = "报表生成-定制报表";
			break;
		case "34":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/disignreport2.aspx";
			wmx_gettitle   = "报表生成-已定制报表";
			break;
		case "6":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/sysmanage.aspx";
			wmx_gettitle   = "系统管理";
			break;
		case "30":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/othermanage.aspx";
			wmx_gettitle   = "其他管理";
			break;
		case "61":
			wmx_getthisURL = "http://www.intouchmoto.com.cn/integral.aspx";
			wmx_gettitle   = "积分与奖励";
			break;
		default:
			//judgeMark = 3;
			wmx_getthisURL = "http://www.intouchmoto.com.cn/admin_other.aspx";
			wmx_gettitle = "其他管理页面";
			break;
	}
	/*
	if(judgeMark==2)
	{
		wmx_getthisURL = "http://www.intouchmoto.com.cn/" + wmx_getthisURL;
	}
	*/
	var _oWmxTracker=new oWmxTracker('motocnGPS','website','wm1.1to1crm.com.cn',1,1);
	_oWmxTracker.track();
	_oWmxTracker.flashTrack(true, wmx_gettitle, wmx_getthisURL);
}
else
{
	var _oWmxTracker=new oWmxTracker('motocnGPS','website','wm1.1to1crm.com.cn',1,1);
	_oWmxTracker.track();
}