// Common Script Library
// File format UTF-8

var skword = "";

function blanklink(strlink){
	window.open(strlink,"_blank");
}

function blankto(strkey)
{
//	alert('blank to MD5: '+strlnk);
	window.open('/go.php?q='+strkey,"_blank");
/*
	if(wordtit!=""){
		tbsearch(wordtit);
	}else{
		window.open('/go.php?q='+strkey,"_blank");
	}
*/
}

function blankto64(strcode)
{
	window.open('/go64b.php?q='+strcode,"_blank");
/*
	if(wordtit!=""){
		tbsearch(wordtit);
	}else{
		window.open('/go.php?q='+strkey,"_blank");
	}
*/
}

function gotolink(strlink){
	strlink = strlink.replace('mm_29756296_0_0', 'mm_10012179_0_0');
	strlink = strlink.replace('mm_24718109_0_0', 'mm_10012179_0_0');
	location.href=strlink;
}

function redirectUrl(urltogo) {
	urltogo = urltogo.replace('mm_29756296_0_0', 'mm_10012179_0_0');
	urltogo = urltogo.replace('mm_24718109_0_0', 'mm_10012179_0_0');
	location.href = urltogo;
}

function tbsearch(wordtitle) {
//	alert('search for :' + wordtitle);
	wordid=-1;
	word = wordtitle;
	wordencode = encodeURI(word);
	var jumpurl = "http://"+document.domain+"/"+"tbmore.php";
	var lastUrl = document.referrer.toString();
	jumpurl = jumpurl + "?wordid="+wordid+"&wdcode="+wordencode+"&refer="+encodeURIComponent(lastUrl);
	jumpurl = jumpurl.replace('mm_29756296_0_0', 'mm_10012179_0_0');
	jumpurl = jumpurl.replace('mm_24718109_0_0', 'mm_10012179_0_0');
//	alert(jumpurl);
	document.location = jumpurl;
}

function pushbuilding() {
//	document.write('building push here.');
//document.write(decodeURI('%3Cscript%20type=%22text/javascript%22%3E%3C!--%0D%0Agoogle_ad_client%20=%20%22pub-2496874701523913%22;%0D%0A/*%20slmoon160x600_11-3-2%20*/%0D%0Agoogle_ad_slot%20=%20%228727485465%22;%0D%0Agoogle_ad_width%20=%20160;%0D%0Agoogle_ad_height%20=%20600;%0D%0A//--%3E%0D%0A%3C/script%3E%0D%0A%3Cscript%20type=%22text/javascript%22%0D%0Asrc=%22http://pagead2.googlesyndication.com/pagead/show_ads.js%22%3E%0D%0A%3C/script%3E'));
	//baidu building 160x600
//	document.write(decodeURI('%3Cscript%20type=%22text/javascript%22%3E/*slmoon160*600%EF%BC%8C2011-3-2*/%20var%20cpro_id%20=%20\'u396090\';%3C/script%3E%3Cscript%20src=%22http://cpro.baidu.com/cpro/ui/c.js%22%20type=%22text/javascript%22%3E%3C/script%3E'));
}

function pushbanner() {
	document.write('banner push here.');
//document.write(decodeURI('%3Cscript%20type=%22text/javascript%22%3E%3C!--%0D%0Agoogle_ad_client%20=%20%22pub-2496874701523913%22;%0D%0A/*%20slmoon728x90_11-3-2%20*/%0D%0Agoogle_ad_slot%20=%20%221862561746%22;%0D%0Agoogle_ad_width%20=%20728;%0D%0Agoogle_ad_height%20=%2090;%0D%0A//--%3E%0D%0A%3C/script%3E%0D%0A%3Cscript%20type=%22text/javascript%22%0D%0Asrc=%22http://pagead2.googlesyndication.com/pagead/show_ads.js%22%3E%0D%0A%3C/script%3E'));
}

function bartbsearch(wordtitle) {
	strs = '%3Cscript%20type=\'text/javascript\'%3E%0D%0Aalimama_pid=\'mm_10012179_0_0\';%0D%0Aalimama_type=\'g\';%0D%0Aalimama_tks=%7B%7D;%0D%0Aalimama_tks.style_i=1;%0D%0Aalimama_tks.lg_i=1;%0D%0Aalimama_tks.w_i=680;%0D%0Aalimama_tks.h_i=45;%0D%0Aalimama_tks.btn_i=1;%0D%0Aalimama_tks.txt_s=\'\';%0D%0Aalimama_tks.hot_i=0;%0D%0Aalimama_tks.hc_c=\'#0065FF\';%0D%0Aalimama_tks.c_i=1;%0D%0Aalimama_tks.cid_i=0;%0D%0A%3C/script%3E%0D%0A%3Cscript%20type=\'text/javascript\'%20src=\'http://a.alimama.cn/inf.js\'%3E%3C/script%3E'
//	strs = strs.replace('%E6%83%B3%E4%B9%B0%E4%BB%80%E4%B9%88%EF%BC%9F%E8%BF%99%E9%87%8C%E5%BE%88%E4%BE%BF%E5%AE%9C',encodeURIComponent(wordtitle))
	document.write(decodeURI(strs));
//	document.write('here place the tbsearch bar');
}

