// 修正JS对字符串长度的计算
function checkLength(strTemp){  
	var i,sum;
	sum=0;
	for(i=0;i<strTemp.length;i++){
		if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255))
			sum=sum+1;
		else
			sum=sum+2;
	}
	return sum;
}
// 检查搜索框
function checkSearch(theForm){
	if(checkLength(theForm.keyword.value)<2){
		  alert("关键字不能少于2个字节！");
		  theForm.keyword.focus();
		  return (false);
		}		
}
//兼容ie,firefox
//设为首页SetHome(this,window.location)
function SetHome(obj,vrl){
try{
		obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
		NavClickStat(1);
}
catch(e){
		if(window.netscape) {
				try {
						netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
				}  
				catch (e) 
						{
						alert("抱歉！您的浏览器不支持直接设为首页。请在浏览器地址栏输入'about:config'并回车然后将[signed.applets.codebase_principal_support]设置为'true'，点击'加入收藏'后忽略安全提示，即可设置成功。");  
						}
				var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
				prefs.setCharPref('browser.startup.homepage',vrl);
		 		}
		}
}
//加入收藏AddFavorite(window.location,document.title)
function AddFavorite(sURL,sTitle)
{
 if (document.all)
    {
       window.external.addFavorite(sURL,sTitle);
    }
    else if (window.sidebar)
    {
       window.sidebar.addPanel(sTitle,sURL, "");
 }
}
function showTab_wenda(tabadid_num,tabadnum){
	for(var i=0;i<4;i++){document.getElementById("tabWendaCon_"+tabadid_num+i).style.display="none";}
	for(var i=0;i<4;i++){document.getElementById("tabWenda_"+tabadid_num+i).className="";}
	document.getElementById("tabWenda_"+tabadid_num+tabadnum).className="tabWendaOn";
	document.getElementById("tabWendaCon_"+tabadid_num+tabadnum).style.display="block";
}
//参数：listshu---------tabMenu的数量
function showTab_List(tabadid_num,tabadnum,listshu){
	for(var i=0;i<listshu;i++){document.getElementById("tabListCon_"+tabadid_num+i).style.display="none";}
	for(var i=0;i<listshu;i++){document.getElementById("tabList_"+tabadid_num+i).className="tabListLi";}
	document.getElementById("tabList_"+tabadid_num+tabadnum).className="tabListLi tabListOn";
	document.getElementById("tabListCon_"+tabadid_num+tabadnum).style.display="block";
}
function showTab_machine(tabadid_num,tabadnum){
	for(var i=0;i<2;i++){document.getElementById("tabMachineCon_"+tabadid_num+i).style.display="none";}
	for(var i=0;i<2;i++){document.getElementById("tabMachine_"+tabadid_num+i).className="";}
	document.getElementById("tabMachine_"+tabadid_num+tabadnum).className="tabMachineOn";
	document.getElementById("tabMachineCon_"+tabadid_num+tabadnum).style.display="block";
}
//显示点击次数
function addhits(ID)
{
	 $.post('/plus/count.php?view=yes','aid='+ID,function(data){
		$('#hits').html(data);
	 })
}
//关闭底部在线预约号
function closefixyy(){
$(".fixyuyue").hide();
}
//获得预约号
function yuyuehao(){
	var mydate = new Date();
	var myyear = mydate.getFullYear();
	var mymonth = mydate.getMonth() + 1;
	var myday = mydate.getDate();
	myyuyehao='您的预约号：'+String(myyear)+String(mymonth)+String(myday);
	return myyuyehao;
}
//关闭两侧咨询商务通
function swtClosed(this_class){        
         $(this_class).fadeOut();
         return false;
}
//中间漂浮的商务通
$(function(){
	 $("#LRfloater1").live("mouseenter",function(){          
            $(this).append("<em>关闭</em><p><span>免费电话</span><span>在线咨询</span></p>");
            $(this).children("em").click(function(){
             LR_HideInvite();LR_RefuseChat();$("#float_window").fadeIn();return false;
            })
            $(this).find("span").click(function(){
              LR_HideInvite();openZoosUrl();return false;
            })

        })
         $("#LRfloater1").live("mouseleave",function(){           
            $(this).empty();
        })
})
//检查是否是合法的电话号码
function IsidNumber(argValue){
	var flag1=false;
	var compStr="1234567890-";
	var length2=argValue.length;
	for (var iIndex=0;iIndex<length2;iIndex++)
		{
			var temp1=compStr.indexOf(argValue.charAt(iIndex));
			if(temp1==-1) 
				{
					flag1=false;
					break;							
				}
			else
				{
					flag1=true;
				}
		}
	return flag1;
}

//检查左上角预约信息
function checkYuyue(theForm){
	if(theForm.yyName.value == ""){
	  alert("请填写您的姓名！");
	  theForm.yyName.focus();
	  return (false);
	}
	if(theForm.yyAge.value == ""){
		alert("请填写您的年龄！");	
		theForm.yyAge.focus();
		return (false);
	}
	if(!IsidNumber(theForm.yyAge.value)){
	  alert("年龄只能输入数字，请您检查！");
	  theForm.yyAge.focus();
	  return (false);
  }	
	if(theForm.yyDate.value == ""){
		alert("请填写您的预约时间！");	
		theForm.yyDate.focus();
		return (false);
	}
	if(theForm.yyItem.value == ""){
		alert("请选择您的预约项目！");	
		theForm.yyItem.focus();
		return (false);
	}
	if(theForm.yyTel.value == ""){
		alert("请填写您的联系方式");	
		theForm.yyTel.focus();
		return (false);
	}
	if(!IsidNumber(theForm.yyTel.value)){
	  alert("电话号码只能输入数字，请您检查！");
	  theForm.yyTel.focus();
	  return (false);
  }
	if(theForm.yyTel.value.length!=11 && theForm.yyTel.value.length!=12 && theForm.yyTel.value.length!=7){
	alert("您的电话号码长度有误，请您检查！");
	theForm.yyTel.focus();
	return (false);
 }
  
	
}

//检查首页中间的预约信息
function checkYuyue2(theForm){
	if(theForm.yyName2.value == ""){
	  alert("请填写您的姓名！");
	  theForm.yyName2.focus();
	  return (false);
	}
	if(theForm.yyAge2.value == ""){
		alert("请填写您的年龄！");	
		theForm.yyAge2.focus();
		return (false);
	}
	if(!IsidNumber(theForm.yyAge.value)){
	  alert("年龄只能输入数字，请您检查！");
	  theForm.yyAge.focus();
	  return (false);
  }		
	if(theForm.yyDate2.value == ""){
		alert("请填写您的预约时间！");	
		theForm.yyDate2.focus();
		return (false);
	}
	if(theForm.yyItem2.value == ""){
		alert("请选择您的预约项目！");	
		theForm.yyItem2.focus();
		return (false);
	}
	if(theForm.yyTel2.value == ""){
		alert("请填写您的联系方式");	
		theForm.yyTel2.focus();
		return (false);
	}
	if(!IsidNumber(theForm.yyTel2.value)){
	  alert("电话号码只能输入数字，请您检查！");
	  theForm.yyTel2.focus();
	  return (false);
  }
	if(theForm.yyTel2.value.length!=11 && theForm.yyTel2.value.length!=12 && theForm.yyTel2.value.length!=7){
	alert("您的电话号码长度有误，请您检查！");
	theForm.yyTel.focus();
	return (false);
 }	
}
