/*  用户注册脚本 */	
function CreateXMLHTTPObject()
{
	var xObject = null;

	try 
	{
		xObject = new ActiveXObject("Msxml2.xmlhttp.4.0");
	}
	catch (e)
	{
		try
		{
			xObject = new XMLHttpRequest(); 
			if (xObject.overrideMimeType) {//设置MiME类别
				xObject.overrideMimeType('text/xml');
			}
		}
		catch (e)
		{
			try 
			{
				xObject = new ActiveXObject("Msxml2.xmlhttp");
			} 
			catch (e) 
			{
				try 
				{
					xObject = new ActiveXObject("Microsoft.xmlhttp");
				} 
				catch (e) 
				{
					alert("Error: Unable to create XML HTTP object!");
				}
			}
		}
	}

	return xObject;
}

function check_form(){
	if (document.getElementById("UserName").value=="")
	{
		document.getElementById("UserName_box").className="errorbox";
		document.getElementById("UserName_box").innerHTML = "<font color='RED'>此项必须填写。</font><br />会员登录名只能由6-15个英文字母或数字组成(不支持中文)";
		document.getElementById("UserName_true").style.visibility = "hidden";
	}
	if (document.getElementById("Password").value=="")
	{
		document.getElementById("Password_box").className="errorbox";
		document.getElementById("Password_box").innerHTML = "<font color='RED'>此项必须填写。</font><br />密码由6-15个英文字母(区分大小写)或数字组成，建议采用易记、难猜的英文、数字组合。";
		document.getElementById("Password_true").style.visibility = "hidden";
	}
	if (document.getElementById("PwdConfirm").value=="")
	{
		document.getElementById("PwdConfirm_box").className="errorbox";
		document.getElementById("PwdConfirm_box").innerHTML = "<font color='RED'>此项必须填写。</font><br />请再输入一遍您上面填写的密码。";
		document.getElementById("PwdConfirm_true").style.visibility = "hidden";
	}
	if (document.getElementById("Email").value=="")
	{
		document.getElementById("Email_box").className="errorbox";
		document.getElementById("Email_box").innerHTML = "<font color='RED'>此项必须填写。</font><br />请再输入一遍您上面填写的密码。";
		document.getElementById("Email_true").style.visibility = "hidden";
	}

	if (document.getElementById("UserName").value=="")
	{
		document.getElementById("UserName").focus();
		return false;
	}
	else if (document.getElementById("Password").value=="")
	{
		document.getElementById("Password").focus();
		return false;
	}
	else if (document.getElementById("PwdConfirm").value=="")
	{
		document.getElementById("PwdConfirm").focus();
		return false;
	}else if (document.getElementById("Email").value=="")
	{
		document.getElementById("Email").focus();
		return false;
	}else{
	
		var finished = true;
	
if(document.UserReg.agreement.value!=1){
			finished = false;
			alert("请同意注册协议");
			document.UserReg.agreement.focus(); 
			return false;
		}
		allElements = document.getElementsByTagName('*');

		for (var i=0; i<allElements.length; i++)
		{
			var obj = allElements[i];
			if (obj.className=="errorbox")
			{
				finished = finished && false;
			}
			else
			{
				finished = finished && true;
			}
		}

		if (finished)
		{
			return true;
		}
		else
		{
			return false;
		}
	}





}


function input_onfocus(input)
{



	if (document.getElementById(input.name+"_box"))
	{
		if (document.getElementById(input.name+"_box").innerHTML!="")
		{
			if ((document.getElementById(input.name+"_box").className!="errorbox") && 
				(input.name!='jobtitle') &&
				(input.name!='mobileno'))
			{
				document.getElementById(input.name+"_box").className="nowbox";
			}
		}
	}
	switch (input.name)
	{
		case "memberid":
			if (document.getElementById("UserName_box").className!="errorbox")
			{
				document.getElementById("UserName_box").innerHTML = "会员登录名只能由6-15个英文字母或数字组成(不支持中文)";
			}
			break;

		case "Password":
			if (document.getElementById("Password_box").className!="errorbox")
			{
				document.getElementById("Password_box").innerHTML = "密码由6-15个英文字母或数字组成，建议采用易记、难猜的英文、数字组合。";
			}
			break;
		case "PwdConfirm":
			if (document.getElementById("PwdConfirm_box").className!="errorbox")
			{
				document.getElementById("PwdConfirm_box").innerHTML = "请再输入一遍您上面填写的密码。";
			}
			break;	
		case "Email":
			if (document.getElementById("Email_box").className!="errorbox")
			{/*非常重要！这是客户与您联系的首选方式，请务必填写真实，并确认是您最常用的电子邮件。*/
				document.getElementById("Email_box").innerHTML = "请确保使用了您常用的邮箱。";
			}
			break;	
			
	}

}



