function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }

    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }

    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }

    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
   
  function displayMsgBox(){        
        document.getElementById('mask').style.display='block';
        document.getElementById('mask').style.width = getPageSize()[0] + 'px';    
        document.getElementById('AlertBox').style.display='block';
        document.getElementById('AlertBox').style.left = (getPageSize()[0]-450)/2 + 'px';
    }
   
   function SetDivLayer3(e){
       e = (e) ? e : window.event;
        var element = (e.target) ? e.target: e.srcElement;
        var left = element.offsetLeft;
        var top  = element.offsetTop;
        while(element=element.offsetParent)
        {
            left += element.offsetLeft;
            top  += element.offsetTop;
        }
       document.getElementById('Layer3').style.left = left + 'px';
       document.getElementById('Layer3').style.display = 'block';  
   }     
   
   function getPageSize(){
         var xScroll, yScroll;
         if (window.innerHeight && window.scrollMaxY)
         {
            xScroll = document.body.scrollWidth;
            yScroll = window.innerHeight + window.scrollMaxY;
        }
        else if (document.body.scrollHeight > document.body.offsetHeight)
        // all but Explorer Mac
        {
            xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
        }
        else
        // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        {
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }
        var windowWidth, windowHeight;
        if (self.innerHeight)
        // all except Explorer
        {
            windowWidth = self.innerWidth;
            windowHeight = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        // Explorer 6 Strict Mode
        {
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        }
        else if (document.body)
        // other Explorers
        {
            windowWidth = document.body.clientWidth;
            windowHeight = document.body.clientHeight;
        }
        // for small pages with total height less then height of the viewport
        if (yScroll < windowHeight)
            pageHeight = windowHeight;
        else
            pageHeight = yScroll;
        // for small pages with total width less then width of the viewport
        if (xScroll < windowWidth)
            pageWidth = windowWidth;
        else
            pageWidth = xScroll;
        arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
        return arrayPageSize;
    }  
    
function changelang(lang){
    var backlocation=window.location.href;
    window.location="./common/setLang.php?changeLang="+lang+"&toppage="+backlocation;
} 
function txtScroller(id,w,n,lang){
    if(lang=="En"){
        document.getElementById(id).innerHTML=
        '<a href="./QandA.php?tab=3">If you want to know about the condition of your hair, come for a free consultation.</a>'+
        '<a href="./QandA.php?tab=3">Except hair care, we still Pedicure and Manicure.</a>'+
        '<a href="./QandA.php?tab=3">Except hair care, we still Eyebrow Shaping.</a>'+
        '<a href="./QandA.php?tab=3">Joining a treatment course can get $200 cash coupon.</a>'+
        '<a href="./QandA.php?tab=3">Hairline members will benefit from 10% or 20% discounts.</a>'+
        '<a href="./QandA.php?tab=3">Hairline offers cash coupons for client referrals.</a>'+
        '<a href="./QandA.php?tab=3">What is hair loss?</a>'+
        '<a href="./QandA.php?tab=3">What are the reasons for hair loss?</a>'+
        '<a href="./QandA.php?tab=3">How long will treatment program start to see results?</a>'+
        '<a href="./QandA.php?tab=3">Why does it take so long for any treatment to work?</a>'+
        '<a href="./QandA.php?tab=3">What is the best way to assess regrowth?</a>'+
        '<a href="./QandA.php?tab=3">How can Hairline help me?</a>';
    }else{
        document.getElementById(id).innerHTML=
        '<a href="./QandA.php?tab=3">您想知道你的頭髮健康嗎?來做個分析。</a>'+
        '<a href="./QandA.php?tab=3">除了頭髮護理,我們還有腳部謢理服務。</a>'+
        '<a href="./QandA.php?tab=3">除了頭髮護理,我們還有修眉服務。</a>'+
        '<a href="./QandA.php?tab=3">購買療程可獲$200現金優惠券。</a>'+
        '<a href="./QandA.php?tab=3">活髮會員可享有九折或八折優惠。</a>'+
        '<a href="./QandA.php?tab=3">成功推薦朋友可獲贈活髮護理現金優惠券。</a>'+
        '<a href="./QandA.php?tab=3">什麼是脫髮？</a>'+
        '<a href="./QandA.php?tab=3">為什麼會脫髮？</a>'+
        '<a href="./QandA.php?tab=3">療程開始了多久會見到成效？</a>'+
        '<a href="./QandA.php?tab=3">為什麼需要這麼長時間？</a>'+
        '<a href="./QandA.php?tab=3">什麼是測量頭髮再生的最佳辦法？</a>'+
        '<a href="./QandA.php?tab=3">活髮可用什麼方法解決我的問題？</a>';  
    }
    var box=document.getElementById(id),can=true,w=w||1500,fq=fq||5,n=n==-1?-2:1;
    box.innerHTML+=box.innerHTML;
    box.onmouseover=function(){can=false};
    box.onmouseout=function(){can=true};
    var max=parseInt(box.scrollHeight/2);
    new function (){
        var stop=box.scrollTop%54==0&&!can;
        if(!stop){
            var set=n>0?[max,0]:[0,max];
            box.scrollTop==set[0]?box.scrollTop=set[1]:box.scrollTop+=n;
        };
        setTimeout(arguments.callee,box.scrollTop%54?fq:w);
    };
};

