// JavaScript Document
//用户登陆验证开始
function send_request(url){
http_request=false;
if(window.XMLHttpRequest){
  http_request=new XMLHttpRequest();
  if(http_request.overrideMineType){
    http_request.overrideMineType("text/xml");
}}

else if(window.ActiveXObject){
  try{
    http_request=new ActiveXObject("Msxml2.XMLHTTP");
  }catch(e){
    try{
	   http_request=new ActiveXObject("Microsoft.XMLHTTP");
	}catch(e){}
  }
  
}

if(!http_request){
window.alert("can not create xmlhttpRequest example");
return false;
}
http_request.onreadystatechange=processRequest;
http_request.open("GET",url,true);
http_request.send(null);
}

function processRequest(){
var atomwu = document.getElementById("detectuser");	
if(http_request.readyState==4){
  if(http_request.status==200){
    //alert(http_request.responseText);
	if(http_request.responseText == "||"){
		document.getElementById("user_password").value = "";
		atomwu.innerHTML = "Wrong with password";}
	else{
		document.getElementById("user_name").value = "";
		document.getElementById("user_password").value = "";
        atomwu.innerHTML = http_request.responseText; 
		}
  }else{
    alert("some error");
  }
  
}
}

function userCheck(){
var user_name=document.getElementById("user_name").value;
var user_password=document.getElementById("user_password").value;
if(user_name == "" || user_password == ""){
	document.getElementById("detectuser").innerHTML = "empty";}
else
send_request("User_login_check.asp?user_name="+user_name+"&user_password="+user_password); 
}
//用户登陆验证登陆

//检查用户名开始
function send_requestx(url){
http_request=false;
if(window.XMLHttpRequest){
  http_request=new XMLHttpRequest();
  if(http_request.overrideMineType){
    http_request.overrideMineType("text/xml");
}}

else if(window.ActiveXObject){
  try{
    http_request=new ActiveXObject("Msxml2.XMLHTTP");
  }catch(e){
    try{
	   http_request=new ActiveXObject("Microsoft.XMLHTTP");
	}catch(e){}
  }
  
}

if(!http_request){
window.alert("can not create xmlhttpRequest example");
return false;
}
http_request.onreadystatechange=processRequestx;
http_request.open("GET",url,true);
http_request.send(null);
}

function processRequestx(){
var atomwu = document.getElementById("usernamecheckedid");	
if(http_request.readyState==4){
  if(http_request.status==200){
    //alert(http_request.responseText);
	if(http_request.responseText == "n"){
		document.getElementById("contactperson").value = "";
		document.getElementById("registersubmite").disabled=true;
		atomwu.innerHTML = "Can not be used";}
	else{
        atomwu.innerHTML = "Can be used";
		document.getElementById("registersubmite").disabled=false;
		}
  }else{
    alert("some error");
  }
  
}
}

function registerCheck(){
var user_name=document.getElementById("contactperson").value;
if(user_name == ""){
	document.getElementById("usernamecheckedid").innerHTML = "empty";}
else
send_requestx("User_register_check.asp?user_name="+user_name); 
}
//检查用户名结束


//用户注册验证开始
function registerallcheck(){
var user_name = document.getElementById("contactperson").value;
var password = document.getElementById("password").value;
var repassword = document.getElementById("repassword").value;
var email = document.getElementById("email").value;
var reEmail = /^(?:\w+\.?)*\w+@(?:\w+\.?)*\w+$/;
if(user_name == "" || user_name.length < 4){
	document.getElementById("usernamecheckedid").innerHTML= "No name Or short";
	return false;
	}
if(reEmail.test(email)==false){
	document.getElementById("emailcheckedid").innerHTML = "Not correct";
	return false;}
if(password == "" || password != repassword){
	document.getElementById("passwordcheckedid").innerHTML = "Pls confirm password";
	return false;
	}	
return true;
}

//用户注册验证结束





