//首页滚动游戏图片
function scroll(n,obj,total){
	oDiv = document.getElementById('marqueeContent');
	marquee_width = parseInt(oDiv.style.width);//整个滚动图片内容的宽
	len  = parseInt(oDiv.style.left.substr(0,oDiv.style.left.length-2));//移动的位置总长度
	if( n == 0 || total <= 5 )return;
	if(oDiv.style.left == '0px' && n == 825)return;
	if(marquee_width + len < 826 && n == -825)return;
	oDiv.style.left = len+n+'px';
}

function $(o){return document.getElementById(o);}

//清除文本框的内容
function clickTxt(id_name){
	if(document.getElementById(id_name).value == '请输入用户名' || document.getElementById(id_name).value == '请输入密码' ){
		document.getElementById(id_name).value = "";
		document.getElementById(id_name).style.color = "#000000";
	}
}
//检测是否需要恢复已清除的文本框的内容
function check_clickTxt(id_name,id_name_value){
	if(document.getElementById(id_name).value == ''){
		document.getElementById(id_name).value = id_name_value;
		document.getElementById(id_name).style.color = "#666666";
	}
}


//读取cookie值
function getCookie(sName)
{
  var aCookie = document.cookie.split("; ");

	for (var i=0; i < aCookie.length; i++)
	{
		var aCrumb = aCookie[i].split("=");
		
		if (encodeURIComponent(sName) == aCrumb[0])
		{
			return decodeURIComponent(aCrumb[1]);
		}
	}
  return null;
}

//此处用在注册时的阅读注册协议处
/*
函数说明：
url   移动层内的内容地址
title  标题
css   移动层的样式（不用包含TOP和LEFT）
cajax  是采用AJAX还是iframe方式调用内容 1为不采用AJAX 0为采用AJAX
scrolling 如果采用iframe 是否启用滚动条，默认为自动 有三个值 no yes auto
top 顶坐标 默认居中
left 顶坐标 默认居中
注意 使用前应引入/imgedit/manipulate.js
请在页面中加入 <div id='movediv' style="display:none;"></div>这个 一般加在最底部
*/
function movediv(url,title,css,cajax,scrolling,top,left,cssid)
{
	if(!cssid)
	{
		cssid="movediv";
	}
	document.getElementById(cssid).style.display='';
	
	if(!scrolling){scrolling='auto';}
	
	var infos='<div class="clear" id=move_div_info style="clear: both;text-align:center;height:100%"><\/div>';
	
	if(!title)
	{
		title='';
	}
	
	document.getElementById(cssid).innerHTML = '<div id="movediv_">'+
		'<div class="movediv clear" onmousedown="canmove(document.getElementById(\'movediv_\'),event)">'+
				'<div style="float:left;height:25px;clear: both;margin-top:8px;margin-left:5px;font-size: 12px;font-weight: bold;color: #FF9900;width:75%;text-align:left;">'+title+'<\/div>'+
				'<div style="float: right;cursor:pointer;height:25px;margin-top:5px;margin-right:3px;width:21px;text-align:right;" title="关闭" onClick="logoutdiv();"><img src="/images/move/close.jpg" width="21" height="21" \/><\/div>'+
		'<\/div>'+
		infos+
	'<\/div>';
	
	//loading('move_div_info','big');//载入

	//var ss=new shade_show("movediv_");
	//ss.show_fade();//渐变显示调用 
	
	var mobj=document.getElementById("movediv_");
	
	mobj.className=css;
	
	document.documentElement.scrollTop = 0; 

	var yw = document.documentElement.clientWidth; 
	
	var yh = document.documentElement.clientHeight; 
	
	var w = mobj.clientWidth||mobj.offsetWidth;
	
	var h = mobj.clientHeight||mobj.offsetHeight;
		
	if(!top && !left)
	{
		mobj.style.top=((yh/2)-(h/2))+"px";
			
		mobj.style.left=((yw/2)-(w/2))+"px";
	}else{
		if(!top)
		{
			mobj.style.top=((yh/2)-(h/2))+"px";
				
			mobj.style.left=left+"px";
		}else if(!left)
		{
			mobj.style.top=top+"px";
				
			mobj.style.left=((yw/2)-(w/2))+"px";
		}else{
			mobj.style.top=top+"px";
				
			mobj.style.left=left+"px";
		}

	}
	
	if(Number(cajax))
	{
		ajax_ultimate(url,'','','','move_div_info');
	}else{
		document.getElementById("move_div_info").innerHTML='<iframe src="'+url+'" hspace="0" vspace="0" frameborder="0" scrolling="'+scrolling+'" height="100%" width="100%"><\/iframe>';
	}
}

