
var sosoCurrHighLight = document.getElementById("sosoweb");

function trim(str){
	return str.replace(/(^\s*)|(\s*$)/g, "");
}
function sosoValidate(){
	wval = trim(frm_head.searchKeyword.value);
	if(wval == "")
		return false;
	else {
		return true;
          }
}

function sosoSubSearch(sc){
	changePage(sc);
	if(sc == "img")
	{
		frm_head.action = "http://www.chinasexq.com/ss/search.asp?searchType=img";
	}
	else if(sc == "game")
	{
		frm_head.action = "http://www.chinasexq.com/ss/search.asp?searchType=game";
	}
	else if(sc == "web")
	{
		frm_head.action = "http://www.chinasexq.com/ss/search.asp?searchType=web";
	}
	else if(sc == "vid")
	{
		frm_head.action = "http://www.chinasexq.com/ss/search.asp?searchType=vid";
	}
	else 
	{
		frm_head.action = "http://www.chinasexq.com/ss/search.asp?searchType=web";
	}
	
}

function sosoGoSoba(){
	
	frm_head.action = "http://post.ChinaSexQ.com/cgi-bin/cgimain";
	frm_head.kw.value = frm_head.w.value;
}

function changePage(sc){
	if(sosoCurrHighLight == null){
		sosoCurrHighLight = document.getElementById("sosoweb");
	}
	
	sosoCurrHighLight.className = "searchfod2";
	sosoCurrHighLight = document.getElementById("soso" + sc)
	sosoCurrHighLight.className = "searchfod1";
	
	if(sc == "general")
	{
		frm_head.searchType.value = "web";
		frm_head.action = "http://www.chinasexq.com/ss/search.asp";
	}
	else if(sc == "web"){
		frm_head.searchType.value = "web";
		frm_head.action = "http://www.chinasexq.com/ss/search.asp";
	}
	else if(sc == "img"){
		frm_head.searchType.value = "img";
		frm_head.action = "http://www.chinasexq.com/ss/search.asp";
	}
	else if(sc == "vid"){
		frm_head.searchType.value = "vid";
		frm_head.action = "http://www.chinasexq.com/ss/search.asp";
	}
	else if(sc == "game"){
		frm_head.searchType.value = "game";
		frm_head.action = "http://www.chinasexq.com/ss/search.asp";
	}
	else{
		frm_head.searchType.value = "web";
		frm_head.action = "http://www.chinasexq.com/ss/search.asp";
	}
}

function isSoba(){
	if(sosoCurrHighLight == document.getElementById("sososoba")){
		sosoGoSoba();
		return true;
	}
	else{
		return true;
	}
}

function goSearch(){
	changeHotWords(document.frm_head.searchType.value);
	if(!sosoValidate())
		return false;
	if(frm_head.searchKeyword.value != ""){
		frm_head.submit();
	}
	else
		return false;
}

function changeHotWords(category){
	document.getElementById("td_hotlist").innerHTML = eval(category + "Words");
}


if (typeof g_mutex_lock == "undefined") 
{
	g_mutex_lock = new Array(); 
}

function mutex_check_init() 
{
	if(!g_mutex_lock) return -1;
	if(!g_mutex_lock.constructor) return -1;;
	if(g_mutex_lock.constructor.toString().toLowerCase().indexOf("array") == -1) return -1;;
}
	
function mutex_lock() 
{
	var name = "TENCENT_AD_LOCK_56318658";
	if (mutex_check_init() < 0) return -1;
	if (!g_mutex_lock[name]) g_mutex_lock[name] = 0;
	g_mutex_lock[name]++;
	if (g_mutex_lock[name] > 1) 
	{
		g_mutex_lock[name]--; return -1;
	}

	return 0;
}

function mutex_unlock()	
{
	var name = "TENCENT_AD_LOCK_56318658";
	if (mutex_check_init() < 0) return -1;
	if (g_mutex_lock[name] <= 0) return -1;
	g_mutex_lock[name]--;
	return 0; 
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function getCookie1 (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0)
			break;
	}
	return "";
}

function setCookie(cookieName,cookieValue,days) {
	var today  = new Date();
	var expire = new Date();
	if (days==null || days==0) days=1;
	expire.setTime(today.getTime() + 3600000*days);
	document.cookie = cookieName+"="+escape(cookieValue) + ";path=/;domain=.ChinaSexQ.com;expires="+expire.toGMTString();
}

function call_0410(type,item,page) {
	try {
		var purl='';
		if (type == "A")
			purl = window.event.srcElement.href;
		else if (type == "IMG")
			purl = window.event.srcElement.parentNode.href;
		
		var iurl = 'http://trace.ChinaSexQ.com/collect?pj=1001&item='+item+'&page='+page+'&url='+purl+'&rnd='+Math.random();
		var img  = new Image(1,1);
		img.onerror = function () {
		}
		img.src	 = iurl;
	} catch (e) {
	}
}

function register0410(item,page) {
	var type = window.event.srcElement.tagName;
	if (type == "A" || type == "IMG" ) {
		call_0410(type,item, page);
	}
	
	return true;
}

function getNames(obj,name,tij)
	{	
		var p = document.getElementById(obj);
		var plist = p.getElementsByTagName(tij);
		var rlist = new Array();
		for(i=0;i<plist.length;i++)
		{
			if(plist[i].getAttribute("name") == name)
			{
				rlist[rlist.length] = plist[i];
			}
		}
		return rlist;
	}

		function fod(obj,name)
		{
			var p = obj.parentNode.getElementsByTagName("td");
			var p1 = getNames(name,"f","div"); // document.getElementById(name).getElementsByTagName("div");
			for(i=0;i<p1.length;i++)
			{
				if(obj==p[i])
				{
					p[i].className = "s";
					p1[i].className = "dis";
				}
				else
				{
					p[i].className = "";
					p1[i].className = "undis";
				}
			}
		}

//综合
	var generalWords = '<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=性生活&searchType=general">性生活</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=性知识&searchType=general">性知识</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=人流&searchType=general">人流</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=裸奔&searchType=general">裸奔</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=包养&searchType=general">包养</a>';
	//网页
	var webWords = '<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=性技巧&searchType=web">性技巧</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=避孕&searchType=web">避孕</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=一夜情&searchType=web">一夜情</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=性用品&searchType=web">性用品</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=杨二&searchType=web">杨二</a>';
	//图片
	var imgWords = '<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=性感&searchType=img">性感</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=自拍&searchType=img">自拍</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=艳照&searchType=img">艳照</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=春宫&searchType=img">春宫图</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=人妖&searchType=img">人妖</a>';
	//视频
	var vidWords = '<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=美女&searchType=vid">美女</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=性爱&searchType=vid">性爱姿势</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=性教育&searchType=vid">性教育</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=广告&searchType=vid">广告</a>';
	//游戏
	var gameWords = '<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=泡妞&searchType=game">泡妞</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=美女脱衣&searchType=game">美女脱衣</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=偷窥&searchType=game">偷窥</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=贪吃蛇&searchType=game">贪吃蛇</a>&nbsp;<a target="_blank" href="http://www.chinasexq.com/ss/search.asp?searchKeyword=轮盘&searchType=game">轮盘</a>';
	
