
/*
Given a date as a string, return the day of week as an integer between 1 and 7. Note Sunday=1.
datestring format: "October 7, 1999"
*/
function dayofweek(datestring){
 var dati;
 dati=new Date(datestring);  //make datestr into a Date instance
 return(1+dati.getDay()); //get the day of the week and add 1
                          //since getDaty() return a number between 0 and 6 
}
function predict(form){
var stDay=1
var stDate="October 7, 1999"
var stMonth=1
var stMonth2="January"
var stYear=2500
var StYear2=1970
var stWeek=1
var result=1
stDay=form.lstDay.options[form.lstDay.selectedIndex].value
stMonth=form.lstMonth.options[form.lstMonth.selectedIndex].value
stYear=form.lstYear.options[form.lstYear.selectedIndex].value

/*Day of week*/
stYear2=parseInt(stYear)-543;
/*convert Month to Janualry format*/
if (stMonth==1){
  stMonth2="January"
}
if (stMonth==2){
  stMonth2="February"
}
if (stMonth==3){
  stMonth2="March"
}
if (stMonth==4){
  stMonth2="April"
}
if (stMonth==5){
  stMonth2="May"
}
if (stMonth==6){
  stMonth2="June"
}
if (stMonth==7){
  stMonth2="July"
}
if (stMonth==8){
  stMonth2="August"
}
if (stMonth==9){
  stMonth2="September"
}
if (stMonth==10){
  stMonth2="October"
}
if (stMonth==11){
  stMonth2="November"
}
if (stMonth==12){
  stMonth2="December"
}
stDate=stMonth2 + " " + stDay + ", " + stYear2
stWeek=dayofweek(stDate)
/*convert to thai month*/
stMonth=++stMonth;
if (stMonth>12){
  stMonth=1; 
}
/*convert to thai year (12 rasi)*/
/*compensate Year for Month < 5 */
/*Thai New Year is on April*/
if (stMonth<5){
 stYear=stYear%12+5;
}else{
 stYear=stYear%12+6;
}
if (stYear>12){
 stYear=parseInt(stYear)-12;
}

/*Open html*/
result=parseInt(stWeek)+parseInt(stMonth)+parseInt(stYear);
result=parseInt(result)*7;
result=parseInt(result)%9;
if (result==0){
  window.location="no9.asp";
}
if (result==1){
  window.location="no1.asp";
}
if (result==2){
  window.location="no2.asp";
}
if (result==3){
  window.location="no3.asp";
}
if (result==4){
  window.location="no4.asp";
}
if (result==5){
  window.location="no5.asp";
}
if (result==6){
  window.location="no6.asp";
}
if (result==7){
  window.location="no7.asp";
}
if (result==8){
  window.location="no8.asp";
}
}