//用户注册弹出框
function userregister(){
//背景
var body_width=screen.width-30+'px';
var wh = window.document.documentElement.scrollHeight;
var bg_obj = createDiv("play_bg","#D5D5D5","0px","0px","absolute",body_width,wh+'px',"999");
bg_obj.style.filter='alpha(opacity=80)';
document.body.appendChild(bg_obj);
//注册填写
dvs = createDiv("av_play","#ffffff","0px","0px","absolute","600px","480px","10000");
dvs.style.top=document.body.clientTop+50+'px';
dvs.style.border="2px solid #cccccc";
dvs.style.left = document.body.clientWidth/5+'px';
document.body.appendChild(dvs);
dvs.style.textAlign="center";
dvs.style.padding="10px";
dvs.innerHTML='<div style="padding:0px; margin:0px; width:600px; border:#CCCCCC 1px solid;"><form style="padding:0px; margin:0px;" onsubmit="return registerallcheck();" action="User_register_add.asp" method="post"><ul style="padding:0px; margin:0px; list-style:none; width:600px;"><li style="width:600px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:14px; font-weight:bold; text-align:left;">Register</li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Sex</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Male <input type="radio" name="sex" value="1"> Female <input type="radio" name="sex" value="0"></li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Username</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="contactperson" onblur="registerCheck();"><span style="color:#FF0000;">*</span><span style="color:#009900;" id="usernamecheckedid"></span></li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Password</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="password" style="padding:0px; margin:0px; width:300px; height:14px;" name="password"><span style="color:#FF0000;">*</span>'+'<li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Repassword</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="password" style="padding:0px; margin:0px; width:300px; height:14px;" name="repassword"><span style="color:#FF0000;">*</span><span style="color:#FF0000;" id="passwordcheckedid"></span></li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Companyname</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="companyname"></li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Address</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="address"></li>'+'<li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Country</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="country"></li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">City</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="city"></li>'+'<li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Tel</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="tel"></li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Fax</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="fax"></li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Email</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="email"><span style="color:#FF0000;">*</span><span style="color:#FF0000;" id="emailcheckedid"></span></li>'+'<li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Website</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="website"></li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Business Detail</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="checkbox" value="1" name="businessdetail1"/>importer/exporter</li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"></li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="checkbox" value="1" name="businessdetail2"/>distributor</li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"></li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid;font-size:12px;text-align:left;"><input type="checkbox" value="1" name="businessdetail3"/>retailer</li><li style="width:100px; float:left;height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"></li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="checkbox" value="1" name="businessdetail4"/>buying agent</li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"></li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="checkbox" value="1" name="businessdetail5"/>broker</li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"></li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="checkbox" value="1" name="businessdetail6"/>promotion house</li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"></li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Would you like to receive our latest products information?<input type="checkbox" value="1" name="receive"/></li><li style="width:100px; float:left; height:20px; font-size:12px;text-align:left;"></li><li style="width:500px; float:left; height:20px; font-size:12px;text-align:left;"><input type="submit" value="Submit" id="registersubmite"/><input type="button" value="Cancel" onclick="close_play();"/></li>'+'</ul></form></div>';
}


function feedbackcheck(){
var contactperson = document.getElementById("contactperson");
var email = document.getElementById("email");
var reEmail = /^(?:\w+\.?)*\w+@(?:\w+\.?)*\w+$/;
if(contactperson.value == ""){
	document.getElementById("contactpersondetect").innerHTML= "input contactperson";
	alert("input contactperson");
	return false;
}
if(reEmail.test(email.value)==false){
	document.getElementById("emailcheckedid").innerHTML = "input correct email";
	return false;
}
document.getElementById("feedbackokdetect").innerHTML = "Done";
return true;
}



//用户反馈弹出框
function userfeedback(){
//背景
var body_width=screen.width-30+'px';
var wh = window.document.documentElement.scrollHeight;
var bg_obj = createDiv("play_bg","#D5D5D5","0px","0px","absolute",body_width,wh+'px',"999");
bg_obj.style.filter='alpha(opacity=80)';
document.body.appendChild(bg_obj);
//注册填写
dvs = createDiv("av_play","#ffffff","0px","0px","absolute","600px","480px","10000");
dvs.style.top=document.body.clientTop+50+'px';
dvs.style.border="2px solid #cccccc";
dvs.style.left = document.body.clientWidth/5+'px';
document.body.appendChild(dvs);
dvs.style.textAlign="center";
dvs.style.padding="10px";
dvs.innerHTML='<div style="padding:0px; margin:0px; width:600px; border:#CCCCCC 1px solid;"><form style="padding:0px; margin:0px;" onsubmit="return feedbackcheck();" action="Feedback_add.asp" method="post"><ul style="padding:0px; margin:0px; list-style:none; width:600px;"><li style="width:600px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:14px; font-weight:bold; text-align:left;">Feedback</li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Contactperson</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="contactperson"><span style="color:#FF0000;">*</span><span style="color:#009900;" id="contactpersondetect"></span></li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Companyname</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="companyname"></li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Address</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="address"></li>'+'<li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Country</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="country"></li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">City</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="city"></li>'+'<li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Tel</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="tel"></li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Fax</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="fax"></li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Email</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="email"><span style="color:#FF0000;">*</span><span style="color:#FF0000;" id="emailcheckedid"></span></li>'+'<li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;">Website</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><input type="text" style="padding:0px; margin:0px; width:300px; height:14px;" name="website"></li><li style="width:100px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;height:84px;">Content</li><li style="width:500px; float:left; height:20px; border-bottom:#CCCCCC 1px solid; font-size:12px;text-align:left;"><textarea style="padding:0px; margin:0px; width:300px; height:80px;" name="content"></textarea></li><li style="width:100px; float:left; height:20px; font-size:12px;text-align:left;"></li><li style="width:500px; float:left; height:20px; font-size:12px;text-align:left;"><span style="color:#FF0000;" id="feedbackokdetect"></span></li><li style="width:100px; float:left; height:20px;  font-size:12px;text-align:left;"></li><li style="width:500px; float:left; height:20px; font-size:12px;text-align:left;"><input type="submit" value="Submit" id="feedsubmite" onclick="return feedbackcheck();"/><input type="button" value="Cancel" onclick="close_play();"/></li>'+'</ul></form></div>';
}