function logoutdiv(cssid)
{
	if(!cssid)
	{
		cssid="movediv";
	}
	document.getElementById(cssid).style.display='none';
}


function canmove(elementToDrag, event)
{
	var deltaX = event.clientX - parseInt(elementToDrag.style.left);
	var deltaY = event.clientY - parseInt(elementToDrag.style.top);
	
	elementToDrag.style.cursor = "move";
	
	if (document.addEventListener)
	{//2 级 DOM事件模型
		document.addEventListener("mousemove", moveHandler, true);
		document.addEventListener("mouseup", upHandler, true);
	}else if (document.attachEvent){//IE5+事件模型
	
		document.attachEvent("onmousemove", moveHandler);
		document.attachEvent("onmouseup", upHandler);
	}else {//IE4事件模型
		document.onmousemove = moveHandler;
		document.onmouseup = upHandler;
	}
	
	//禁止起泡
	if (event.stopPropagation)//DOM2
	event.stopPropagation();
	else event.cancelBubble = true;//IE
	
	if (event.preventDefault)
	event.preventDefault();
	else event.cancelBubble = true;
	
	function moveHandler(e)
	{
		if (!e)
		e = window.event;
		
		elementToDrag.style.left = (e.clientX - deltaX) + "px";
		elementToDrag.style.top = (e.clientY - deltaY) + "px";
		
		if (e.stopPropagation)
		e.stopPropagation();
		else e.cancelBubble = true;
	}
	
	function upHandler(e)
	{
		if (!e)
		e = window.event;
		
		elementToDrag.style.cursor = "default";
		
		if (document.removeEventListener)
		{ //DOM2
			document.removeEventListener('mousemove', moveHandler, true);
			document.removeEventListener('mouseup', upHandler, true);
			
		}else if (document.detachEvent) 
		{ //IE5+
			document.detachEvent("onmousemove", moveHandler);
			document.detachEvent("onmouseup", upHandler);
			
			
		}else {//IE4
			document.onmousemove = moveHandler;
			document.onmouseup = upHandler;
		}
		
		if (e.stopPropagation)
		e.stopPropagation();
		else e.cancelBubble = true;
	}
}
//*************移动层结束*********************************************/


/* //////////////////////////////////////////////////////////////////////////////////////////////////
  *   AJAX主函数
  *   参数说明：
  *   url 提交页面  可选参数 geturl(id) 自定义 为空 ，3中状态 必选 其它不为必选
  *   fun 调用函数 默认调用client  可选参数 不调用 自定义
  *   method提交方式 get post 默认 GET 
  *   fromid 提交表单的ID或名称
  *   id     可以带一个返回参数
  
  *   当method为GET时 只需调用 url 和fum两个即可
  *   当method为POST时 如果URL启用的是 geturl()函数时只需调用 url,fun,method即可 
  *   如果URL为用户定义路径时 需要把url,fun,method,id这4个参数掉齐全
  *   如果URL为空时则属要调用 url,fun,method,id 4个参数
  *   geturl(id)；AJAX附加调用函数
  *   作用：为AJAX取得FORM表单的路径 参数ID为 FORM表单ID或名称
  *   POST用法有3种 
  *   1、URL 用户自定义地址 Fun 可为空 ,method 为POST 输入FORM表单ID  ajax_ultimate(url,fun,method,id)
  *   2、URL 为空 Fun 可为空 ,method 为POST  ,id 提交表单的ID或名称 ajax_ultimate('',fun,method,id)
  *   3、URL 调入url() 函数  Fun 可为空 ,method 为POST ajax_ultimate(geturl(ID),fun,method,id)
*/////////////////////////////////////////////////////////////////////////////////////////////////
function getRequestBody(oForm)
{
	var aParams=new Array();
	for(var i=0;i<oForm.elements.length;i++)
	{
		if(oForm.elements[i].type=="radio" || oForm.elements[i].type=="checkbox")
		{
			if(oForm.elements[i].checked==true)
			{
				var sParam=encodeURIComponent(oForm.elements[i].name);
				sParam+="=";
				sParam+=encodeURIComponent(oForm.elements[i].value);
				aParams.push(sParam);
			}
		}else{
			var sParam=encodeURIComponent(oForm.elements[i].name);
			sParam+="=";
			sParam+=encodeURIComponent(oForm.elements[i].value);
			aParams.push(sParam);
		}
	}
	return aParams.join("&");
}

