String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

function isEmail(val) 
{ 
 var email =/\w+@\w+\.[a-z]+/; 
//return email.test(val); 
 if (!email.test(val)) 
  { 
   return false; 
  } 
else 
  { 
    return true; 
  } 
}
function MemberPasswordCheck()
{
	if(document.MemberPasswordForm.Password1.value=="")
	{
		alert("请输入旧密码！");
		document.MemberPasswordForm.Password1.focus();
		return false;
	}
	if(document.MemberPasswordForm.Password2.value=="")
	{
		alert("请输入新密码！");
		document.MemberPasswordForm.Password2.focus();
		return false;
	}
	if(document.MemberPasswordForm.Password2.value.length<6)
	{
		alert("密码必须大于6位！");
		document.MemberPasswordForm.Password2.focus();
		return false;
	}
	if(document.MemberPasswordForm.Password2.value!=document.MemberPasswordForm.Password3.value)
	{
		alert("确认密码不正确！");
		document.MemberPasswordForm.Password3.focus();
		return false;
	}
}
function MemberInformationFormCheck()
{
	
	if(document.regForm.Contact.value=="")
	{
		alert("联系人不能为空!");
		document.regForm.Contact.focus();
		return false;
	}
	if(document.regForm.YPhone.value=="")
	{
		alert("手机号码不能为空!");
		document.regForm.YPhone.focus();
		return false;
	}
	if(document.regForm.Address.value=="")
	{
		alert("联系地址不能为空!");
		document.regForm.Address.focus();
		return false;
	}
	if(document.regForm.Email.value!="")
	{
		if(!isEmail(document.regForm.Email.value))
		{alert("邮箱地址格式不正确!");
		 document.regForm.Email.focus();
		 return false;
		}
	}
	return true;
}
function U5CardApplicationCheck()
{
	if(document.U5CardApplicationForm.Contact.value.trim()=="")
	{
		alert("请填写联系人");
		document.U5CardApplicationForm.Contact.focus();
		return false;
	}
	if(document.U5CardApplicationForm.IDCard.value.trim()=="")
	{
		alert("请填身份证");
		document.U5CardApplicationForm.IDCard.focus();
		return false;
	}
	if(document.U5CardApplicationForm.YPhone.value.trim()=="")
	{
		alert("请填写手机号码");
		document.U5CardApplicationForm.YPhone.focus();
		return false;
	}
	if(document.U5CardApplicationForm.Address.value.trim()=="")
	{
		alert("请填写联系地址");
		document.U5CardApplicationForm.Address.focus();
		return false;
	}
	if(document.U5CardApplicationForm.Email.value.trim()=="")
	{
		alert("请填写电子邮件");
		document.U5CardApplicationForm.Email.focus();
		return false;
	}
	if(!isEmail(document.U5CardApplicationForm.Email.value.trim()))
	{
		alert("电子邮件格式不对");
		document.U5CardApplicationForm.Email.focus();
		return false;
	}
}
function NameApplicationCheck()
{
	
	if(document.NameApplicationForm.YPhone.value.trim()=="")
	{
		alert("请填写手机号码");
		document.NameApplicationForm.YPhone.focus();
		return false;
	}
	
}
function ActingAddCheck()
{
	if(document.ActingAddForm.City.value.trim()=="")
	{
		alert("请填写城市");
		document.ActingAddForm.City.focus();
		return false;
	}
	if(document.ActingAddForm.Area.value.trim()=="")
	{
		alert("请填写区域");
		document.ActingAddForm.Area.focus();
		return false;
	}
	if(document.ActingAddForm.Contact.value.trim()=="")
	{
		alert("请填写联系人");
		document.ActingAddForm.Contact.focus();
		return false;
	}
	if(document.ActingAddForm.Address.value.trim()=="")
	{
		alert("请填写联系地址");
		document.ActingAddForm.Address.focus();
		return false;
	}
	if(document.ActingAddForm.PhoneLink.value.trim()=="")
	{
		alert("请填写联系电话");
		document.ActingAddForm.PhoneLink.focus();
		return false;
	}
	if(document.ActingAddForm.QQ.value.trim()=="")
	{
		alert("请填写QQ");
		document.ActingAddForm.QQ.focus();
		return false;
	}
	
}
function BusinessAddCheck()
{
	if(document.BusinessAddForm.City.value.trim()=="")
	{
		alert("请填写城市");
		document.BusinessAddForm.City.focus();
		return false;
	}
	if(document.BusinessAddForm.Area.value.trim()=="")
	{
		alert("请填写地区");
		document.BusinessAddForm.Area.focus();
		return false;
	}
	if(document.BusinessAddForm.BusinessName.value.trim()=="")
	{
		alert("请填写商家名称");
		document.BusinessAddForm.BusinessName.focus();
		return false;
	}
	if(document.BusinessAddForm.TypeId.value.trim()=="")
	{
		alert("请选择所属类别");
		document.BusinessAddForm.TypeId.focus();
		return false;
	}
	if(document.BusinessAddForm.ContactAddress.value.trim()=="")
	{
		alert("请填写联系地址");
		document.BusinessAddForm.ContactAddress.focus();
		return false;
	}
	if(document.BusinessAddForm.ShopAddress.value.trim()=="")
	{
		alert("请填写商铺地址");
		document.BusinessAddForm.ShopAddress.focus();
		return false;
	}
	if(document.BusinessAddForm.Contact.value.trim()=="")
	{
		alert("请填写联系人");
		document.BusinessAddForm.Contact.focus();
		return false;
	}
	if(document.BusinessAddForm.PhoneLink.value.trim()=="")
	{
		alert("请填写联系电话");
		document.BusinessAddForm.PhoneLink.focus();
		return false;
	}
	if(document.BusinessAddForm.OpeningHoursBegin.value.trim()=="")
	{
		alert("请选择营业时间");
		document.BusinessAddForm.OpeningHoursBegin.focus();
		return false;
	}
	if(document.BusinessAddForm.OpeningHoursEnd.value.trim()=="")
	{
		alert("请选择营业时间");
		document.BusinessAddForm.OpeningHoursEnd.focus();
		return false;
	}
	if(document.BusinessAddForm.ClosingHoursBegin.value.trim()=="")
	{
		alert("请选择营业时间");
		document.BusinessAddForm.ClosingHoursBegin.focus();
		return false;
	}
	if(document.BusinessAddForm.ClosingHoursEnd.value.trim()=="")
	{
		alert("请选择营业时间");
		document.BusinessAddForm.ClosingHoursEnd.focus();
		return false;
	}
	if(document.BusinessAddForm.PerConsumption.value.trim()=="")
	{
		alert("请填写人均消费");
		document.BusinessAddForm.PerConsumption.focus();
		return false;
	}
	if(document.BusinessAddForm.Content1.value.trim()=="")
	{
		alert("请填写折扣说明");
		document.BusinessAddForm.Content1.focus();
		return false;
	}
	
}
function BusinessRecommendedCheck()
{
	if(document.BusinessRecommededForm.BusinessName.value.trim()=="")
	{
		alert("商户名称不能为空!");
		document.BusinessRecommededForm.BusinessName.focus();
		return false;
	}
	if(document.BusinessRecommededForm.City.value.trim()=="")
	{
		alert("请把地址填全!");
		document.BusinessRecommededForm.City.focus();
		return false;
	}
	if(document.BusinessRecommededForm.Area.value.trim()=="")
	{
		alert("请把地址填全!");
		document.BusinessRecommededForm.Area.focus();
		return false;
	}
	if(document.BusinessRecommededForm.Address.value.trim()=="")
	{
		alert("请把地址填全!");
		document.BusinessRecommededForm.Address.focus();
		return false;
	}
}
function RegCheck()
{
	if(!document.regForm.RegRead.checked)
	{
		alert("已阅读并同意用户协议后才能注册");
		return false;
	}
	if(document.regForm.UserName.value=="")
	{
		alert("用户名不能为空!");
		document.regForm.UserName.focus();
		return false;
	}
	if((document.regForm.UserName.value).length>12)
	{
		alert("用户名不能超过12个字符!");
		document.regForm.UserName.focus();
		return false;
	}
	if((document.regForm.password.value).length<6 || (document.regForm.password.value).length>20)
	{
		alert("密码长度在6和20之间!");
		document.regForm.password.focus();
		return false;
	}
	if(document.regForm.password2.value!=document.regForm.password.value)
	{
		alert("确认密码不正确!");
		document.regForm.password2.focus();
		return false;
	}
	if((document.regForm.CardNum.value).trim()=="")
    {
        alert("卡号不能为空");
	    document.regForm.CardNum.focus();
	    return false;
    }
    if((document.regForm.CardNum.value).length!=12)
    {
        alert("卡号不正确");
	    document.regForm.CardNum.focus();
	    return false;
    }
	if(document.regForm.CardCode.value=="")
	{
		alert("卡验证码不能为空!");
		document.regForm.CardCode.focus();
		return false;
	}
	if((document.regForm.CardCode.value).length!=8)
	{
		alert("卡验证码不正确!");
		document.regForm.CardCode.focus();
		return false;
	}
	if(document.regForm.Contact.value=="")
	{
		alert("联系人不能为空!");
		document.regForm.Contact.focus();
		return false;
	}
	if(document.regForm.YPhone.value=="")
	{
		alert("手机号码不能为空!");
		document.regForm.YPhone.focus();
		return false;
	}
	if(document.regForm.Address.value=="")
	{
		alert("联系地址不能为空!");
		document.regForm.Address.focus();
		return false;
	}
	if(document.regForm.Email.value!="")
	{
		if(!isEmail(document.regForm.Email.value))
		{alert("邮箱地址格式不正确!");
		document.regForm.Email.focus();
		return false;
		}
	}
}
//全选
function SelectAll(obj)
    {
        var allInput = document.getElementsByTagName("input");
        //alert(allInput.length);
        var loopTime = allInput.length;
        for(i = 0;i < loopTime;i++)
        {
            //alert(allInput[i].type);
            if(allInput[i].type == "checkbox")
            {
                allInput[i].checked = obj.checked;
            }
        }
    }
	
	
	
	