function input_onblur(input)
{
	if (document.getElementById(input.name+"_box"))
	{
		if (document.getElementById(input.name+"_box").innerHTML!="")
		{
			if (document.getElementById(input.name+"_box").className!="errorbox")
			{
				document.getElementById(input.name+"_box").className="px12";
			}	
		}		
	}
	switch (input.name)
	{
		case "UserName":
			change_memberid();
			break;	
		case "Password":
			change_password();
			break;
		case "PwdConfirm":
			change_repassword();
			break;
		case "Email":
			change_email();
			break;

	}
}


function change_memberid()
{
	var obj = document.getElementById("UserName");
	
	if ((obj.className!="errorbox") && (obj.value!=''))
	{
		action = 1;

		xmlhttp = CreateXMLHTTPObject();
		xmlhttp.onreadystatechange = getReady;
		xmlhttp.open("POST", "member_check.php?action=memberid", true);
		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlhttp.send("memberid="+obj.value);
		document.getElementById("UserName_box").className="nowbox";
		document.getElementById("UserName_box").innerHTML="正在与数据库服务器通讯中...";
	}
}


function change_password() {
	var obj = document.getElementById("Password");
	if (obj.value.length==0)
	{
		if (document.getElementById("Password_box").className!="errorbox")
		{
			document.getElementById("Password_box").className="px12";
			document.getElementById("Password_box").innerHTML = "密码由6-15个英文字母或数字组成，建议采用易记、难猜的英文、数字组合";
			document.getElementById("Password_true").style.visibility = "hidden";
		}
	}
	else if (obj.value.length<6 || obj.value.length>15)
	{
		document.getElementById("Password_box").className="errorbox";
		document.getElementById("Password_box").innerHTML = "<font color='RED'>您填写的有误。<br /></font>密码由6-15个英文字母或数字组成，建议采用易记、难猜的英文、数字组合。";
		document.getElementById("Password_true").style.visibility = "hidden";
	}
	else
	{
		document.getElementById("Password_box").innerHTML = "填写正确。";
		document.getElementById("Password_box").className="px12";
		document.getElementById("Password_true").style.visibility = "visible";
	}
	if (document.getElementById("PwdConfirm").value!="")
	{
		change_repassword();
	}
}


function change_repassword() {
	var repassword_obj = document.getElementById("PwdConfirm");
	var password_obj = document.getElementById("Password");
	if (repassword_obj.value.length==0)
	{
		document.getElementById("PwdConfirm_box").className="px12";
		document.getElementById("PwdConfirm_true").style.visibility = "hidden";
		document.getElementById("PwdConfirm_box").innerHTML = "请再输入一遍您上面填写的密码。";
	}
	else if (repassword_obj.value==password_obj.value)
	{
		document.getElementById("PwdConfirm_box").className="px12";
		document.getElementById("PwdConfirm_box").innerHTML = "填写正确。";
		document.getElementById("PwdConfirm_true").style.visibility = "visible";
	}
	else
	{
		document.getElementById("PwdConfirm_box").className="errorbox";
		document.getElementById("PwdConfirm_box").innerHTML = "<font color='RED'>您再次填写的密码不一致。</font><br />请按照上方填写的密码再填一次。";
		document.getElementById("PwdConfirm_true").style.visibility = "hidden";
	}
}

