		



function setAD() {
     //alert(maxContentId);
       //alert(contentId);
     if(contentId==maxContentId-1)contentId = 0;
     //alert(contentId);
     //alert(contentList[contentId]);
     var content = contentList[contentId];
     content = content.substring(1);
     content = content.substring(0,content.length-1);
    
     advDivObj.innerHTML=content; 
	 advDivObj.style.height = '1px';	
	 contentId++;
	 advRun(0);
	
} 

function advRun(i) {  
    if(i<130){
       advDivObj.style.height = i + 'px';
	   i=i+2;
	   setTimeout('advRun('+i+')', 10);
    }else{
       setTimeout('setAD()', 4000);
    }  
 }


//==============check ===============================

var sonwind=null;	

  function isNumber(oNum) 
  { 
      if(!oNum) return false; 
       
      var strP=/^\d+(\.\d+)?$/; 
      if(!strP.test(oNum)) return false; 
      
      try{ 
         
         if(parseFloat(oNum)!=oNum) return false; 
      } catch(ex) { 
           return false; 
      } 
       return true; 
  }		
		
function testStandard(){

     var sex = getRadioValue(document.getElementById("radiobutton1"))=="1";
     
     var selectValue =  getRadioValue(document.getElementById("radiobutton2")) == 'metric';
    
     var s = 0;
  
	// alert("Input your height and weight!"+radioTest);
     if (selectValue){
        //var s1 = form.stature1.value;
        var s2=document.getElementById("stature2").value;
       //alert(s2);
        if(!isNumber(s2)){
                alert("請輸入恰當的腰圍值，且其必須為數字！");
                return false;
        }

       
        //a=form.avoirdupois1.value;
        //alert("s1="+s1);


         s=s2;
         //s=s+"";
         //alert("s="+s);
         
         //check
         
         if(s>400||s<12){
		      alert("請輸入恰當的腰圍值！");
		      return false;
	      }
	}else{
        //s = form.stature.value;
        s=document.getElementById("stature").value
       // alert("s="+s);
        if(!isNumber(s)){
                alert("請輸入恰當的腰圍值，且其必須為數字！");
                return false;
        }
        //check
          if(s>1000||s<20){
		      alert("請輸入恰當的腰圍值！");
		      return false;
	       }
    }
   if(window.showModalDialog != null) //IE   
  {   
  var result =  window.showModalDialog("SingularController?service=healthCheck&sex="+sex+"&selectValue="+selectValue+"&s="+s,null,"dialogWidth=720px;dialogHeight=430px;dialogTop=220px;dialogLeft=250px;status:0;resizable:0;help:0;scroll:no");
  }   
  else   
  {  
                                       //modelessDialog可以将modal换成dialog=yes   
  feature="width=720,height=430,top=220,left=250,menubar=no,toolbar=no,location=no,";   
  feature+="scrollbars=no,status=no,modal=yes"; 
  var url=  "SingularController?service=healthCheck&sex="+sex+"&selectValue="+selectValue+"&s="+s;
  if(sonwind){
     sonwind.close();
   }
 sonwind= window.open(url,null,feature);   
  }  
	
// 	window.location.href= "<%=request.getContextPath()%>"  + "/SingularController?service=healthCheckAll&age="+age+"&sex="+sex+"&height="+s+"&weight="+a+"&path=bmr";
	}

	




function  show1(){ 
     //form.stature1.value="";
     //form.stature2.value=""; 
document.getElementById("stature2").value="";
     document.getElementById("t1").style.display  =  "block";  
     document.getElementById("t2").style.display  =  "none";  
}  



function  show2(){ 
           //form.stature.value=""; 
           document.getElementById("stature").value="";
           document.getElementById("t1").style.display  =  "none";  
           document.getElementById("t2").style.display  =  "block";  
}  