function GetXmlHttpObject()
{
   var xmlHttp=null;
   if (window.XMLHttpRequest)
    {
     xmlHttp=new XMLHttpRequest();
    }
   else if (window.ActiveXObject)
    {
     xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
   return xmlHttp;
}



function TopClear()
{
	if(document.SearchForm.AreaName.value=="全市")
	{document.SearchForm.AreaName.value="";}	
}
function TopColor()
{
	document.SearchForm.AreaName.style.color="#000000";
}
function Type_Over(str)
{
	document.getElementById("Can").style.display="none";
	document.getElementById("Bin").style.display="none";
	document.getElementById("Xiu").style.display="none";
	document.getElementById("Gou").style.display="none";
	document.getElementById("Mei").style.display="none";
	document.getElementById("Xiao").style.display="none";
	switch(str)
	{
		case 1:
		document.getElementById("Can").style.display="";break;
		case 2:
		document.getElementById("Bin").style.display="";break;
		case 3:
		document.getElementById("Xiu").style.display="";break;
		case 4:
		document.getElementById("Gou").style.display="";break;
		case 5:
		document.getElementById("Mei").style.display="";break;
		case 6:
		document.getElementById("Xiao").style.display="";break;
	}
}

function Comments(page)
{
   
   xmlHttp=GetXmlHttpObject()
   theDate=new Date().getTime();
   var url="class/Comments.asp";
   url=url+"?page="+page+"&thedate="+theDate;
   //window.location.href=url;
   xmlHttp.onreadystatechange=function thechange() 
  { 
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
       document.getElementById("Comments").innerHTML=xmlHttp.responseText;
	     
   } 
  } 
   xmlHttp.open("GET",url,true)
   xmlHttp.send(null)
}