function ajaxsends(url,fun,method,fromid,id)
{
	var this_=this;
	this_.url=url;
	this_.fun=fun;
	this_.method=method;
	this_.fromid=fromid;
	this_.id=id;
	
	/*AJAX执行状态*/
	ajaxsends.prototype.ajax_yun=function()
	{
		//获取执行状态
		this_.ajax.onreadystatechange = function() 
		{
			//如果执行是状态正常，那么就把返回的内容赋值给上面指定的层
			if (this_.ajax.readyState == 4 && this_.ajax.status == 200)
			{
				var	strdiv = this_.ajax.responseText;  //读取PHP页面打印出来的文字
				
				var jsstr=strdiv;
				
				strdiv=strdiv.replace(/<script[\s\S]+?<\/script>/igm,"");
				
				if(this_.fun)
				{
					eval(this_.fun + "(strdiv,id)");
				}else if(this_.id){
					 document.getElementById(this_.id).innerHTML=strdiv;
				}
				
				this_.ajaxjs(jsstr);
				
		//////////////////////////////////上面是处理//////////////////////////////////////////////////
			}
	
		}
	}
	
	/* 实例化AJAX*/
	ajaxsends.prototype.user_InitAjaxw=function()
	{
		 if (window.ActiveXObject)
		 {
			//IE
			try {
				//IE6.0以上
				return new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e1) {
					//IE5.5以下
					return new ActiveXObject("Msxml2.XMLHTTP");
			}
		} else if (window.XMLHttpRequest) {
			//FireFox
			return new XMLHttpRequest();
		}

	}
	
	/*获取表单URL*/
	ajaxsends.prototype.geturl=function()
	{	
		var u=new Array();
		
		try{
			var url=document.getElementById(this_.fromid).action; 
		}catch(err){
			var  url=document.getElementsByName(this_.fromid)[0].action; 
		}
		
		if(!url)
		{
			alert('表单action属性为空（要提交的地址）！');
			return false;
		}
		
		u[0]=url;
		u[1]=fromid;
		
		return u;
	}
	
	/*执行JS */
	ajaxsends.prototype.ajaxjs=function(msg)
	{
		var str2=msg.split("\r\n").join('');
		str2=str2.split("\n").join('');
		str2=str2.split("\r").join('');
		
		var reg=/<script[^>]*?>(.*?)<\/script>/ig;
		var str=str2.match(reg);
		
		if(!str)
		{
			return false;
		}
		
		for(var i=0;i<str.length;i++)
		{
			str[i]=str[i].replace(reg,"$1");
		
			eval(str[i]);
		}
	}
	
	
	/*POST提交*/
	ajaxsends.prototype.post=function()
    {
		if(!this_.url)
		{
			this_.url=this_.geturl();
		}else{
			if ( this_.url.constructor != window.Array)
			{
				var url_=this_.url;
				this_.url = new Array () ; 
				this_.url[0]=url_;
				this_.url[1]=this_.fromid;
			}
		}
		
		
		if (!typeof(this_.url[0])){return;}

		if(!this_.url[0]){return;}
       
		this_.ajax_yun();
        this_.ajax.open("POST", this_.url[0], true);
        this_.ajax.setRequestHeader("If-Modified-Since","0");
        this_.ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		//发送空
		try
		{
			var oForm=document.getElementById(this_.url[1]);
			
		}catch(err){
		
		   var oForm=document.getElementsByName(this_.url[1])[0];
		}
		
		var sBody=getRequestBody(oForm);
		
		this_.ajax.send(sBody);
	}

	

	/*GET提交*/
	ajaxsends.prototype.get=function()
	{
		if (!typeof(this_.url)){return;}
		
		if(!this_.url){return;}
		
		this_.ajax.open("GET",this_.url,true);
		this_.ajax_yun();
		this_.ajax.setRequestHeader("Content-Type","text/html; charset=UTF-8");
		this_.ajax.setRequestHeader("If-Modified-Since","0");
		this_.ajax.send(null);
	}
	
	this_.ajax = this_.user_InitAjaxw();
	
	if(!this_.method || this_.method=='get'  || this_.method=='GET')
	{
		
		this_.get();//GET方式
	}else{
		this_.post();//POST方式	
	}

}
//ajax调用函数
function ajax_ultimate(url,fun,method,fromid,id)
{
	new ajaxsends(url,fun,method,fromid,id);
	return ;
}
//////////////////////////////////////////

