//Kal routines(c)Geare Info-Systems Ltd. 2009
//Version 1.1.0 - 5th October 2009
var ErrCon=0;var gv2=1;var gv3;var gv4=false;
function funMA(n){for(var i=1;i<=n;i++){this[i]=0}return this}
var A1=funMA(12);A1[1]=31;A1[2]=29;A1[3]=31;A1[4]=30;A1[5]=31;A1[6]=30;A1[7]=31;A1[8]=31;A1[9]=30;A1[10]=31;A1[11]=30;A1[12]=31;
function fun1(s){return((s==null)||(s.length==0))}
function fun2(c){return((c>="0")&&(c<="9"))}
function fun3(s){var i;if(fun1(s))if(fun3.arguments.length==1)return gv4;else return(fun3.arguments[1]==true);for(i=0;i<s.length;i++){var c=s.charAt(i);if(!fun2(c))return false;}return true;}
function fun4(s){if(fun1(s))if(fun4.arguments.length==1)return gv4;else return(fun4.arguments[1]==true);else{var startPos=0;var secondArg=gv4;if(fun4.arguments.length>1)secondArg=fun4.arguments[1];if((s.charAt(0)=="-")||(s.charAt(0)=="+"))startPos=1;return(fun3(s.substring(startPos,s.length),secondArg))}}
function fun5(s){var secondArg=gv4;if(fun5.arguments.length>1)secondArg=fun5.arguments[1];return(fun4(s,secondArg)&&((fun1(s)&&secondArg)||(parseInt(s)>=0)));}
function fun6(s,a,b){if(fun1(s))if(fun6.arguments.length==1){return gv4}else {return(fun6.arguments[1]==true)}if(!fun3(s,false))return false;var num=parseInt(s);return((num>=a)&&(num<=b));}
function fun7(c){return(((c>="a")&&(c<="z"))||((c>="A")&&(c<="Z")))}
function fun8(s){if(fun1(s))if(fun8.arguments.length==1)return gv4;else return(fun8.arguments[1]==true);if(!fun5(s))return false;return((s.length==2)||(s.length==4));}
function fun9(s){var i;for(i=0;i<s.length;i++){var c=s.charAt(i);if(!(fun7(c)||fun2(c)||(c==" ")))return false;}return true;}
function fun10(s){var i;for(i=0;i<s.length;i++){var c=s.charAt(i);if(!(fun7(c)||fun2(c)))return false;}return true;}
function fun11(s){var i;for(i=0;i<s.length;i++){var c=s.charAt(i);if(!fun7(c))return false;}return true;}
function fun12(s){var i;for(i=0;i<s.length;i++){var c=s.charAt(i);if(!(fun7(c)||(c==" ")))return false;}return true;}
function fun13(s){var i;for(i=0;i<s.length;i++){var c=s.charAt(i);if(!(fun2(c)||(c==".")||(c=="+")||(c=="-")||(c==",")))return false;}return true;}
function fun14(s){var i;for(i=0;i<s.length;i++){var c=s.charAt(i);if(!(fun2(c)||(c=="+")||(c==" ")||(c=="(")||(c==")")))return false;}return true;}
function fun15(s){var i;var c=s.charAt(0);if(!((c=="Y")||(c=="y")||(c=="n")||(c=="N"))){return false;}return true;}
function fun16(s){var i;for(i=0;i<s.length;i++){var c=s.charAt(i);if(c=="'")return false;}return true;}
function fun17(s){if(fun1(s))if(fun17.arguments.length==1)return gv4;else return(fun17.arguments[1]==true);return fun6(s,1,12);}
function fun18(s){if(fun1(s))if(fun18.arguments.length==1)return gv4;else return(fun18.arguments[1]==true);return fun6(s,1,31);}
function fun19(pip1){return(((pip1%4==0)&&((!(pip1%100==0))||(pip1%400==0)))? 29 : 28 );}
function fun20(pip1,pip2,pip3){if(!(fun8(pip1,false)&&fun17(pip2,false)&&fun18(pip3,false)))return false;var lv1=parseInt(pip1);var lv2=parseInt(pip2);var lv3=parseInt(pip3);if(lv3>A1[lv2])return false;if((lv2==2)&&(lv3>fun19(lv1)))return false;return true;}
function fun21(pip1,pip2,pip3){var lv1;if(pip3>1900){pip3=pip3-1900}lv1=((pip3)*365)+parseInt(pip3/4)+pip1;if(pip2==1)lv1=lv1+0;if(pip2==2)lv1=lv1+31;if(pip2==3)lv1=lv1+59;if(pip2==4)lv1=lv1+90;if(pip2==5)lv1=lv1+120;if(pip2==6)lv1=lv1+151;if(pip2==7)lv1=lv1+181;if(pip2==8)lv1=lv1+212;if(pip2==9)lv1=lv1+243;if(pip2==10)lv1=lv1+273;if(pip2==11)lv1=lv1+304;if(pip2==12)lv1=lv1+334;return lv1}
function fun22(pip1,pip2,pip3){var lv1;var lv2;var lv3;var lv4;var lv5;lv1=pip1.toString();if(lv1=="NaN"){lv1="0"}lv2=lv1.lastIndexOf('.');lv5='';if(lv2!=-1){for(lv3=lv2+1;lv3<(lv2+pip2+1);lv3++){lv5=lv5+lv1.charAt(lv3)}if(lv5.length<pip2){lv5=lv5+'0'}}else{if(pip2>0){lv5='.';for(lv3=0;lv3<pip2;lv3++){lv5=lv5+'0'}}lv2=lv1.length}lv4=0;for(lv3=lv2;lv3>-1;lv3--){if(lv4==4){lv5=','+lv5;lv4=1}lv5=lv1.charAt(lv3)+lv5;lv4=lv4+1}if(pip3.length!=0){lv5=pip3+lv5}return lv5}
function stKalFld(pip1,pip2,pip3){var s=pip1+' '+window.document.forms[pip3].elements['KALENDA_TEMP_MONTH'].value+' '+window.document.forms[pip3].elements['KALENDA_TEMP_YEAR'].value;window.document.forms[pip3].elements[pip2].value=s;document.getElementById('DisplayACDateFrom').innerHTML=s;window.document.forms[pip3].elements['KALENDA_TEMP_DATE'].value="";window.document.forms[pip3].elements['KALENDA_TEMP_MONTH'].value="";window.document.forms[pip3].elements['KALENDA_TEMP_YEAR'].value="";var o="KALENDA_"+pip2;document.getElementById(o).className='QKalendaHide';document.getElementById(o).innerHTML='';}
function ptKal2(pip1,pip2,pip3,pip4,pip5){var lv1=["January","February","March","April","May","June","July","August","September","October","November","December"];var lv2=["Su","Mo","Tu","We","Th","Fr","Sa"];var lv3=window.document.forms[pip3].elements[pip2].value;var lv4=new Date(pip1);var lv5=new Date(lv3);var lv6=new Date();var lv7;if(isNaN(Date.parse(pip1))){lv4=new Date();}var lv8,lv9,lv10,lv11,lv12,lv13;lv8=parseInt(lv5.getDate());lv9=parseInt(lv5.getMonth());lv10=parseInt(lv5.getFullYear());lv11=parseInt(lv6.getDate());lv12=parseInt(lv6.getMonth());lv13=parseInt(lv6.getFullYear());window.document.forms[pip3].elements['KALENDA_TEMP_DATE'].value=parseInt(lv4.getDate());window.document.forms[pip3].elements['KALENDA_TEMP_MONTH'].value=lv1[parseInt(lv4.getMonth())].substr(0,3);window.document.forms[pip3].elements['KALENDA_TEMP_YEAR'].value=parseInt(lv4.getFullYear());var lv14;var lv15='1 '+lv1[parseInt(lv4.getMonth())].substr(0,3)+' '+parseInt(lv4.getFullYear());var lv16=new Date(lv15);var lv17=parseInt(lv16.getDay());var lv18=A1[parseInt(lv4.getMonth())+1];if(parseInt(lv4.getMonth())==2)lv18=fun19(parseInt(lv4.getFullYear()));lv7="<TABLE class=\"KalendaTblMain\">";var lv19="var o='KALENDA_"+pip2+"';s=window.document.forms['"+pip3+"'].elements['KALENDA_TEMP_DATE'].value+' '+window.document.forms['"+pip3+"'].elements['KALENDA_TEMP_MONTH'].value+' '+window.document.forms['"+pip3+"'].elements['KALENDA_TEMP_YEAR'].value;document.getElementById(o).innerHTML=ptKal2(s,'"+pip2+"','"+pip3+"');";lv7+="<TR>\n<TD colspan=\"7\"><TABLE class=\"KalendaTblHeader\"><TR><TD align=\"left\">";lv7+="<SELECT name=\"MonthSelector\" class=\"KalendaSelMonth\" onChange=\"window.document.forms['"+pip3+"'].elements['KALENDA_TEMP_MONTH'].value=this.value;"+lv19+"\">";for(lv14=0;lv14<12;lv14++){lv7+="<OPTION";if(lv14==lv4.getMonth()){lv7+=" SELECTED";}lv7+=" value=\""+lv1[lv14].substr(0,3)+"\">"+lv1[lv14]+"\n";}lv7+="</SELECT></TD>";lv7+="\n<TD align='right'><TABLE class=\"KalendaTblYear\"><TR>";lv7+="<TD class=\"KalendaCellYear\">";if(pip4==pip5){lv7+=pip5;}else{lv7+="<SELECT id=\"KalendaDDLYear\" class=\"KalendaSelMonth\" name=\"KalendaDDLYear\" onChange=\"window.document.forms['"+pip3+"'].elements['KALENDA_TEMP_YEAR'].value=this.value;\">";for(lv14=pip4;lv14<=pip5;lv14++){lv7+="<OPTION value=\""+lv14+"\"";if(lv14==parseInt(lv4.getFullYear())){lv7+=" SELECTED";}lv7+=">"+lv14+"</OPTION>";}}lv7+="</SELECT>";lv7+="</TD>";lv7+="</TR></TABLE>";lv7+="</TD></TR></TABLE></TD>\n";lv7+="</TR>";lv7+="<TR>";for(lv14=0;lv14<7;lv14++){lv7+="<TD class=\"KalendaCellDOW\">"+lv2[lv14]+"</TD>";}lv7+="</TR>";var lv19=0;if(lv17>lv19){for(lv14=0;lv14<lv17;lv14++){lv7+="<TD>&nbsp;</TD>";lv19=lv17;}}var lv20;for(lv14=1;lv14<=lv18;lv14++){lv20="KalendaCellWeekDay";if((lv19==0)||(lv19==6)){lv20="KalendaCellWeekend";}if((lv11==lv14)&&(lv1[lv12].substr(0,3)==window.document.forms[pip3].elements['KALENDA_TEMP_MONTH'].value)&&(lv13==window.document.forms[pip3].elements['KALENDA_TEMP_YEAR'].value)){lv20="KalendaCellToday";}if((lv8==lv14)&&(lv1[lv9].substr(0,3)==window.document.forms[pip3].elements['KALENDA_TEMP_MONTH'].value)&&(lv10==window.document.forms[pip3].elements['KALENDA_TEMP_YEAR'].value)){lv20="KalendaCellSelected";}lv7+="<TD class=\""+lv20+"\" onClick=\"stKalFld("+lv14+",'"+pip2+"','"+pip3+"');\">"+lv14+"</TD>";lv19++;if(lv19==7){lv19=0;lv7+="</TR>";if(lv14<lv18){lv7+="<TR>";}}}if((lv19<7)&&(lv19>0)){for(lv14=lv19;lv14<7;lv14++){lv7+="<TD>&nbsp;</TD>";}lv7+="</TR>";}lv7+="</TABLE></TD></TR>";lv7+="</TABLE>";return lv7;}
function AccomCk(){if((ckSDate('AccomChecker',1,'',document.forms['AccomChecker'].elements['ACDateFrom'].value,'','',2,'A','Y',3)==0)&&(ckNumber('AccomChecker',2,'',document.forms['AccomChecker'].elements['ACNoNights'].value,1,99,'I',0,'','Y',3)==0)&&(ckNumber2('AccomChecker',3,'',document.forms['AccomChecker'].elements['ACRoomType'].options[document.forms['AccomChecker'].elements['ACRoomType'].selectedIndex].value,1,9999,'I','Y',3)==0)){return true}else{alert('Arrival date, No. of days and Room Type are all required to run a check for availability of accommodation.');return false;}}