//选择类别的处理
function TypeChange(id)
{
   
   xmlHttp=GetXmlHttpObject()
   theDate=new Date().getTime();
   var url="class/ShopType.asp";
   url=url+"?id="+id+"&thedate="+theDate;
   //window.location.href=url;
   xmlHttp.onreadystatechange=function thechange() 
  { 
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
       document.getElementById("SmallType").innerHTML=xmlHttp.responseText;
	     
   } 
  } 
   xmlHttp.open("GET",url,true)
   xmlHttp.send(null)
}
function OneDeal(id,biao,ziduan,thevalue)
{
   xmlHttp=GetXmlHttpObject();
   var url="../function/OneDeal.asp";
   url=url+"?id="+id+"&biao="+biao+"&ziduan="+ziduan+"&value="+thevalue;
   //window.location.href=url;
   xmlHttp.onreadystatechange=function thechange() 
  { 
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
       alert('修改成功');
   } 
  } 
   xmlHttp.open("GET",url,true)
   xmlHttp.send(null)
}

//选择省的处理
function AreaChange(biao,id)
{

   xmlHttp=GetXmlHttpObject()
   theDate=new Date().getTime();
   var url="Class/AreaChange.asp";
   url=url+"?id="+id+"&biao="+biao+"&thedate="+theDate;
   //window.location.href=url;
   xmlHttp.onreadystatechange=function thechange() 
  { 
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
       document.getElementById(biao).innerHTML=xmlHttp.responseText;
       if(biao=="U5_City")
	   {
		   document.getElementById("U5_Area").innerHTML="";
	   }   
   } 
  } 
   xmlHttp.open("GET",url,true)
   xmlHttp.send(null)
}