function menujump(page){
    window.location="./common/setSession.php?page="+page;    
}
function changehour(hour){
    if(hour=="hh"){
        document.getElementById("SelectTimeMinID").disabled=true;    
    }else{
        document.getElementById("SelectTimeMinID").disabled=false;
    }
    if(hour=="11"){
        document.getElementById("SelectTimeMinID").style.display="none";
        document.getElementById("SelectTimeMinID2").style.display="block";
        document.getElementById("SelectTimeMinID3").style.display="none";
    }else if(hour=="20"){
        document.getElementById("SelectTimeMinID").style.display="none";
        document.getElementById("SelectTimeMinID2").style.display="none";   
        document.getElementById("SelectTimeMinID3").style.display="block";
    }else{
        document.getElementById("SelectTimeMinID").style.display="block";
        document.getElementById("SelectTimeMinID2").style.display="none";   
        document.getElementById("SelectTimeMinID3").style.display="none"; 
    }        
}

function changeCountryCode(code){
    if(code=="Others"){
        document.getElementById("orderscountrycodeID").style.display="block";
    }else{
        document.getElementById("orderscountrycodeID").style.display="none";    
    }    
}

function checkquestform(){
    var name=document.getElementById("nameid");
    if(name.value==""){
        document.getElementById("ErrorSummary").style.display="block";
        document.getElementById("Errormail").style.display='none';
        name.focus();
        return false;
    }  
    var Expressionemail=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
    var objExpemail=new RegExp(Expressionemail);
    var email=document.getElementById("Emailid");
    if(!objExpemail.test(email.value) && email.value!=""){
        document.getElementById("Errormail").style.display='block';
        document.getElementById("ErrorSummary").style.display="none";
        email.focus();
        return false;
    }
}
                                   
function checkfield (a) {
    if ((a.value=='') || (a.value==' ')){
        errorFlag++;
        a.style.backgroundColor = "#4286CE";
        a.style.color = "#FFFFFF";
    } else {
        a.style.backgroundColor = "#FFFFFF";
        a.style.color = "#000000"; 
    }
}

function checkcontactform(){
    errorFlag = 0;
    with (document.contactForm) {
        checkfield(contactname);
        checkfield(CountryCode); 
        checkfield(ContactNum); 
        checkfield(contactEmail);
        checkfield(NatureOfCommnet); 
        checkfield(Comment); 
    }
    if (errorFlag != 0) {
        document.getElementById("checkerror").style.display="block";
        document.getElementById("Errormail").style.display='none';
        return false; 
    }else{
        document.getElementById("checkerror").style.display="none";
        document.getElementById("Errormail").style.display='none';  
    } 
    var Expressionemail=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
    var objExpemail=new RegExp(Expressionemail);
    var email=document.getElementById("contactEmailid");
    if(!objExpemail.test(email.value) && email.value!=""){
        document.getElementById("Errormail").style.display='block';
        document.getElementById("checkerror").style.display="none";
        email.focus();
        return false;
    }
} 