function decode64push(code64p){
	recode = base64decode(code64p)
	recode = recode.replaceAll("&gt;",">");
	recode = recode.replaceAll("&lt;","<");
	recode = recode.replaceAll("&quot;","\"");
	recode = recode.replaceAll("&#39;","'");
	return recode;
}

function counter(){
	baiducount();
	yahoocunt();
}


function yahoocunt(){
		//YahooCount
	document.write(decodeURI('%3Cscript%20type=%22text/javascript%22%20src=%22http://js.tongji.linezing.com/2314154/tongji.js%22%3E%3C/script%3E%3Cnoscript%3E%3Ca%20href=%22http://www.linezing.com%22%3E%3Cimg%20src=%22http://img.tongji.linezing.com/2314154/tongji.gif%22/%3E%3C/a%3E%3C/noscript%3E'));
}

function baiducount(){
	//BaiduCounter
	document.write(decodeURI('%3Cscript%20type=%22text/javascript%22%3E%0Avar%20_bdhmProtocol%20=%20((%22https:%22%20==%20document.location.protocol)%20?%20%22%20https://%22%20:%20%22%20http://%22);%0Adocument.write(unescape(%22%253Cscript%20src=\'%22%20+%20_bdhmProtocol%20+%20%22hm.baidu.com/h.js%253F015a4e7d2b8c8c394c647f057120fb56\'%20type=\'text/javascript\'%253E%253C/script%253E%22));%0A%3C/script%3E%0A'));
}

function st(strmd, lnkstr) //show item thumb
{
	var _imgurl = base64decode(strmd);
	if (lnkstr!='') 
	{
		document.write('<img class="itemthumb" src="'+_imgurl+'" onClick=\"blankto(\''+lnkstr+'\')\"/>');
	}else{
		document.write('<img class="itemthumb" src="'+_imgurl+'"/>');
	}
}

function st64(strmd, lnkstr) //show item thumb
{
	var _imgurl = base64decode(strmd);
	if (lnkstr!='') 
	{
		document.write('<img class="itemthumb" src="'+_imgurl+'" onClick=\"blankto64(\''+lnkstr+'\')\"/>');
	}else{
		document.write('<img class="itemthumb" src="'+_imgurl+'"/>');
	}
}

function showthumb(strmd)
{
	st(strmd,'');
}


/**
*
* AJAX 功能函数开始
*
**/

var xmlHttp;

function getTBS(wordstr)
{
	skword = wordstr;
	if (wordstr.length<0)
	{ 
		return false;
	}
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null)
	{
//		alert ("Browser does not support HTTP Request")
		return false;
	} 
	var lastUrl = document.referrer.toString();
	var url="http://"+document.domain+"/"+"vrmitemget.php";
	url=url+"?h=1&q="+encodeURI(wordstr);
	url=url+"&sid="+Math.random();
	url=url+"&r="+encodeURIComponent(lastUrl);
	xmlHttp.onreadystatechange = stateChanged ;
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

function stateChanged() 
{ 
	var moreHtm = '<div class="srhmore" onClick="tbsearch(\''+skword+'\')"><label>&nbsp;</label></div>';
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("tbsresult").innerHTML = xmlHttp.responseText;
		document.getElementById("fstmore").innerHTML = moreHtm;
	} 
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}



/**
*
* AJAX 功能函数结束
*
**/



function getCookie(cookie_name)
{
	var allcookies = document.cookie;
	var cookie_pos = allcookies.indexOf(cookie_name);
	var value = "";
	if (cookie_pos != -1)
	{
		cookie_pos += cookie_name.length + 1;
		var cookie_end = allcookies.indexOf(";", cookie_pos);
		if (cookie_end == -1)
		{
			cookie_end = allcookies.length;
		}
		value = decodeURIComponent(allcookies.substring(cookie_pos, cookie_end));
	}
	return value;
}

function setCookie( name, value, expires, path, domain, secure )
{
	// set time, it's in milliseconds
	var today = new Date();
//	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60;
	}
	var expires_date = new Date( today.getTime() + (expires) );
//	alert("SetCookie: name:"+name+", value:"+value+", expires date:"+expires_date.toGMTString());
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function base64decode(str) {
var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var base64DecodeChars = new Array(
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
  52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
  -1, 0, 1, 2, 3,  4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
  -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
  41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);
  var c1, c2, c3, c4;
  var i, len, out;
  len = str.length;
  i = 0;
  out = "";
  while(i < len) {
 /* c1 */
 do {
   c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
 } while(i < len && c1 == -1);
 if(c1 == -1)
   break;
 /* c2 */
 do {
   c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
 } while(i < len && c2 == -1);
 if(c2 == -1)
   break;
 out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
 /* c3 */
 do {
   c3 = str.charCodeAt(i++) & 0xff;
   if(c3 == 61)
 return out;
   c3 = base64DecodeChars[c3];
 } while(i < len && c3 == -1);
 if(c3 == -1)
   break;
 out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
 /* c4 */
 do {
   c4 = str.charCodeAt(i++) & 0xff;
   if(c4 == 61)
 return out;
   c4 = base64DecodeChars[c4];
 } while(i < len && c4 == -1);
 if(c4 == -1)
   break;
 out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
  }
  return out;
}