function ReleasedCheck()
{
	if(document.theform.Services.value=="")
	{
		alert("请选择服务!");
		document.theform.Services.focus();
		return false;
	}
	if(document.theform.Environment.value=="")
	{
		alert("请选择环境!");
		document.theform.Environment.focus();
		return false;
	}
	if(document.theform.Cost_effective.value=="")
	{
		alert("请选择性价比!");
		document.theform.Cost_effective.focus();
		return false;
	}
	if((document.theform.Content.value.trim()).length<30 || (document.theform.Content.value.trim()).length>2000)
	{
		alert("评论内容必须在规定范围内!");
		document.theform.Content.focus();
		return false;
	}
	if(document.theform.YanZhengMa.value!=document.theform.YanZhengMa1.value)
	{
		alert("验证码不正确!");
		document.theform.YanZhengMa.focus();
		return false;
	}
}


//城市切换处理
function excelDownload(biao,sql)
{
	xmlHttp=GetXmlHttpObject()
   var url="class/function.asp"
   url=url+"?biao="+biao+"&sql="+sql
   //window.location.href=url;
   xmlHttp.onreadystatechange=function thechange() 
  { 
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
       document.getElementById("mesWindowContent").innerHTML=xmlHttp.responseText;
   } 
  } 
   xmlHttp.open("GET",url,true)
   xmlHttp.send(null)
}
//登陆验证
function LoginCheck(){
	if(document.loginForm.UserName.value=="")
	{
		alert('用户名不能为空!');
		document.loginForm.UserName.focus();
		return false;
	}
	if(document.loginForm.Password.value=="")
	{
		alert('密码不能为空!');
		document.loginForm.Password.focus();
		return false;
	}
}
//QQ代码;   
function CheckInstallQQ2(uin,item){
	sitename="由我网";
	if(!item) Link="tencent://message/?uin="+uin+"&fromuserid=no&touserid=no&unionid=由我网&WebSiteName=由我网";
	else Link="tencent://message/?uin="+uin+"&fromuserid="+item+"&touserid="+item+"&unionid=由我网&WebSiteName=由我网";
	try{//支持
		var xmlhttp=new ActiveXObject("TimwpDll.TimwpCheck");
		this.location.href=Link;
		var  n = xmlhttp.GetVersion();
		if (n >= 2.1)
			this.location.href=Link;
		else
		{
			alert("由我网温馨提示：\r\n　　请您访问http://im.qq.com/下载新版的QQ/TM以支持与由我网在线交流！");
			window.target="_top";
			window.open("http://im.qq.com/");
		}
	}catch(e){//不支持
		alert("由我网温馨提示：\r\n　　请您访问http://im.qq.com/下载新版的QQ/TM以支持与由我网在线交流！");
		window.target="_top";
		window.open("http://im.qq.com/");
	}
	return false;	
}
function CheckType1(value,functionid,divid)
{
   xmlHttp=GetXmlHttpObject();
   str="";
   theDate=new Date().getTime();
   //rndnum=Math.round(Math.random()*100000);
   var url="../function/function.asp";
   url=url+"?value="+escape(value)+"&functionid="+escape(functionid)+"&timestemp="+theDate ;
   //alert(url);
  // window.location.href=url;
   xmlHttp.onreadystatechange=function thechange() 
  { 
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
       document.getElementById(divid).innerHTML=xmlHttp.responseText;
	   if(xmlHttp.responseText.indexOf("<img src='../image/Ok.gif'>")==-1)
	   str="0"
	   else
	   str="1"
   } 
  } 
 
   xmlHttp.open("GET",url,false);
   xmlHttp.send(null);
   if(str=="1")
   return true;
   else
   return false;
}

