// JavaScript Document

function F(){var E=parseFloat(navigator.appVersion);if(E>=2.0&&E<2.1&&navigator.appName.indexOf("Netscape")!=-1)return false;else return true;}function R(Q){var c=parseInt(Q,10);return!(c%4)&&(!(c%400)||(c%100));}function P(b,c){if(b==2)return R(c)?29:28;if(b==4||b==6||b==9||b==11)return 30;else return 31;}function D(c,C){for(var d=0;d<C.length;d++)if(c==C.options[d].text)return d;return 0;}function m(b,u){return((b+11+u)%12)+1;}function k(b,c,u){return c+((b+11+u)-(b+11+u)%12)/12-1;}function CalCreate(b,c,h,p){if(!F()){alert("Feature not supported.");return;}var l;var B=new Date();if(parseInt(b.options.selectedIndex)==B.getMonth()&&parseInt(c.options[c.options.selectedIndex].text)==B.getYear()){j=0;g=2;}else{j=-1;g=1;}f=g-j+1;if(navigator.appVersion.indexOf("Mac",0)!=-1)l=window.open("","Calendar"+h,"width="+(78+f*200)+",height=255,resizable=yes,scrollbars=no");else l=window.open("","Calendar"+h,"width="+(78+f*200)+",height=235,resizable=yes,scrollbars=no");l.focus();if(h=="A")winA=l;else winD=l;CalCalc(l,b.options.selectedIndex+1,c.options[c.options.selectedIndex].text,c.options[0].text,c.options[c.options.length-1].text,h,p);}function CalCalc(y,O,N,t,s,h,p){if(!F())return;var x=new Array("January","February","March","April","May","June","July","August","September","October","November","December");var b=parseInt(O);var c=parseInt(N,10);while(k(b,c,j)<t)b++;while(k(b,c,g)>s)b--;var a="";var r=0;var e,d;y.document.open();a+="<html><head>";a+='<style type="text/css">';a+='td {font-family: Verdana, Arial, Geneva; font-size: 12px} ';a+='.submit {FONT-SIZE: 9px; COLOR: black; FONT-FAMILY: Verdana, Arial, Geneva}';a+='</style>';a+="<title>"+p+"</title></head><body bgcolor=fbf96d link='#000000'>"+"<center></center>";a+="<table border=0 cellspacing=0 cellpadding=3 width="+200*f+">";a+="<tr valign=top>";for(e=j;e<=g;e++){a+="<td colspan=7 align=center bgcolor=#3a3a36>"+"<b><font color=#f6aa43>"+x[m(b,e)-1]+" "+k(b,c,e)+"</font></b></td>";a+="<td></td>";}a+="</tr>";M=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");a+="<tr align=right>";for(e=j;e<=g;e++){for(d=1;d<=7;d++)a+="<td><font color='"+(((d+r)%7||6)==6?"#787877":"#525251")+"'><b>"+M[(d+r)%7]+"</b></font></td>";if(e<g)a+="<td></td>";}a+="</tr>";var A=0,q,i,z;var o=0;var n,w;while(A<f&&o<10){a+="<tr>";for(e=j;e<=g;e++){i=m(b,e);q=k(b,c,e);z=new Date(i+"/01/"+q);n=(z.getDay()+13-r)%7;w=P(i,q)+n;for(d=o*7+1;d<(o+1)*7+1;d++){if(d<=n||d>w)a+="<td>&nbsp;</td>";else{if(d==w)A++;a+="<td "+(((d+r)%7||6)==6?"bgcolor='#fefd91'":"")+" align=right>&nbsp;<a href='JavaScript:self.close();opener.C"+h+"("+(d-n)+","+i+","+q+")'>"+(d-n)+"</a></td>";}}if(e<g)a+="<td></td>";}o++;a+="</tr>";}if(o<6)a+="<tr><td>&nbsp;</td></tr>";var L=m(b,-1);var K=m(b,+1);var J=k(b,c,1);var I=k(b,c,-1);var H=k(b,c,g+1);var G=k(b,c,j-1);a+="<form action='javascript:return;'><tr><td align=left colspan="+((f==1)?3:7)+" bgcolor=#3a3a36>";if(G<t)a+="&nbsp;";else a+="<input type='button' class='submit' value=' < "+((f==1)?"":x[m(b,j-1)-1]+" ")+"'"+"onClick='document.clear();opener.CalCalc(opener.win"+h+","+L+","+I+","+t+","+s+",\""+h+"\",\""+p+"\")'>";a+="</td>"+"<td align=center colspan="+((f==1)?8*f-7:8*f-15)+" bgcolor=#3a3a36>&nbsp;</td><td align=right colspan="+((f==1)?3:7)+" bgcolor=#3a3a36>";if(H>s)a+="&nbsp;";else a+="<input type='button' class='submit' value='"+((f==1)?"":x[m(b,g+1)-1])+" > '"+"onClick='document.clear();opener.CalCalc(opener.win"+h+","+K+","+J+","+t+","+s+",\""+h+"\",\""+p+"\")'>";a+="</td></tr></form>";a+="</table></body></html>";y.document.write(a);y.document.close();}function CA(v,i,c){document.formx.day_a.options.selectedIndex=parseInt(v)-1;document.formx.month_a.options.selectedIndex=parseInt(i)-1;document.formx.year_a.options.selectedIndex=D(c,document.formx.year_a);calcDate(4);}function CD(v,i,c){document.formx.day_d.options.selectedIndex=parseInt(v)-1;document.formx.month_d.options.selectedIndex=parseInt(i)-1;document.formx.year_d.options.selectedIndex=D(c,document.formx.year_d);calcDate(14);}

function openWindow(k,j,i){var f="width="+j+",height="+i+",";f+="resizable=yes,scrollbars=yes,status=yes,";f+="menubar=yes,toolbar=yes,location=no,directories=no";var h=window.open(k,'_blank',f);h.focus();}function moDa(e){if(typeof arrival=="undefined")calcDate();arrival.setDate(arrival.getDate()+e);depart.setDate(depart.getDate()+e);changeDate();calcDate();}function moNi(e){if(typeof arrival=="undefined")calcDate();document.formx.nights.value=parseInt(document.formx.nights.value)+e;calcDepart();}dow=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");function calcDate(g){var nights=document.formx.nights.value;arrival=new Date(document.formx.year_a.options[document.formx.year_a.selectedIndex].value,document.formx.month_a.selectedIndex,document.formx.day_a.selectedIndex+1);document.formx.month_a.selectedIndex=arrival.getMonth();document.formx.day_a.selectedIndex=arrival.getDate()-1;document.formx.dow_a.value=dow[arrival.getDay()];depart=new Date(document.formx.year_d.options[document.formx.year_d.selectedIndex].value,document.formx.month_d.selectedIndex,document.formx.day_d.selectedIndex+1);document.formx.month_d.selectedIndex=depart.getMonth();document.formx.day_d.selectedIndex=depart.getDate()-1;document.formx.dow_d.value=dow[depart.getDay()];document.formx.nights.value=Math.round((depart-arrival)/86400000);if(g>0&&nights>0){if(g<10)document.formx.nights.value=nights;else if(document.formx.nights.value<=0)document.formx.nights.value=1;calcDepart();}}function changeDate(){var b,a;var d,c;d=new Date(document.formx.year_a.options[0].text,0,1);c=new Date(document.formx.year_a.options[document.formx.year_a.length-1].text,11,31);if(arrival<d)arrival=d;else if(arrival>c)arrival=c;if(depart<d)depart=d;else if(depart>c)depart=c;if(depart<arrival)depart=arrival;document.formx.month_a.selectedIndex=arrival.getMonth();document.formx.day_a.selectedIndex=arrival.getDate()-1;b=arrival.getYear();if(b<1000)b=b+1900;for(a=0;a<document.formx.year_a.length;a++)if(b==document.formx.year_a.options[a].value)document.formx.year_a.options[a].selected=true;document.formx.month_d.selectedIndex=depart.getMonth();document.formx.day_d.selectedIndex=depart.getDate()-1;b=depart.getYear();if(b<1000)b=b+1900;for(a=0;a<document.formx.year_d.length;a++)if(b==document.formx.year_d.options[a].value)document.formx.year_d.options[a].selected=true;}function calcDepart(){arrival=new Date(document.formx.year_a.options[document.formx.year_a.selectedIndex].value,document.formx.month_a.selectedIndex,document.formx.day_a.selectedIndex+1);depart=new Date(document.formx.year_a.options[document.formx.year_a.selectedIndex].value,document.formx.month_a.selectedIndex,document.formx.day_a.selectedIndex+1);depart.setDate(depart.getDate()+parseInt(document.formx.nights.value));changeDate();calcDate(0);}

function createNights() {
document.write(''+

''+
' <input type="hidden" class="form4" size="2" name="nights" value=5 '+
'onchange="calcDepart()">&nbsp; <input type="hidden" class="submit" style="width: 70px; font-size: 10px; margin: 1px 2px 1px 0;" value="+1 Night" onClick="moNi(1)">'+
'<input type="hidden" class="submit" style="width: 70px; font-size: 10px; margin: 1px 2px 1px 0;" value="-1 Night" onClick="moNi(-1)">'+
'');
 }

 function dow_aCal() {
 document.write('<input type="text" size="1" '+
  'value="Thu" class="form11" name="dow_a" onchange="calcDate()">');
document.write("&nbsp<a href=JavaScript:CalCreate(document.formx.month_a,document.formx.year_a,'A','Calendar&nbsp;Arrival')><img align=top src=images/cal.png border=0 ALT=Calendar&nbsp;Arrival></a>");
 }

 function dow_dCal() {
 document.write('<input type="hidden" size="1" '+
  'value="Tue" class="form11" name="dow_d" onchange="calcDate()">');
document.write("&nbsp<a href=JavaScript:CalCreate(document.formx.month_d,document.formx.year_d,'D','Calendar&nbsp;Departure')></a>");
 }
 


function disableButton(theButton) {
theButton.value="Processing Form";
theButton.disabled = true;
return Validate(document.formx)
} 

function Validate(form) {
checkEmail = form.email.value

if (document.formx.firstname.value=='') {
alert("First Name must be filled in!");
form.firstname.select();
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (document.formx.lastname.value=='') {
alert("Last Name or Surname must be filled in!");
form.lastname.select();
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))) {
alert("Email Address field is empty or not valid!");
form.email.select();
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (document.formx.hotelApt.value=='') {
alert("Pickup at must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (document.formx.address1.value=='') {
alert("Street Address must be filled in!");
form.address1.select();
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (document.formx.district.value=='') {
alert("Prague District must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (document.formx.tour.value=='') {
alert("Your tour must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (document.formx.party.value=='') {
alert("Number of people must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (document.formx.hour.value=='') {
alert("Meeting time Hour must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (document.formx.minute.value=='') {
alert("Meeting time Minute must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (document.formx.ampm.value=='') {
alert("AM/PM must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

else {
return true;
}
}

function shapeWrapper(lineHeight,Xs) {
	var out = '';
	Xvalues = Xs.split('|');
	for(i=0; i < Xvalues.length; i++) {
		parts = Xvalues[i].split(',');
		out += '<div style="float:left;clear:left;height:'+lineHeight+'px;width:'+ parts[1]+'px"></div>';
		out += '<div style="float:right;clear:right;height:'+lineHeight+'px;width:'+ parts[2]+'px"></div>';
	}
	document.write(out);
}

function capitalize(f,m) {

if (m) /*cap words*/ {
	var temp, tempC, pre, post, strlen;
	temp = f.value.toLowerCase();
	stringLen = temp.length;
	  if (stringLen > 0) {
		for (i = 0; i < stringLen; i++) {
		  if (i == 0) {
			tempC = temp.substring(0,1).toUpperCase();
			post = temp.substring(1,stringLen);
			temp = tempC + post;
		  } else {
			tempC = temp.substring(i,i+1);
			if (tempC == " " && i < (stringLen-1)) {
			tempC = temp.substring(i+1,i+2).toUpperCase();
			pre = temp.substring(0,i+1);
			post = temp.substring(i+2,stringLen);
			temp = pre + tempC + post;
		  }
		}
	  }
	}
  } else /*cap all*/ {
    var temp = f.value.toUpperCase();
  }
  f.value = temp;
}