//网站头部读取城市script_city.js中函数showcity()调用到此函数()
function isUndefined(variable) {
	return typeof variable == 'undefined' ? true : false;
}

function MyKeypress(){
	var e = arguments[0];
	e=e||window.event;
	var kCode=e.keyCode||e.which||e.charCode; 

	if(kCode == '13'){
		login_check_api();
	}
}







function reg_check_api_c(msg,info_id)
{
	var msgg = msg.split("a1_ww_1a");
	if(msgg[1]=='u_chk')//用户名验证是否合法状态值 1为合法
	{
		document.getElementById("u_chk").value=msgg[2];
	}
	if(msgg[1]=='m_chk')//邮箱验证是否合法状态值 1为合法
	{
		document.getElementById("m_chk").value=msgg[2];
	}
	if(msgg[1]=='c_chk')//验证码验证是否合法状态值 1为合法
	{
		document.getElementById("c_chk").value=msgg[2];
	}
	
	document.getElementById(info_id).innerHTML=msgg[0];

}

//校正两次密码输入的正确性
function chkpwd_api() 
{
	var relogin_pwd=document.getElementById('relogin_pwd').value;
	var login_password=document.getElementById('login_pwd').value;
	var obj=document.getElementById('p_info');
	
	if (relogin_pwd=='' || login_password=='')
	{
		obj.innerHTML="<font color=\"red\">密码不能为空!</font>";
		document.myform.login_pwd.focus();
		return false;
	}
	
	if (relogin_pwd != login_password)
	{
		obj.innerHTML="<font color=\"red\">两次密码不一致</font>";
		document.myform.login_pwd.focus();
		return false;
	} else {
		obj.innerHTML="<font color=\"green\">两次密码输入一致</font>";
		return true;
	}
}

//reg_x用户注册时提交表单综合验证
function tijiaoisok_api_reg_x()
{
	var login_name = document.getElementById('login_name').value;
	if(login_name.length == 0) {
		document.getElementById('u_info').innerHTML="<font color=\"red\">帐号不能为空！</font>";
		document.myform.login_name.focus();
		return false;
	}
	if(login_name.length < 2 || login_name.length > 26) {
		document.getElementById('u_info').innerHTML="<font color=\"red\">帐号不符合要求！</font>";
		document.myform.login_name.focus();
		return false;
	}
	var email = document.getElementById('email').value;
	if(email.length == 0) {
		document.getElementById('e_info').innerHTML="<font color=\"red\">邮箱不能为空！</font>";
		document.myform.email.focus();
		return false;
	}
	
	var login_pwd = document.getElementById('login_pwd').value;
	if(login_pwd.length == 0) {
		document.getElementById('p_info').innerHTML="<font color=\"red\">密码不能为空！</font>";
		document.myform.login_pwd.focus();
		return false;
	}
	
	var relogin_pwd = document.getElementById('relogin_pwd').value;
	if(relogin_pwd.length == 0) {
		document.getElementById('p_info').innerHTML="<font color=\"red\">确认密码不能为空！</font>";
		document.myform.relogin_pwd.focus();
		return false;
	}
	
	chkpwd_api('relogin_pwd','p_info','两次密码不一致！');
	
	var u_chk=document.getElementById('u_chk').value;//用户名验证状态值
	var m_chk=document.getElementById('m_chk').value;//电子邮件验证状态值
	var c_chk=document.getElementById('c_chk').value;//验证码验证状态值
	
	if(u_chk ==1 && m_chk==1) { //表单正确提交
	   document.myform.submit();
	   return true;
	}else{
		alert('请修正红色提示部分！');
		return false;
	}
}


function sendestat_result(msg,sendestat){
	document.getElementById('sendestat').innerHTML=msg;
}
/** 
 * 判断是不是有效的email地址 
 */ 
function IsValidateEmail(str) { 
	//如果为空，则通过校验 
	if (str == "" || str.length == 0) { 
		return false; 
	} 
	//正则表达式 
	//var pattern = /^\w{1,}@[\.,\w]{1,}$/; 
	var pattern = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; 
	if (!pattern.test(str)) { 
		return false; 
	} 
	return true; 
} 
//-----------------------------------END客户留言-------------------------------------//