function CheckType2(value,value2,functionid,divid)
{
   xmlHttp=GetXmlHttpObject();
   str="";
   //rndnum=Math.round(Math.random()*100000);
   theDate=new Date().getTime();
   var url="../function/function.asp";
   //下面一个随机参数为了让AJAX与数据库同步更新
   url=url+"?value="+escape(value)+"&value2="+escape(value2)+"&functionid="+escape(functionid)+"&timestemp="+theDate ;
   //window.location.href=url;
   xmlHttp.onreadystatechange=function thechange() 
  { 
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
       document.getElementById(divid).innerHTML=xmlHttp.responseText;
	   if(xmlHttp.responseText.indexOf("<img src='../image/Ok.gif'>")==-1)
	   str="0"
	   else
	   str="1"
   } 
  } 
   xmlHttp.open("GET",url,false);
   xmlHttp.send(null);
   if(str=="1")
   return true;
   else
   return false;
}

function CheckType3(value,value2,value3,functionid,divid)
{
   xmlHttp=GetXmlHttpObject();
   str="";
   //rndnum=Math.round(Math.random()*100000);
   theDate=new Date().getTime();
   var url="../function/function.asp";
   //下面一个随机参数为了让AJAX与数据库同步更新
   url=url+"?value="+escape(value)+"&value2="+escape(value2)+"&value3="+value3+"&functionid="+escape(functionid)+"&timestemp="+theDate ;
   //window.location.href=url;
   xmlHttp.onreadystatechange=function thechange() 
  { 
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
       document.getElementById(divid).innerHTML=xmlHttp.responseText;
	   if(xmlHttp.responseText.indexOf("<img src='../image/Ok.gif'>")==-1)
	   str="0"
	   else
	   str="1"
   } 
  } 
   xmlHttp.open("GET",url,false);
   xmlHttp.send(null);
   if(str=="1")
   return true;
   else
   return false;
}

function CheckType4(value,value1,value2,value3,functionid,divid)
{
   xmlHttp=GetXmlHttpObject();
   str="";
   //rndnum=Math.round(Math.random()*100000);
   theDate=new Date().getTime();
   var url="../function/function.asp";
   //下面一个随机参数为了让AJAX与数据库同步更新
   url=url+"?value="+escape(value)+"&value1="+escape(value1)+"&value2="+escape(value2)+"&value3="+value3+"&functionid="+escape(functionid)+"&timestemp="+theDate ;
  // window.location.href=url;
   xmlHttp.onreadystatechange=function thechange() 
  { 
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
       document.getElementById(divid).innerHTML=xmlHttp.responseText;
	   if(xmlHttp.responseText.indexOf("<img src='../image/Ok.gif'>")==-1)
	   str="0"
	   else
	   str="1"
   } 
  } 
   xmlHttp.open("GET",url,false);
   xmlHttp.send(null);
   if(str=="1")
   return true;
   else
   return false;
}



