﻿// JScript 文件
//check isnull
function IsText(txt,minlen,msg,lblid)
    {
      if($C(txt).value.length>=minlen)
       {
         return true;
       }
       else
       {
         $C(lblid).innerHTML="请输入"+msg+"!";
         return false;
       }        
    }  
 //check mobile  
function IsMobile(mobile,IsAlert)
    {
      
        var reg=/^1(3|5)\d{9}$/;
	    if(!reg.test(mobile))
	    {  
	       if(IsAlert)
	      {
	       alert("手机格式错误.");	
	      }  
	      return false;
	    }
	    else
	    {	      
	      return true;
	    }
    }
function IsEmail(email,IsAlert)
    {
        var reg=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
     
	    if(!reg.test(email))
	    {  
	       if(IsAlert)
	      {
	       alert("Email格式错误.");	
	      }  
	      return false;
	    }
	    else
	    {	      
	      return true;
	    }
	    
    }
    //打印
function popprint(title,div)
{
var printPop=window.open("","Print","resizable=yes,scrollbars=no,toolbar=no,menubar=yes");
document.onload = printPop; 
printPop.focus(); 
printPop.document.open(); 
printPop.document.write("<html>\n<head>\n<title>"+title+"</title>\n<META http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n");
printPop.document.write("<link href=\"CSS/main.css\" rel=\"stylesheet\" type=\"text/css\" />");
printPop.document.write("<style>@media print{input,.button{display:none}} .printbutton,#lblDesc,.font4{display:none;} P,td{font-size:11px;}</style>");
printPop.document.write("</head>\n");
printPop.document.write("<body rightmargin=\"0\" bottommargin=\"0\" leftmargin=\"0\" topmargin=\"0\">\n");
printPop.document.write("<div >");
printPop.document.write(div);
printPop.document.write("<br/><center><input type=button class=\"print\" value=Print onclick=\"window.print();\"></center>");
printPop.document.write("</div>");
printPop.document.write("</body>\n</html>");
printPop.document.close();
}
//view images
function ViewImg(imgurl,title){ 
imgurl=imgurlChange(imgurl);
var left=(window.screen.width-width)/2;
 var top=(window.screen.height-height)/2; 
newwin=window.open('',"img","left="+left+",top="+top+",width=100,height=100,toolbar=no,menubar=no,scrollbars=no,resizable=yes,location=no"); 
newwin.document.clear();
newwin.document.open(); 
newwin.document.write("<html><head><title>"+title+"</title></head>");
newwin.document.write('<body leftmargin=0 topmargin=0><img onclick="window.close();" title="关闭" style="cursor:pointer" src='+imgurl+' onload="self.resizeTo(this.offsetWidth+12,this.offsetHeight+50);"></body></html>'); 
newwin.document.close();
newwin.focus();
} 
function ViewImgInit(imgclass)
{
    var imgs=document.getElementsByTagName("IMG");
    for(var i=0;i<imgs.length;i++)
    {
      if(imgs[i].className==imgclass)
      {
         imgs[i].title=imgs[i].alt;
         imgs[i].onclick=function(){ViewImg(this.src,this.title);};
      }
    }
}
function imgurlChange(url)
{
  return url.replace("wwf.",'.')
}
function setHomepage(){var url="http://www.hubs1.net/";if (document.all){document.body.style.behavior="url(#default#homepage)";document.body.setHomePage(url);}else if (window.sidebar){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",url);}}
function addFavor(){if(document.all)window.external.AddFavorite("http://www.hubs1.net","HUBS1汇通天下--中国2010年上海世博会指定订房业务承办方");else if (window.sidebar)window.sidebar.addPanel("HUBS1汇通天下--中国2010年上海世博会指定订房业务承办方", "http://www.hubs1.net", "")}
//find contrl
function $C(id){ return document.getElementById(id);}
function $V(id){ return $C(id).value;}
function $H(id){ return $C(id).innerHTML;}
function $Hide(id){$C(id).style.display="none";};
function $Display(id){$C(id).style.display="";}
function ChangeInt(txt){return parseInt(parseFloat("0"+txt.value));}
function ChangeFloat(txt){return parseFloat("0"+txt.value);}
function EnterKey(e,script){var key = window.event ? e.keyCode : e.which;if(key.toString() == "13"){eval(script);}}
function textfocus(id){ $C(id).focus();$C(id).select();}
function WriteCookie(tag,value){var d = new Date();d.setFullYear(d.getFullYear() +1);var CookieInfo = tag + "=" + escape(value) + ";expires="+d.toGMTString()+" path=/;";document.cookie = CookieInfo;}
function ReadCookie(tag){var mycookie=document.cookie;var start = mycookie.indexOf(tag + "=");if (start== -1){return null;}else{start=mycookie.indexOf("=",start)+1;var end = mycookie.indexOf(";",start);if (end==-1){end=mycookie.length;}return unescape(mycookie.substring(start,end));}}
function StringCheck(id,min,max){var txt= $C(id);var flag=true;var str =txt.value;if (str == ""){flag=false;}if (str.length < min ||str.length > max){flag=false;}var temp="";for (index=0; index<str.length; index++){check = str.charAt(index);if (!((("0"<=check) && (check<="9"))||(check=="_")||(("a"<=check) && (check<="z"))||(("A"<=check) && (check<="Z")))){flag=false;}else{temp=temp+check;}}if(!flag){txt.value=temp;}return flag;}
function pageopen(url){var win=window.open(url,"book","resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes");win.focus();}
function Redirect(url){ location.href=url; }
function LoadCSS(file,cssid){var cssTag = document.getElementById(cssid);var head = document.getElementsByTagName("head").item(0);if(cssTag){ head.removeChild(cssTag);}css = document.createElement("link");css.href = file;css.rel ="stylesheet";css.type= "text/css";css.id = cssid;head.appendChild(css)}
function LoadJavaScript(file,scrid){var scriptTag = document.getElementById(scrid);var head = document.getElementsByTagName('head').item(0);if(scriptTag) head.removeChild(scriptTag);script = document.createElement('script'); script.src = file;script.type = 'text/javascript';script.id = scrid;head.appendChild(script)}   
function popwindow(title,html,width,height,fun){bgdiv();popdiv(title,html,width,height,fun);}
function bgdiv(){var div = document.getElementById("divbg");var body = document.body;if(div) body.removeChild(div);div = document.createElement('div');div.id = "divbg";div.style.width=body.clientWidth+"px";div.style.height=body.clientHeight+"px";div.innerHTML="<iframe frameborder=0  style=\"position:absolute; visibility:inherit; top:0px;border:none; left:0px; width:"+body.clientWidth+"px; height:"+body.offsetHeight+"px; z-index:-1; filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';\"></iframe>"; body.appendChild(div);}
function popdiv(title,fromhtml,width,height,fun){var div = document.getElementById("divPop");var body = document.body;if(div) body.removeChild(div);div = document.createElement('div');div.id = "divPop";div.style.height=height;div.style.width=width;div.innerHTML="<div class='top'><div class='close' title='close' onclick='closepop(event);'></div><div id='poptitle'>"+title+"</div></div><div class='clear'/><div id=\"divWindow\">"+fromhtml+"</div>";var bwidth=body.clientWidth;var bheight=body.offsetHeight;var left=0;var top=0;if(bwidth>width){left=(bwidth-width)/2+"px";}if(bheight>height){top=(bheight-height)/2+"px";}div.style.top=top;div.style.left=left;body.appendChild(div);if(fun.lengh>0){eval(fun);}}
function closepop(e){if(e)e.cancelBubble=true;var div = document.getElementById("divPop");var body = document.body;if(div) body.removeChild(div);div=document.getElementById("divTip");if(div) body.removeChild(div);div=document.getElementById("divbg");if(div) body.removeChild(div);}
function popCommonWindow(url,width,height){ var left=(window.screen.width-width)/2; var top=(window.screen.height-height)/2; var params='left='+left+',top='+top+'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width='+width+',height='+height; var win=window.open(url, 'pop', params);win.focus();}
function popCustomerWindow(url,width,height,popname){ var left=(window.screen.width-width)/2; var top=(window.screen.height-height)/2; var params='left='+left+',top='+top+'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width='+width+',height='+height; var win=window.open(url, popname, params);win.focus();}
function pagination(page,total,pagesize,chagefunction){var pagestr="";if(page<1){page=1;}var allpage=1;allpage=parseInt(total/pagesize);allpage=parseInt((total%pagesize)!=0?allpage+1:allpage);allpage=parseInt(allpage==0?1:allpage);var next=page+1;if(next>allpage){next=allpage;}var pre=page-1;if(pre<1){pre=1;}var startcount=(page+5)>allpage?allpage-9:page-4;var endcount=page<5?10:page+5;pagestr+="<div class=\"pagenum\">";pagestr+="<span class=\"left\">第"+page+"页，总"+allpage+"页，点击页码查看下一页</strong></span>";pagestr+="<div align=\"right\">";if(startcount<1){startcount=1;}if(allpage<endcount){endcount=allpage;}pagestr+=page>1?"<a href=\"javascript:void(0);\"  onclick=\""+chagefunction+"(1)\" ><img src=\"images/page/nav_first.gif\" width=\"15\" height=\"10\" hspace=\"5\" border=\"0\"></a><a href=\"javascript:void(0);\"  onclick=\""+chagefunction+"("+pre+")\" ><img src=\"images/page/nav_left.gif\" hspace=\"5\" border=\"0\"></a>":"<img src=\"images/page/nav_first1.gif\" width=\"15\" height=\"10\" hspace=\"5\"><img src=\"images/page/nav_left1.gif\" hspace=\"5\">";for(var i=startcount;i<=endcount;i++){pagestr+=page==i?"&nbsp;&nbsp;<font color=\"#ff0000\">"+i+"</font>":"&nbsp;&nbsp;<a href=\"javascript:void(0);\"  onclick=\"ChangePage("+i+")\" >"+i+"</a>";}pagestr+=page!=allpage?"&nbsp;<a href=\"javascript:void(0);\"  onclick=\""+chagefunction+"("+next+")\" ><img src=\"images/page/nav_right.gif\" hspace=\"5\" border=\"0\"></a><a href=\"javascript:void(0);\"  onclick=\""+chagefunction+"("+allpage+")\" ><img src=\"images/page/nav_last.gif\" width=\"15\" height=\"10\" hspace=\"5\" border=\"0\"></a>":"<img src=\"images/page/nav_right1.gif\" hspace=\"5\"><img src=\"images/page/nav_last1.gif\" width=\"15\" height=\"10\" hspace=\"5\" border=\"0\">";pagestr+="</div>";pagestr+="</div>";return pagestr;}
function SelectSetValue(drp,htxt,hval){for(var i=0;i<drp.options.length;i++){if(drp.options[i].selected){htxt.value = drp.options[i].text;hval.value = drp.options[i].value;break;}}}
function setTab(name,cursel,n,fun){for(i=1;i<=n;i++){var menu=document.getElementById(name+i);var con=document.getElementById("con_"+name+"_"+i);menu.className=i==cursel?"hover":"";con.style.display=i==cursel?"":"none";}if(fun){fun();}fSetOutLinkIframe();}function GetMaxString(msg,max){if(msg.length <= max){return msg;}else{return msg.substring(0, max- 1) + "...";}}
function GetMaxString(msg,max){if(msg.length <= max){return msg;}else{return msg.substring(0, max- 1) + "...";}}
function fSetOutLinkIframe(){}
function getStar(star,diamond)
{
   var temp="";
   var sbStar =parseInt(star);
   var sbdiamond=parseInt(diamond);
   if(sbStar>0)
   {
   temp="star star"+sbStar;
   }
   else if(sbdiamond>0)
   {
      temp="star diamond"+sbdiamond;
   }
   else
   {
      temp="star star0";
   }
   return temp;
}
function GetHotelDeal(id)
{
HCRS.Web.Net.AjaxClass.GetHotelPromotion(id,GetHotelPromotionEnd);
}
function GetHotelPromotionEnd(req)
{
var Deal={};
eval("Deal="+req.value)
var html="";
    
var title="<div><span>"+Deal.hotelname+"</span></div>";//<span class=\""+  getStar(Deal.stars,Deal.diamond) +"\"></span>
html+="<form action=\"hotel.aspx\" method=\"get\" onsubmit=\"return CheckPop();\"><div class=\"auto\">";
html+=""+Deal.content +"</div>";
html+="<hr><center><table  border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> ";
html+="<tr><td>入住日期<label><input type=\"text\" name=\"ChkIN\" onfocus=\"this.blur()\" id=\"txtdStart\" size=\"10\"   /></label> ";
html+="<a onclick=\"event.cancelBubble=true;\" href=\"javascript:ShowDate('ddimg1','ddimg2','txtdStart','txtdEnd',true);\"> ";
html+="<img id=\"ddimg1\" height=\"21\" alt=\"入住日期\" src=\"images/calendar/calendar.gif\" width=\"25\" align=\"absmiddle\"  border=\"0\" /></a> ";
html+="</td> ";
html+="<td>离店日期";
html+="<label><input type=\"text\" onfocus=\"this.blur()\" name=\"ChkOUT\" id=\"txtdEnd\" size=\"10\" value=\"\" /></label> ";
html+="<a onclick=\"event.cancelBubble=true;\" href=\"javascript:ShowDate('ddimg1','ddimg2','txtdStart','txtdEnd',false)\"> ";
html+="<img id=\"ddimg2\" height=\"21\" alt=\"离店日期\" src=\"images/calendar/calendar.gif\" width=\"25\" align=\"absmiddle\"   border=\"0\" /></a> ";
html+="</td>";
html+="<td ><input type=hidden name=\"hid\" value=\""+Deal.hid+"\"><input type=\"submit\" class=\"button\"   value=\"查看价格\" /> ";
html+="</td></tr></table>";
html+="</form>";
popwindow(title,html,500,400,"");
}
function CheckPop()
{
       if($C("txtdStart").value=='')
         {
           alert("请选择入住日期");
           return false;
         }
          if($C("txtdEnd").value=="")
         {
            alert("请选择离店日期");
             
            return false;
         }        
         if(!DateValidate("txtdStart","txtdEnd",14))
         {
            return false;
         }
}
function AddDays(date,days)
{ 
   var	date=date.replace(/\-/g,"/");
	f=new Date(date);
	fs=f.getTime();
	ss=fs+86400000*days;
	endday=new Date(ss);
	var y=endday.getFullYear();
	var m=endday.getMonth()+1;
	var d=endday.getDate();
	if(m<10)m="0"+m;
	if(d<10)d="0"+d;
	return y+"-"+m+"-"+d;
}
  