function change_email()
{


	var obj = document.getElementById("Email");

	if(obj.value==""){

		document.getElementById("Email_box").className="errorbox";
		document.getElementById("Email_true").style.visibility = "hidden";
		document.getElementById("Email_box").innerHTML = "<font color='RED'>请填写邮箱地址。</font><br />请确保使用了您常用的邮箱。";

	}else{
		var i = 1;
		var len = obj.value.length;
		if (len > 100){
			document.getElementById("Email_box").className="errorbox";
			document.getElementById("Email_true").style.visibility = "hidden";
			document.getElementById("Email_box").innerHTML = "<font color='RED'>您填写邮箱地址长度超过100个字符。</font><br />请确保使用了您常用的邮箱。";
		}else{

			pos1 = obj.value.indexOf("@");
			pos2 = obj.value.indexOf(".");
			pos3 = obj.value.lastIndexOf("@");
			pos4 = obj.value.lastIndexOf(".");
			//check '@' and '.' is not first or last character
			if ((pos1 <= 0)||(pos1 == len)||(pos2 <= 0)||(pos2 == len)) {
				document.getElementById("Email_box").className="errorbox";
				document.getElementById("Email_true").style.visibility = "hidden";
				document.getElementById("Email_box").innerHTML = "<font color='RED'>您填写的有误。</font><br />请确保使用了您常用的邮箱。";
			}else{
				//check @. or .@
				if( (pos1 == pos2 - 2) || (pos1 == pos2 + 2) 
				|| ( pos1 != pos3 )  //find two @
				|| ( pos4 < pos3 ) ) //. should behind the '@'  		
				{
					document.getElementById("Email_box").className="errorbox";
					document.getElementById("Email_true").style.visibility = "hidden";
					document.getElementById("Email_box").innerHTML = "<font color='RED'>您填写的有误。</font><br />请确保使用了您常用的邮箱。";
				}else{

					document.getElementById("Email_box").className="px12";
					document.getElementById("Email_box").innerHTML = "填写正确。";
					document.getElementById("Email_true").style.visibility = "visible";

				}
			}
		}
	}

}


function getReady()
{

	if(xmlhttp.readyState==4)
	{
		if(xmlhttp.status==200)
		{
			if (action==1)
			{
				switch (xmlhttp.responseText){
					case "OK":
						document.getElementById("UserName_box").innerHTML = "该会员名可以注册。";
						document.getElementById("UserName_box").className="px12";
						document.getElementById("UserName_true").style.visibility = "visible";
						break;
					case "ERR_1":
						document.getElementById("UserName_box").innerHTML = "<font color='RED'>该用户名已经被注册。</font><br />会员登录名只能由6-15个英文字母或数字组成";
						document.getElementById("UserName_box").className="errorbox";
						document.getElementById("UserName_true").style.visibility = "hidden";
						break;

					case "ERR_2":
						document.getElementById("UserName_box").innerHTML = "<font color='RED'>您填写的有误。<br /></font>会员登录名只能由6-15个英文字母或数字组成(不支持中文)";
						document.getElementById("UserName_box").className="errorbox";
						document.getElementById("UserName_true").style.visibility = "hidden";
						break;
					default:

				}

			}
			xmlhttp = null;
		}
	}
	
}


        function showRegister()
        {
            var ck = document.getElementById("ckCheck");
            var btn = document.getElementById("validatemsg");
            if(ck.checked )
            {
                btn.style.display = "block";
             }
            else
                btn.style.display = "none";
        }



		//-->
	
/*  伯客注册 */	
function showadv(){
if (document.UserReg.advshow.checked == true) {
        adv.style.display = "";
        advance.innerText="关闭申请博客:";
}else{
        adv.style.display = "none";
        advance.innerText="我要申请博客:";
}


}



function check_user_exists(form){
u_name=myform.TextBoxUserName.value;
myurl=location.protocol+"//"+location.hostname+"/member_check.php?weblan=e&mbName="+u_name;
checkm.location.href=myurl;
return;
}


function do_feedback(form){
title=myform.title.value;
name=myform.name.value;
sex=myform.sex.value;
tel=myform.tel.value;
fax=myform.fax.value;
address=myform.address.value;
email=myform.email.value;
qq=myform.qq.value;
msn=myform.msn.value;
content=myform.content.value;
weblan=myform.weblan.value;
tt_id=myform.tt_id.value;
act=myform.act.value;
myurl='article.php?tt_id='+tt_id+'&act='+act+'&title='+title+'&name='+name+'&sex='+sex+'&tel='+tel+'&fax='+fax+'&address='+address+'&email='+email+'&qq='+qq+'&msn='+msn+'&content='+content+'&weblan='+weblan;
checktl.location.href=myurl;
return;
}

 /* ============================================================会员注册二次表单==============================	*/	  
function CheckusersecordForm()
{

	if (document.UserReg.user_name.value==""){
		alert("请输入您的姓名或昵称！");
		document.UserReg.user_name.focus(); 
		return false
	}
	if (document.UserReg.address.value==""){
		alert("请填写您的地址");
		document.UserReg.address.focus(); 
		return false
	}	if(document.UserReg.mobile.value==""){
		alert("请填写您的手机号码");
		document.UserReg.mobile.focus(); 
		return false
	}
}