var mesW=document.createElement("div");
mesW.style.cssText="background-color:#FFFFFF; position:absolute; z-index:100;border:5px solid #f4f4f4;"
function ShopPicShow(event,PicAddress,Name,Discounts){
  
  mesW.style.display="";
  event = event || window.event;
  if(event.clientY-document.documentElement.scrollTop+10+mesW.offsetHeight>(window.screen.availHeight-2*window.screenTop))
  mesW.style.top  = event.clientY+document.documentElement.scrollTop+10-mesW.offsetHeight+"px";
  else
  mesW.style.top  = event.clientY+document.documentElement.scrollTop+10+"px";
  
  if(event.clientX+10+ mesW.offsetWidth>document.body.offsetWidth)
  mesW.style.left = event.clientX-10-mesW.offsetWidth+"px";
  else
  mesW.style.left = event.clientX+10+"px";
  document.body.insertBefore(mesW,document.body.firstChild);
  
  if(Name=="1" && Discounts=="1")
  mesW.innerHTML = '<img src="'+ PicAddress+'"/><div>';
  else
  mesW.innerHTML = '<img src="'+ PicAddress+'" width=239 height=215/><div>';


  //alert(window.screen.height);alert(window.screen.availHeight);
  

 }
 function ShopPicClose()
 {
	 mesW.style.display="none";
 }
 
 
 //************************************************弹出窗口效果开始*****************************************
var isIe=(document.all)?true:false;
//设置select的可见状态

function setSelectState(state)
{
var objl=document.getElementsByTagName('select');
for(var i=0;i<objl.length;i++)
{
objl[i].style.visibility=state;
}
}
function mousePosition(ev)
{
if(ev.pageX || ev.pageY)
{
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
}

//弹出方法
function showMessageBox(pos,wWidth)
{
closeWindow();
var bWidth=parseInt(document.documentElement.scrollWidth);
var bHeight=parseInt(document.documentElement.scrollHeight);
if(isIe){
setSelectState('hidden');}

//新建一个DIV
var back=document.createElement("div");
back.id="back";
var styleStr="top:0px;left:0px;position:absolute;background:#666;width:"+bWidth+"px;height:"+bHeight+"px;";
styleStr+=(isIe)?"filter:alpha(opacity=40);":"opacity:0.40;";
back.style.cssText=styleStr;
document.body.appendChild(back);

//新建一个DIV
var mesW=document.createElement("div");
mesW.id="mesWindow";
mesW.className="mesWindow";
mesW.innerHTML="<div id='mesWindowContent' style=' background-color:#FFFFFF; border:#669999 2px solid; padding:50px;'>"+document.getElementById('Discounts').innerHTML+"<br><input type='button' style='border:1px solid #333333;background-color:#CFDCEF;cursor:hand;' value='关闭窗口' onclick='closeWindow();'></div>";
styleStr="left:"+(((pos.x-wWidth)>0)?(pos.x-wWidth):pos.x)+"px;top:"+(pos.y)+"px;position:absolute;width:"+wWidth+"px;";
mesW.style.cssText=styleStr;
document.body.appendChild(mesW);
}


/*function showBackground(obj,endInt)
{
obj.filters.alpha.opacity+=1;
if(obj.filters.alpha.opacity<endInt)
{
setTimeout(function(){showBackground(obj,endInt)},8);
}
}*/
//关闭窗口
function closeWindow()
{
if(document.getElementById('back')!=null)
{
document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
}
if(document.getElementById('mesWindow')!=null)
{
document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
}
if(isIe){
setSelectState('');}
}
//测试弹出
function testMessageBox(ev)
{
var objPos = mousePosition(ev);
showMessageBox(objPos,350);
}

//********************************************弹出窗口效果结束*******************************************