﻿var cURLsc=location.href;
var exURL=document.referrer;    
var tcodegetsc=getTcode();
var sename;
sename="";
var keywordlist;
var setail;

keywordlist={keyword:[
{kw:"gen_aw_ch_cn_tek",value:"_ad_Brand"},
{kw:"la_aw_ch_cn_lah",value:"_ad_LA"},
{kw:"scope_aw_ch_cn_jttr",value:"_ad_OS_Jitter"},
{kw:"scope_aw_ch_cn_mso",value:"_ad_OS_mso"},
{kw:"scope_aw_ch_cn_probe",value:"_ad_OS_probe"},
{kw:"scope_aw_ch_cn_scope",value:"_ad_OS_scope"},
{kw:"scope_aw_ch_cn_sdata",value:"_ad_OS_sata"},
{kw:"scope_aw_ch_cn_sftwr",value:"_ad_OS_software"},
{kw:"rf_aw_ch_cn_sa",value:"_ad_RF"},
{kw:"ss_aw_ch_cn_ssh",value:"_ad_SignalGen"},
{kw:"vid_aw_ch_cn_hdt",value:"_ad_VD_hd"},
{kw:"vid_aw_ch_cn_sdt",value:"_ad_VD_sd"},
{kw:"vid_aw_ch_cn_vth",value:"_ad_VD_vth"},
{kw:"vid_aw_ch_cn_wfm",value:"_ad_VD_wfm"},
{kw:"vid_aw_ch_cn_mpeg",value:"_ad_VD_mpeg"},
{kw:"vid_aw_ch_cn_sigGen",value:"_ad_VD_sigGen"},
{kw:"gen_aw_ch_cn_train",value:"_ad_Training"}
]};

//search the list of AD keyword group and write the value into setail.
function getTrackKeyword()
{
	var i=keywordlist.keyword.length;
	setail="";
	for(j=0;j<i;j++)
	{
		if(cURLsc.search(keywordlist.keyword[j].kw)!=-1)
		{
			setail=keywordlist.keyword[j].value;
		}
	}

}
//----------------------------------------------


if(exURL.search("yahoo")!=-1){sename="yahoo";}
if(exURL.search("yodao.com")!=-1){sename="163";}
if(exURL.search("baidu.com")!=-1){sename="baidu";}
if(exURL.search("google.com")!=-1){sename="google";}
if(exURL.search("google.cn")!=-1){sename="google";}
if(exURL.search("sogou.com")!=-1){sename="sogou";} 
	
if (sename!="")	
{
	getTrackKeyword();
	sename=sename+setail;
	document.cookie = "tcode="+sename+ ";path=/;domain=.tek.com;";
	//document.cookie = "tcode="+sename+ ";path=/;";
}


tcodegetsc=getTcode(); 
if ((tcodegetsc==undefined)||(tcodegetsc==""))
{
	document.cookie = "tcode=0;path=/;domain=.tek.com;";
	//document.cookie = "tcode=0;path=/;";
}


function getTekPrefsAP() {
		
  	var nameEQ = "TEK_PREFS=";
  	var ca = document.cookie.split(';');
  	for(var i=0;i < ca.length;i++)
	{
  		var c = ca[i];
  		while (c.charAt(0)==' ') c = c.substring(1,c.length);
  		if (c.indexOf(nameEQ) == 0)
		{
 		    return c.substring(nameEQ.length,c.length);
  		 }
 	 }
  	document.cookie = "TEK_PREFS=COUNTRY%3DCN%26LANGUAGE%3DZH%26;path=/;domain=.tek.com;"
 	return "";
}
getTekPrefsAP();
//------------------------------------------------------------------------