function CheckuserthirdForm()
{

	if (document.frm.producer_name.value==""){
		alert("请输入完整的公司名称！");
		document.frm.producer_name.focus(); 
		return false
	}
	if (document.frm.area.value==""){
		alert("请选择公司所在区域");
		document.frm.area.focus(); 
		return false
	}
	
    if(document.frm.hy_type1.value==""){
		alert("请选择行业分类");
		document.frm.hy_type1.focus(); 
		return false
	}
    if(document.frm.selcity.value==""){
		alert("请选择行业分类");
		document.frm.selcity.focus(); 
		return false
	}
    if(document.frm.seltown.value==""){
		alert("请选择行业分类");
		document.frm.seltown.focus(); 
		return false
	}
    if(document.frm.phone.value==""){
		alert("请填写公司联系电话");
		document.frm.phone.focus(); 
		return false
	}
    if(document.frm.fax.value==""){
		alert("请填写公司传真号码");
		document.frm.fax.focus(); 
		return false
	}
    if(document.frm.conent.value==""){
		alert("请填写公司负责人姓名");
		document.frm.conent.focus(); 
		return false
	}
    if(document.frm.email.value==""){
		alert("请填写公司常用企业邮箱");
		document.frm.email.focus(); 
		return false
	}
    if(document.frm.intro.value==""){
		alert("请填写公司介绍");
		document.frm.intro.focus(); 
		return false
	}
}



 /*  用户登陆 */	

	function CheckForm()
	{
		if(document.UserLogin.username.value=="")
		{
			alert("请输入用户名");
			document.UserLogin.username.focus();
			return false;
		}
		if(document.UserLogin.password.value == "")
		{
			alert("请输入密码");
			document.UserLogin.password.focus();
			return false;
		}
	}


	  function Checksendpw()
{

	if (document.sendpw.name.value==""){
		alert("请输入你的用户ID！");
		document.sendpw.name.focus(); 
		return false
	}
	if (document.sendpw.quesion.value==""){
		alert("请填写你的密码问题");
		document.sendpw.quesion.focus(); 
		return false
	}	if(document.sendpw.answer.value==""){
		alert("请正确填写你的问题答应");
		document.sendpw.answer.focus(); 
		return false
	}
}




function checkupassinput() { 

	if(document.frm.old_pass.value=='' || document.frm.new_pass.value=='' || document.frm.new_pass2.value==''){
		alert("请输入密码");
		document.frm.old_pass.focus();
		return false;
	}
	if(document.frm.new_pass.value != document.frm.new_pass2.value){
		alert("请确定新密码输入是否正确");
		document.frm.new_pass.focus();
		return false;
	}
	return true;
}



/* 网页头鼠标经过JS */	
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



var i = 2;
function addfiles() {
	var str='<ul id="layer'+i+'"><span id=td1></span> <input type="file" name="imgs'+i+'" size="20" class="upload"><input type=button value="del" onclick="delfiles('+i+')"></ul>';
    document.swform.i.value=i;
	i++;
	document.all['nf'].innerHTML += str;
}
function delfiles(str) {
	

	document.getElementById("layer"+str).innerHTML = "";
	eval("layer"+str+".style.display=\"none\";");
    //eval("document.myform.imgs"+str+".value=''");

}

/*======================================================== 商务信息脚本 */	
	  function Checkinfoform()
{


		if(document.swform.in_title.value==""){
		alert("请输入信息标题");
		document.swform.in_title.focus(); 
		return false
	}
		if(document.swform.content.value==""){
		alert("请填写信息内容");
		document.swform.content.focus(); 
		return false
	}		if(document.swform.phone.value==""){
		alert("手机或电话请留一个");
		document.swform.phone.focus(); 
		return false
	}
}


/*========================================================  /*  用户发布商机控制 */	

	function Checksjform()
	{
		if(document.sjfrom.sj_title.value=="")
		{
			alert("请输入发布商机的标题");
			document.sjfrom.sj_title.focus();
			return false;
		}
		if(document.sjfrom.sj_t.value == "")
		{
			alert("请选择行业分类");
			document.sjfrom.sj_t.focus();
			return false;
		}
		
		if(document.sjfrom.sj_http.value == "")
		{
			alert("请输入链接网址");
			document.sjfrom.sj_http.focus();
			return false;
		}
	}

function show_sj_way(i){
	if(i==2){
		import_file.style.display = "";
	}else if(i==1){
		import_file.style.display = "none";		
	}
}
