/**
 * START WRating v1.0 页面埋码
 *
 * @author yaojing
 * @date 2009-12-01
 */

if (typeof XIYOU == 'undefined') {
	var XIYOU = {};
}
XIYOU.WRating = {
	sId			: "860010-1108230100",
	aUris		: [],
	aConfigs	: {},
	
	init		: function() {
		this.aUris = this.getUris();
		this.parse();
	},
	getUris		: function() {
		return window.location.href.toString().split("/");
	},
	getId		: function() {
		return this.sId.toString();
	},
	//根据视频ID得到播放器中应该埋码的ID
	getIdByCategory	: function(categoryId){
		return this.aConfigsForCategory[categoryId] || "860010-1208230100";
	},
	parse		: function() {
		var p1 = this.aUris[3] || "";
		var p2 = this.aUris[4] || "";
		var p3 = this.aUris[5] || "";
		if (-1 != p1.indexOf("?")) p1 = p1.substr(0, p1.indexOf("?"));
		if ("undefined" != typeof(__category_id__)) p2 = __category_id__;
		if (this._isExists(this.aConfigs[p1])) {
			this.sId = this.aConfigs[p1];
		}else if (this._isExists(this.aConfigs[p1][p2])) {
			this.sId = this.aConfigs[p1][p2];
		}else if (this._isExists(this.aConfigs[p1][p3])) {
			this.sId = this.aConfigs[p1][p3];
		}else if (this._isInt(p2) && this._isExists(this.aConfigs[p1]["_p2int"])) {
			this.sId = this.aConfigs[p1]["_p2int"];
		}else if (this._isInt(p3) && this._isExists(this.aConfigs[p1]["_p3int"])) {
			this.sId = this.aConfigs[p1]["_p3int"];
		}
	},
	_isExists	: function(v) {
		return "string" == typeof(v) && "" != v;
	},
	_isInt		: function(v) {
		var i = parseInt(v * 1);
		if (isNaN(i)) {
			return false;
		}
		return v == i && v.toString() == i.toString();
	}
};

XIYOU.WRating.aConfigs = {
	"video" : {
				"index.html"	: "860010-1108020100",
				"index"			: "860010-1108020100",
				
				"96"			: "860010-1108040100",
				"97"			: "860010-1108050100",
				"98"			: "860010-1108060100",
				"99"			: "860010-1108060100",
				"100"			: "860010-1108070100",
				"101"			: "860010-1108150100",
				"102"			: "860010-1108080100",
				"103"			: "860010-1108090100",
				"104"			: "860010-1108100100",
				"105"			: "860010-1108030100",
				"106"			: "860010-1108120100",
				"107"			: "860010-1108140100",
				"108"			: "860010-1108130100",
				"109"			: "860010-1108110100",
				"110"			: "860010-1108160100",
				"111"			: "860010-1108170100",
				"128"			: "860010-1108260100"
			  },
	"playlist" : {
					"index.html": "860010-1108190100",
					"_p2int"	: "860010-1108200100",
					"_p3int"	: "860010-1108190100"
				 },
	"playlistinfo"				: "860010-1108200100",
	"ptv" : {
				"index.html"	: "860010-1108210100",
				"_p2int"		: "860010-1108210200",
				"_p3int"		: "860010-1108210300",
				"default"		: "860010-1108210500"
			},
	"user"						: "860010-1108210400",
	"upload.html"				: "860010-1108180100",
	"search.php"				: "860010-1108220100"					
};

//视频播放器中，视频类别与埋码ID的对应关系
XIYOU.WRating.aConfigsForCategory = {
	"96"			: "860010-1208040100",
	"97"			: "860010-1208050100",
	"98"			: "860010-1208060100",
	"99"			: "860010-1208060100",
	"100"			: "860010-1208070100",
	"101"			: "860010-1208150100",
	"102"			: "860010-1208080100",
	"103"			: "860010-1208090100",
	"104"			: "860010-1208100100",
	"105"			: "860010-1208030100",
	"106"			: "860010-1208120100",
	"107"			: "860010-1208140100",
	"108"			: "860010-1208130100",
	"109"			: "860010-1208110100",
	"110"			: "860010-1208160100",
	"111"			: "",	
	"128"			: "860010-1208260100"
};

try {
	XIYOU.WRating.init();
	var vjAcc = XIYOU.WRating.getId() || "860010-1108230100";
//	if ("undefined" != typeof(__page_code__) && __page_code__ == "")
//	    _vjTrack('');
	var wrUrl="http://cntv.wrating.com/";
	var wrVideoUrl="http://cntv.wrating.com/";
}catch (e){}
