/*共用JS*/
$(document).ready(function(){
	init_contact();
});

//取得当前服务器域名
function getdomain() {
	$.getJSON('domain_json.php',function(data){
		return data;
	});
}

//初始化联系方式
function init_contact() {
	//载入右边栏
	if($("#right").attr("title")!='index') {
			//载入联系邮件
			$("#mail").attr({href:"mailto:lshzhuhai@163.com"});
			$("#mail").html('lshzhuhai@163.com');
			//载入QQ
			$("#QQ").html('QQ:304570672');
	}
	else {
			//载入联系邮件
			$("#mail").attr({href:"mailto:lshzhuhai@163.com"});
			$("#mail").html('lshzhuhai@163.com');
			//载入QQ
			$("#QQ").html('QQ:304570672');
	}
}//init_contact


//自动隐藏错误信息
function hide_messsage() {
	setTimeout("$('#message').hide()",4000);
}

function show_this(elem) {
	hide_all();
	$(elem).slideDown(500); 
}

function hide_all() {
	$("#demo").slideUp(500); 
	$("#api").slideUp(500); 
	$("#down").slideUp(500); 
}

// 验证码更换
function change_code() {
	var timenow = new Date().getTime();
	$("#img_code").attr("src","code.php?"+timenow);
}


//cookies相关函数
function setCookie(name, value)		//cookies设置
{
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	if(expires!=null)
	{
		var LargeExpDate = new Date ();
		LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24));
	}
	document.cookie = name + "=" + escape (value)+((expires == null) ? "" : ("; expires=" +LargeExpDate.toGMTString()));
}

function getCookie(Name)			//cookies读取
{
	var search = Name + "="
	if(document.cookie.length > 0) 
	{
		offset = document.cookie.indexOf(search)
		if(offset != -1) 
		{
			offset += search.length
			end = document.cookie.indexOf(";", offset)
			if(end == -1) end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
		 }
	else return ""
	  }
}

//判断cookie是否开启
function enCookie() {
	var isCookie = navigator.cookieEnabled ? true : false;
	return isCookie;
}

//繁体转换
function ST_replace(str,type,charset) {
	if( enCookie() && type=='zh-hk' ) {
		var client = new PHPRPC_Client('http://app.17kaixin8.com/zhconvert/ZhConvert.ser.php', ['ZhConvert']);
		client.ZhConvert(str, type, charset, function(res) {
			$('body').html(res);
		});
	}
	else {
		return false;
	}
}