function ajaxsends(url,fun,method,fromid,id)
{
	var this_=this;
	this_.url=url;
	this_.fun=fun;
	this_.method=method;
	this_.fromid=fromid;
	this_.id=id;
	
	/*AJAX执行状态*/
	ajaxsends.prototype.ajax_yun=function()
	{
		//获取执行状态
		this_.ajax.onreadystatechange = function() 
		{
			//如果执行是状态正常，那么就把返回的内容赋值给上面指定的层
			if (this_.ajax.readyState == 4 && this_.ajax.status == 200)
			{
				var	strdiv = this_.ajax.responseText;  //读取PHP页面打印出来的文字
				
				var jsstr=strdiv;
				
				strdiv=strdiv.replace(/<script[\s\S]+?<\/script>/igm,"");
				//alert(strdiv);
				if(this_.fun)
				{
					//alert(this_.fun + "(strdiv,id)")
					
					eval(this_.fun + "(strdiv,id)");
				}else if(this_.id){
					 document.getElementById(this_.id).innerHTML=strdiv;
				}
				
				this_.ajaxjs(jsstr);
				
		//////////////////////////////////上面是处理//////////////////////////////////////////////////
			}
	
		}
	}
	
	/* 实例化AJAX*/
	ajaxsends.prototype.user_InitAjaxw=function()
	{
		 if (window.ActiveXObject)
		 {
			//IE
			try {
				//IE6.0以上
				return new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e1) {
					//IE5.5以下
					return new ActiveXObject("Msxml2.XMLHTTP");
			}
		} else if (window.XMLHttpRequest) {
			//FireFox
			return new XMLHttpRequest();
		}

	}
	
	/*获取表单URL*/
	ajaxsends.prototype.geturl=function()
	{	
		var u=new Array();
		
		try{
			var url=document.getElementById(this_.fromid).action; 
		}catch(err){
			var  url=document.getElementsByName(this_.fromid)[0].action; 
		}
		
		if(!url)
		{
			alert('表单action属性为空（要提交的地址）！');
			return false;
		}
		
		u[0]=url;
		u[1]=fromid;
		
		return u;
	}
	
	/*执行JS */
	ajaxsends.prototype.ajaxjs=function(msg)
	{
		var str2=msg.split("\r\n").join('');
		str2=str2.split("\n").join('');
		str2=str2.split("\r").join('');
		
		var reg=/<script[^>]*?>(.*?)<\/script>/ig;
		var str=str2.match(reg);
		
		if(!str)
		{
			return false;
		}
		
		for(var i=0;i<str.length;i++)
		{
			str[i]=str[i].replace(reg,"$1");
		
			eval(str[i]);
		}
	}
	
	
	/*POST提交*/
	ajaxsends.prototype.post=function()
    {
		if(!this_.url)
		{
			this_.url=this_.geturl();
		}else{
			if ( this_.url.constructor != window.Array)
			{
				var url_=this_.url;
				
				this_.url = new Array () ; 
				this_.url[0]=url_;
				this_.url[1]=this_.fromid;
			}
		}
		
		
		if (!typeof(this_.url[0])){return;}

		if(!this_.url[0]){return;}
       
		this_.ajax_yun();
        this_.ajax.open("POST", this_.url[0], true);
        this_.ajax.setRequestHeader("If-Modified-Since","0");
        this_.ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		//发送空
		try
		{
			var oForm=document.getElementById(this_.url[1]);
			
		}catch(err){
		
		   var oForm=document.getElementsByName(this_.url[1])[0];
		}
		
		var sBody=getRequestBody(oForm);
		
		this_.ajax.send(sBody);
	}

	

	/*GET提交*/
	ajaxsends.prototype.get=function()
	{
		if (!typeof(this_.url)){return;}
		
		if(!this_.url){return;}
		
		this_.ajax.open("GET",this_.url,true);
		this_.ajax_yun();
		this_.ajax.setRequestHeader("Content-Type","text/html; charset=UTF-8");
		this_.ajax.setRequestHeader("If-Modified-Since","0");
		this_.ajax.send(null);
	}
	
	this_.ajax = this_.user_InitAjaxw();
	
	if(!this_.method || this_.method=='get'  || this_.method=='GET')
	{
		
		this_.get();//GET方式
	}else{
		this_.post();//POST方式	
	}

}







//ajax调用函数
function ajax_ultimate(url,fun,method,fromid,id)
{
	new ajaxsends(url,fun,method,fromid,id);
	return ;
}

function to(url){
	window.open=url;
}
            
function toQzoneLogin()
{
   var A=window.open("/oauth/redirect_to_login.php","TencentLogin","width=450,height=320,menubar=0,scrollbars=1, resizable=1,status=1,titlebar=0,toolbar=0,location=1");
} 