function  resets(){ 
//var radioTest = document.form.elements['radiobutton2'];
var radioTest = document.getElementById("radiobutton2");
	//alert("111111111="+radioTest);
if (getRadioValue(radioTest) == 'metric'){
	//alert("222222");
	show1();
	}else{
	//alert("3333333333");
	show2();
	}

 
}  


	
	function getRadioValue(radio) { 
	 if (!radio.length && radio.type.toLowerCase() == 'radio') 
	   { return (radio.checked)?radio.value:'';  } 
	 if (radio[0].tagName.toLowerCase() != 'input' || radio[0].type.toLowerCase() != 'radio')
	      { return ''; }     
	       var len = radio.length;     
	       for(i=0; i<len; i++) 
	       {if (radio[i].checked)
	       {return radio[i].value; }     
	       }    
	        return ''; 
	} 
	  
	function goLaba(tag){
   //alert(tag);
  //alert('xingyunlaba'==tag);
  if('xingyunlaba'==tag){
    //window.location.href="promotion.html"; 
    window.open('promotion.jsp',null); 
    return false;
  }else{
    return true;
  }
}
 function trim(str) 
   { 
     return str.replace(/^\s*(.*?)[\s\n]*$/g, '$1'); 
   }
    
    //var contextPath='<%=request.getContextPath()%>';         
    function voteSubmit(){
       var cookieString=document.cookie;
       var myCookie = cookieString.split(";");
      
       if(myCookie!=null){
           var tmp ="";
           var tmp2="";
           for(var i=0;i<myCookie.length;i++){
             tmp = myCookie[i];
             tmp = trim(tmp);
             if(tmp=="polled=1"){
               alert("您已經投過票了！");
               return false;
             }
          }
       }
      
       var pl_id=document.getElementById("pl_id").value;
       var voteObj=document.getElementsByName("radiobutton");
     
       var voteValue=0;
       //alert(voteObj.length);
       for(var i=0;i<voteObj.length;i++){
          if (voteObj[i].checked) { 
             voteValue = voteObj[i].value;
		     break;
		  } 
       }
	   
	   if(voteValue==0){
	     alert("請先選擇一個選項然後點擊投票。");
	   }else{	
	      //write,set date
	      var date=new Date(); 
          var expireDays=365; 
          date.setTime(date.getTime()+expireDays*24*3600*1000); 
          //设置为10天后过期 
          document.cookie="polled=1;expire="+date.toGMTString(); 

	     if (window.showModalDialog!=null)//IE判断
         {
            var result =  window.showModalDialog( "SingularController?service=votePoll&pl_id="+pl_id+"&voteValue="+voteValue,null,"dialogWidth=540px;dialogHeight=420px;status:0;resizable:0;help:0;scroll:no");
         }else{
            window.open("SingularController?service=votePoll&pl_id="+pl_id+"&voteValue="+voteValue,null,"top=100,left=150,width=540,height=400,menubar=no,toolbar=no,location=no,scrollbars=no,status=no,modal=yes"); 
          }
	   }
    }

   function viewSubmit(){
      var pl_id=document.getElementById("pl_id").value;
     
      
         if (window.showModalDialog!=null)//IE判断
         {
           
            var result =  window.showModalDialog("SingularController?service=getPollResult&pl_id="+pl_id,null,"dialogWidth=540px;dialogHeight=420px;status:0;resizable:0;help:0;scroll:no");
           
         }else{
            
            window.open( "SingularController?service=getPollResult&pl_id="+pl_id,null,"top=100,left=150,width=540,height=400,menubar=no,toolbar=no,location=no,scrollbars=no,status=no,modal=yes"); 
          }

    }
  
//==============check end===============================

//=====================kaluli=========

            function  goKaluLi(){
            var win="undefined";
               //if (window.showModalDialog!=null)//IE判断
               if (false)
               {
                   var result =  window.showModalDialog("SingularController?service=CalorieList",null,"dialogWidth=1000px;dialogHeight=1550px;status:0;resizable:0;help:0;scroll:no");
               }else{
                   if(win&&win.open&&!win.closed)
       win.close();
         win=window.open("SingularController?service=CalorieList",null,"top=0,left=50,width=900,height=900,menubar=no,toolbar=no,location=no,scrollbars=yes,status=yes,modal=no,resizable=yes");
         win.focus(); 
               }
               return false;
          
             }