//用户登陆弹出对话框开始
function user_login_pop(){
var body_width=screen.width-30+'px';
var wh = window.document.documentElement.scrollHeight;
var bg_obj = createDiv("play_bg","#D5D5D5","0px","0px","absolute",body_width,wh+'px',"999");
bg_obj.style.filter='alpha(opacity=80)';
document.body.appendChild(bg_obj);
//用户登陆框
dvs = createDiv("av_play","#ffffff","0px","0px","absolute","200px","100px","10000");
dvs.style.top=document.body.clientTop+100+'px';
dvs.style.border="2px solid #cccccc";
dvs.style.left = document.body.clientWidth/5+'px';
document.body.appendChild(dvs);
dvs.style.textAlign="center";
dvs.style.padding="10px";
dvs.innerHTML='<ul style="padding:0px; margin:0px; list-style:none; height:100px; width:200px; border:#CCCCCC 1px solid;"><li style="height:20px; width:200px; font-size:13px; font-weight:bold;">User Login</li><li style="height:20px; width:200px; font-size:12px; text-align:left;">Username<input type="text" style="padding:0px; margin:0px; height:16px; width:120px;" name="user_name"/></li><li style="height:20px; width:200px; font-size:12px; text-align:left;">&nbsp;Password<input type="password" style="padding:0px; margin:0px; height:16px; width:120px;" name="user_password"/></li><li style="height:20px; width:200px; font-size:12px;"><input type="button" value="submit" onclick="userCheckpop();"/> <input type="button" value="cancel" onclick="close_play();" /></li><li style="height:20px; width:200px; font-size:12px; color:#990000;" id="detectuser"></li></ul>';
//location.reload();
}
//用户登陆弹出对话框结束

//用户登陆弹出对话框验证开始
function send_requestpop(url){
http_request=false;
if(window.XMLHttpRequest){
  http_request=new XMLHttpRequest();
  if(http_request.overrideMineType){
    http_request.overrideMineType("text/xml");
}}

else if(window.ActiveXObject){
  try{
    http_request=new ActiveXObject("Msxml2.XMLHTTP");
  }catch(e){
    try{
	   http_request=new ActiveXObject("Microsoft.XMLHTTP");
	}catch(e){}
  }
  
}

if(!http_request){
window.alert("can not create xmlhttpRequest example");
return false;
}
http_request.onreadystatechange=processRequestpop;
http_request.open("GET",url,true);
http_request.send(null);
}
function processRequestpop(){
var atomwu = document.getElementById("detectuser");	
if(http_request.readyState==4){
  if(http_request.status==200){
    //alert(http_request.responseText);
	if(http_request.responseText == "||"){
		document.getElementById("user_password").value = "";
		atomwu.innerHTML = "Wrong with password";}
	else{
		document.getElementById("user_name").value = "";
		document.getElementById("user_password").value = "";
        atomwu.innerHTML = http_request.responseText;
		location.reload();
		}
  }else{
    alert("some error");
  }
  
}
}

function userCheckpop(){
var user_name=document.getElementById("user_name").value;
var user_password=document.getElementById("user_password").value;
if(user_name == "" || user_password == ""){
	document.getElementById("detectuser").innerHTML = "empty";}
else
send_requestpop("User_login_check.asp?user_name="+user_name+"&user_password="+user_password); 
}
////用户登陆弹出对话框验证结束




function close_play(){
	var bg_obj=document.getElementById("play_bg");
	var dvs = document.getElementById("av_play");
	document.body.removeChild(bg_obj);
	document.body.removeChild(dvs);
}


/*创建一个div对象*/
function createDiv(dvid,bgcolor,lft,tp,pos,wdth,hgt,zindex){
	var newdv = document.createElement("div");
	if(dvid!=""){
		newdv.id = dvid;
	}
	if(bgcolor!=""){
		newdv.style.backgroundColor=bgcolor;
	}
	if(lft!=""){
		newdv.style.left = lft;
	}
	if(tp!=""){
		newdv.style.top = tp;
	}
	if(pos!=""){
		newdv.style.position = pos;
	}
	if(wdth!=""){
		newdv.style.width = wdth;
	}
	if(hgt!=""){
		newdv.style.height = hgt;
	}
	if(zindex!=""){
		newdv.style.zIndex = zindex;
	}
	return newdv;
}

function Gotosearch(){
var searchkey = document.getElementById("searchkey").value;
if(searchkey == ""){
 return false;
}
else
 document.formsearch.submit();
}





function gourl(id){
window.location.href=id;
}

function photochange(id){
document.getElementById("product_pic").src="admin/up/"+id;
}



