﻿var t_DiglogX=0;
var t_DiglogY=0;
var t_DiglogW=0;
var t_DiglogH=0;
var right="<img src='../template/default/images/note_ok.gif'>";
var error="<img src='../template/default/images/note_error.gif'>";
var errorold="<img src='template/default/images/note_error.gif'>";
var rightold="<img src='template/default/images/note_ok.gif'>";
var pass=/^[^#&/*<>'", \\\r\t\n]{6,16}$/;
var user_length_error=error+"<font color=\"red\"> 用户名长度错误,3-12字符内！</font>";
var user_regist_ok=right+"<font color=\"green\">恭喜您，该用户名还未被注册，您可以使用这个用户名！</font>";
var user_regist_error=error+"<font color=\"red\"> 该用户名已经被注册，请选用其他用户名。</font>";
var waite_chk="检测中，请稍等...";
var pwd_nothing_error=error+"<font color=red > 请输入密码!</font>";
var pwd_length_error=error+"<font color=red > 密码不合法!最少6位(英文字母、数字)，区分大小写</font>";
var pwd_insert_align=error+"<font color=red > 请再一次输入遍您上面输入的密码</font>";
var pwd_same_error=error+"<font color=red > 两次密码不符，请重新输入</font>";
var email_nothing_error=error+"<font color=red > 请输入您的电子邮件地址</font>";
var email_error_error=error+"<font color=red > 电子邮件地址不符合规则!</font>";
var email_regist_error=error+'<font color=red > 该电子邮件地址已被注册!</font>';
var code_length_error=error+"<font color=red > 请正确输入验证码</font>";
var ok=right+"<font color=green > 符合要求!</font>";
var user_login_error=error+"<font color=\"red\">用户名3-12字符内！</font>";
var user_pwd_error=error+"<font color=\"red\">密码6-32字符内！</font>";
var user_pwd11_error=error+"<font color=\"red\">密码只能为英文字母、数字！</font>";
var okok="";
var chrshop_length_error=error+"<font color=\"red\">请输入持卡消费的商家,如果不记得请到商家列表查询！</font>";
var chrshop_add_error=error+"<font color=\"red\">对不起,此商家不存在,如果不记得请到商家列表查询！</font>";
var chrxiangmu_length_error=error+"<font color=\"red\">对不起,请填写购买或消费的名目！</font>";
var chrusername_length_error=error+"<font color=\"red\">对不起,请填写消费人真实姓名！</font>";
var chrxiangmu_length1_error=error+"<font color=\"red\">对不起,购买或消费的名目长度不能大于30！</font>";
var chrusername_length1_error=error+"<font color=\"red\">对不起,消费人真实姓名长度不能大于10！</font>";
var chrxiaofei_length_error=error+"<font color=\"red\">对不起,请填写消费的总金额！</font>";
var okokok=rightold+"<font color=green > 符合要求!</font>";
var chrchrmark_length_error=error+"<font color=red > 对不起,其它反馈信息与谏言，限200汉字内!</font>";
var chrmark_error="(欢迎反馈其它信息与谏言，限200汉字内)";
var shopcomment_error_name=error+"<font color=\"red\">对不起,请填写您的用户名！</font>";
var shopcomment_error_pwd=error+"<font color=\"red\">对不起,请填写您的密码！</font>";
var shopcomment_error_code=error+"<font color=\"red\">对不起,请填写验证码！</font>";
var shopcomment_error_chrmark=error+"<font color=\"red\">对不起,请填写内容！</font>";
var shopcomment_error_chrmark1=error+"<font color=\"red\">对不起,内容仅限300汉字！</font>";
var chrxiaofeidate_length=error+"<font color=red > 对不起,请填写购买或消费的时间!</font>";
function setmsg(obj,id){
	document.getElementById(obj).innerHTML = eval(id);
}
function doc(ob)
{
	var value=document.getElementById(ob).value;
	value=value.replace(/(^\s)|(\s$)/g,'');
	return value;
}
function getObj(ob)
{
	var obj=document.getElementById(ob);
	return obj;
}
/****************************通过ID号取得对象***********************************/
function $$(id){
  return document.getElementById(id);
}
function checkcompanycomment(){
	if($$("chrname")){
		trimspace($$("chrname"))
		if($$("chrname").value==""){
			$$("chrname").focus();
			setmsg('checkcompany','shopcomment_error_name');
			return false;
		}	
	}
	if($$("chrpwd")){
		trimspace($$("chrpwd"))
		if($$("chrpwd").value==""){
			$$("chrpwd").focus();
			setmsg('checkcompany','shopcomment_error_pwd');
			return false;
		}	
	}
	if($$("code")){
		trimspace($$("code"))
		if($$("code").value==""){
			$$("code").focus();
			setmsg('checkcompany','shopcomment_error_code');
			return false;
		}	
	}
	trimspace($$("chrmark"))
	if($$("chrmark").value==""){
		$$("chrmark").focus();
		setmsg('checkcompany','shopcomment_error_chrmark');
		return false;
	}
	if($$("chrmark").value.length>300){
		$$("chrmark").select();
		setmsg('checkcompany','shopcomment_error_chrmark1');
		return false;
	}
	var chrname="";
	if($$("chrname")){
		chrname=$$("chrname").value;
	}
	var chrpwd="";
	if($$("chrpwd")){
		chrpwd=$$("chrpwd").value;
	}	
	addcompanycomment(chrname,chrpwd,$$("code").value,$$("chrmark").value,$$("shopid").value,$$("total_score").value);
	return false;
}
function addcompanycomment(chrname,chrpwd,code,chrmark,shopid,score)
{
      	var url="../request.aspx?action=addcommpanycomment&chrname="+escape(chrname);
		url =url+"&chrpwd="+escape(chrpwd)+"&code="+escape(code)+"&chrmark="+escape(chrmark)+"&shopid="+escape(shopid)+"&score="+escape(score);
		var  Digital=new  Date();
		Digital=Digital+40000;
		url=url+"&k="+Digital;
		xmlHttp=GetXmlHttpObject(requestaddshopcomment)
		xmlHttp.open("POST", url , true)
		xmlHttp.send(null)
}
function checkshopcomment(){
	if($$("chrname")){
		trimspace($$("chrname"))
		if($$("chrname").value==""){
			$$("chrname").focus();
			setmsg('checkshop','shopcomment_error_name');
			return false;
		}	
	}
	if($$("chrpwd")){
		trimspace($$("chrpwd"))
		if($$("chrpwd").value==""){
			$$("chrpwd").focus();
			setmsg('checkshop','shopcomment_error_pwd');
			return false;
		}	
	}
	if($$("code")){
		trimspace($$("code"))
		if($$("code").value==""){
			$$("code").focus();
			setmsg('checkshop','shopcomment_error_code');
			return false;
		}	
	}
	trimspace($$("chrmark"))
	if($$("chrmark").value==""){
		$$("chrmark").focus();
		setmsg('checkshop','shopcomment_error_chrmark');
		return false;
	}
	if($$("chrmark").value.length>300){
		$$("chrmark").select();
		setmsg('checkshop','shopcomment_error_chrmark1');
		return false;
	}
	var chrname="";
	if($$("chrname")){
		chrname=$$("chrname").value;
	}
	var chrpwd="";
	if($$("chrpwd")){
		chrpwd=$$("chrpwd").value;
	}	
	addshopcomment(chrname,chrpwd,$$("code").value,$$("chrmark").value,$$("shopid").value);
	return false;
}
function addshopcomment(chrname,chrpwd,code,chrmark,shopid)
{
      	var url="../request.aspx?action=addshopcomment&chrname="+escape(chrname);
		url =url+"&chrpwd="+escape(chrpwd)+"&code="+escape(code)+"&chrmark="+escape(chrmark)+"&shopid="+escape(shopid);
		var  Digital=new  Date();
		Digital=Digital+40000;
		url=url+"&k="+Digital;
		xmlHttp=GetXmlHttpObject(requestaddshopcomment)
		xmlHttp.open("POST", url , true)
		xmlHttp.send(null)
}
function requestaddshopcomment()
{
	if(xmlHttp.readyState==4)
	{
		if(xmlHttp.status==200)
		{
			if(xmlHttp.responseText==1)
			{
				alert("恭喜您，发布成功，请等待管理员审核！");	
				window.location.href=window.location.href;
			}
			else if(xmlHttp.responseText==2)
			{
				alert("恭喜您，发布成功！");	
				window.location.href=window.location.href;
			}
			else{
				alert(xmlHttp.responseText);
			}
		}
	}
}
function checkpinpaicomment(){
	if($$("chrname")){
		trimspace($$("chrname"))
		if($$("chrname").value==""){
			$$("chrname").focus();
			setmsg('checkshop','shopcomment_error_name');
			return false;
		}	
	}
	if($$("chrpwd")){
		trimspace($$("chrpwd"))
		if($$("chrpwd").value==""){
			$$("chrpwd").focus();
			setmsg('checkshop','shopcomment_error_pwd');
			return false;
		}	
	}
	if($$("code")){
		trimspace($$("code"))
		if($$("code").value==""){
			$$("code").focus();
			setmsg('checkshop','shopcomment_error_code');
			return false;
		}	
	}
	trimspace($$("chrmark"))
	if($$("chrmark").value==""){
		$$("chrmark").focus();
		setmsg('checkshop','shopcomment_error_chrmark');
		return false;
	}
	if($$("chrmark").value.length>300){
		$$("chrmark").select();
		setmsg('checkshop','shopcomment_error_chrmark1');
		return false;
	}
	var chrname="";
	if($$("chrname")){
		chrname=$$("chrname").value;
	}
	var chrpwd="";
	if($$("chrpwd")){
		chrpwd=$$("chrpwd").value;
	}	
	addpinpaicomment(chrname,chrpwd,$$("code").value,$$("chrmark").value,$$("pinpaiid").value,$$("score").value);
	return false;
}
function addpinpaicomment(chrname,chrpwd,code,chrmark,pinpaiid,score)
{
      	var url="../request.aspx?action=addpinpaicomment&chrname="+escape(chrname);
		url =url+"&chrpwd="+escape(chrpwd)+"&code="+escape(code)+"&chrmark="+escape(chrmark)+"&pinpaiid="+escape(pinpaiid)+"&score="+score;
		var  Digital=new  Date();
		Digital=Digital+40000;
		url=url+"&k="+Digital;
		xmlHttp=GetXmlHttpObject(requestaddshopcomment)
		xmlHttp.open("POST", url , true)
		xmlHttp.send(null)
}
function showxieyi(id){
	 if($$(id).style.display==''){
		 $$(id).style.display='none';}
	 else{$$(id).style.display='';}
}
function setshow(val){
	for(var mm=1;mm<5;mm++){
		if(mm==val){
			if(mm==1){
				$$("showpic").style.display="";	
			}	
			else{
				$$("showpic"+mm).style.display="";		
			}
		}
		else{
			if(mm==1){
				$$("showpic").style.display="none";	
			}	
			else{
				$$("showpic"+mm).style.display="none";		
			}
		}
	}	
}
var xmlHttp;
function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null
if (navigator.userAgent.indexOf("Opera")>=0)
{
alert("This example doesnt work in Opera") 
return; 
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
} 
try
{ 
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler 
return objXmlHttp
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled") 
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp
}
}
//用于处理注册用户
function checkregister(){
	if(!$$("checkxieyi").checked){
		alert("请先阅读接受会员注册协议!");
		$$("checkxieyi").focus();
		return false;
	}
	trimspace($$("chrname"));
	if($$("chrname").value==""){
		setmsg('check','user_length_error');
		return false;
	}
	checkpwd();
	trimspace($$("chrpwd"));
	if($$("chrpwd").value==""){
		setmsg('chkpwd','pwd_length_error');
		return false;
	}
	trimspace($$("chrpwd_1"));
	if($$("chrpwd_1").value==""){
		setmsg('rchkpwd','pwd_insert_align');
		return false;
	}
	if($$("chrpwd_1").value!=$$("chrpwd").value){
		setmsg('rchkpwd','pwd_same_error');
		return false;
	}
	trimspace($$("chremail"));
	if($$("chremail").value==""){
	   	setmsg('chkemail','email_nothing_error')
		return false;
	}
	if(!isRightEmail($$("chremail").value)){
	   	setmsg('chkemail','email_regist_error')
		return false;
	}
	trimspace($$("code"));
	if($$("code").value.length!=5){
	   	setmsg('chkcode','code_length_error')
		return false;
	}
	addregister($$("chrname").value,$$("chrpwd").value,$$("chrpwd_1").value,$$("chremail").value,$$("code").value);
	return false;
}
function addregister(chrname,chrpwd,chrpwd_1,chremail,code)
{
      	var url="../request.aspx?action=register&chrname="+escape(chrname);
		url =url+"&chrpwd="+escape(chrpwd)+"&chrpwd_1="+escape(chrpwd_1)+"&chremail="+escape(chremail)+"&code="+escape(code);
		var  Digital=new  Date();
		Digital=Digital+40000;
		url=url+"&k="+Digital;
		xmlHttp=GetXmlHttpObject(requestaddregister)
		xmlHttp.open("POST", url , true)
		xmlHttp.send(null)
}
function requestaddregister()
{
	if(xmlHttp.readyState==4)
	{
		if(xmlHttp.status==200)
		{
			if(xmlHttp.responseText!=1)
			{
				alert(xmlHttp.responseText);	
			}
			else{
				alert("恭喜您,注册成功并登陆成功!");	
				var sss=getCookie("registergoto");
				if(sss)
				{
					window.location.href=sss;
				}
				else{
					window.location.href="../";
				}
			}
		}
	}
}
/*****用于持卡补单****/
function checkaddbudan(){
	trimspace($$("companydid"));
	if($$("companydid").value==""){
		setmsg('checkshop','chrshop_length_error');
		return false;
	}
	trimspace($$("xiangmu"));
	if($$("xiangmu").value=="" || $$("xiangmu").value.length<1){
		setmsg('checkxiangmu','chrxiangmu_length_error');
		return false;
	}
	else if($$("xiangmu").value.length>30){
		setmsg('checkxiangmu','chrxiangmu_length1_error');
		return false;
	}
	trimspace($$("xiaofeidate"));
	/*if($$("xiaofeidate").value=="" || $$("xiaofeidate").value.length<1){
		setmsg('checkxiaofeidate','chrxiaofeidate_length');
		return false;
	}else{
		setmsg('checkxiaofeidate','ok');
	}*/
	trimspace($$("username"));
	if($$("username").value=="" || $$("username").value.length<1){
		setmsg('checkusername','chrusername_length_error');
		return false;
	}
	else if($$("username").value.length>10){
		setmsg('checkusername','chrusername_length1_error');
		return false;
	}
	trimspace($$("xiaofei"));
	if($$("xiaofei").value=="" || $$("xiaofei").value=="0"){
		setmsg('checkxiaofei','chrxiaofei_length_error');
		return false;
	}
	trimspace($$("chrmark"));
	if($$("chrmark").value.length>200){
		setmsg('checkchrmark','chrchrmark_length_error');
		return false;
	}
    addbudan($$("companydid").value,$$("xiangmu").value,$$("xiaofeidate").value,$$("username").value,$$("xiaofei").value,$$("chrtel").value,$$("fuwu").value,$$("price").value,$$("chrmark").value)
	return false;
}
function chkchrshop(){
	trimspace($$("chrshop"));
	if($$("chrshop").value==""){
		setmsg('checkshop','chrshop_length_error');
		return false;
	}
	else{
		checkshopexist($$("chrshop").value);
	}
}
function showcompany(){
	trimspace($$("companydid"));
	if($$("companydid").value==""){
		setmsg('checkshop','chrshop_length_error');
		return false;
	}
	else{
		setmsg('checkshop','ok');
	}
}
function chkxiangmu(){
	trimspace($$("xiangmu"));
	if($$("xiangmu").value=="" || $$("xiangmu").value.length<1){
		setmsg('checkxiangmu','chrxiangmu_length_error');
		return false;
	}
	else if($$("xiangmu").value.length>30){
		setmsg('checkxiangmu','chrxiangmu_length1_error');
		return false;
	}
	else{
		setmsg('checkxiangmu','ok');
	}
}
function chkusername(){
	trimspace($$("username"));
	if($$("username").value=="" || $$("username").value.length<1){
		setmsg('checkusername','chrusername_length_error');
		return false;
	}
	else if($$("username").value.length>10){
		setmsg('checkusername','chrusername_length1_error');
		return false;
	}
	else{
		setmsg('checkusername','ok');
	}
}
function chkxiaofei(){
	trimspace($$("xiaofei"));
	if($$("xiaofei").value=="" || $$("xiaofei").value=="0"){
		setmsg('checkxiaofei','chrxiaofei_length_error');
		return false;
	}
	else{
		setmsg('checkxiaofei','ok');
	}
}
function chkxiaofeidate(){
	trimspace($$("xiaofeidate"));
	/*if($$("xiaofeidate").value=="" ){
		setmsg('checkxiaofeidate','chrxiaofeidate_length');
		return false;
	}
	else{
		setmsg('checkxiaofeidate','ok');
	}*/
}
function chkchrmark(){
	trimspace($$("chrmark"));
	if($$("chrmark").value.length>200){
		setmsg('checkchrmark','chrchrmark_length_error');
		return false;
	}
	else{
		setmsg('checkchrmark','chrmark_error');
	}
}
function checkshopexist(chrname)
{
      	var url="../request.aspx?action=checkshop&chrname="+escape(chrname);
		var  Digital=new  Date();
		Digital=Digital+40000;
		url=url+"&k="+Digital;
		xmlHttp=GetXmlHttpObject(requestcheckshopexist)
		xmlHttp.open("POST", url , true)
		xmlHttp.send(null)
}
function requestcheckshopexist()
{
	if(xmlHttp.readyState==4)
	{
		if(xmlHttp.status==200)
		{
			if(xmlHttp.responseText!=1)
			{
				setmsg('checkshop','chrshop_add_error');
				return false;
			}
			else{
				setmsg('checkshop','ok');
			}
		}
	}
}
function addbudan(chrshop,xiangmu,xiaofeidate,username,xiaofei,chrtel,fuwu,price,chrmark)
{
      	var url="../request.aspx?action=addbudan&chrshop="+escape(chrshop);
		url =url+"&xiangmu="+escape(xiangmu)+"&xiaofeidate="+escape(xiaofeidate)+"&username="+escape(username)+"&xiaofei="+escape(xiaofei)+"&chrtel="+escape(chrtel);
		url =url+"&fuwu="+escape(fuwu)+"&price="+escape(price)+"&chrmark="+escape(chrmark);
		var  Digital=new  Date();
		Digital=Digital+40000;
		url=url+"&k="+Digital;
		xmlHttp=GetXmlHttpObject(requestaddbudan)
		xmlHttp.open("POST", url , true)
		xmlHttp.send(null)
}
function requestaddbudan()
{
	if(xmlHttp.readyState==4)
	{
		if(xmlHttp.status==200)
		{
			if(xmlHttp.responseText!=1)
			{
				alert(xmlHttp.responseText);	
			}
			else{
				alert("补单成功,请等待管理员审核!");
				window.location.href=window.location.href;	
			}
		}
	}
}
function showpinp()
{
	$$("showpinpai").style.display="block";
}
function showpinp1()
{
	$$("showpinpai").style.display="none";
}
function DialogLoc(){
	 var dde = document.documentElement;
	 if (window.innerWidth){
	 	var ww = window.innerWidth;
		var wh = window.innerHeight;
		var bgX = window.pageXOffset;
		var bgY = window.pageYOffset;	
	 }else{	 	
		var ww = dde.offsetWidth;
		var wh = dde.offsetHeight;
		var bgX = dde.scrollLeft;
		var bgY = dde.scrollTop;	  
	 }
	 t_DiglogX = (bgX + ((ww - t_DiglogW)/2));
	 t_DiglogY = (bgY + ((wh - t_DiglogH)/2));
}
