// 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>";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')></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 checkRadio (frmName, rbGroupName) {
 var radios = document[frmName].elements[rbGroupName];
 for (var i=0; i <radios.length; i++) {
  if (radios[i].checked) {
   return true;
  }
 }
 return false;
}


 

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.party.value =='') {
alert("Number of people must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (document.formx.carType.value =='') {
alert("Type of transportation must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (document.formx.destination.value == '') {
alert("Destination must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (document.formx.destAddr.value == '') {
alert("Destination street address must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (document.formx.pickupHour.value =='') {
alert("Pickup time Hour must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (document.formx.pickupMin.value =='') {
alert("Pickup time Minute must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (document.formx.pickupAmpm.value =='') {
alert("Pickup AM/PM must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (!checkRadio("formx","transfers")){
alert("Pickup At must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

myOption = -1;
for (i=form.transfers.length-1; i > -1; i--) {
if (form.transfers[i].checked) {
myOption = i; i = -1;

(radioVal = form.transfers[myOption].value);
}
}


if (radioVal == 'Airport' & document.formx.airline.value == ''){
alert("Arriving airline name must be entered!");
form.airline.select();
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (radioVal == 'Airport' & document.formx.flightNum.value == ''){
alert("Airline flight number must be entered!");
form.flightNum.select();
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (radioVal == 'Airport' & document.formx.airportHour.value == ''){
alert("Flight arrival time hour must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (radioVal == 'Airport' & document.formx.airportMin.value == ''){
alert("Flight arrival time minute must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (radioVal == 'Airport' & document.formx.airportAmpm.value == ''){
alert("Flight arrival time ampm must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (radioVal == 'Train Station' & document.formx.arrStation.value == ''){
alert("Arriving train station must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (radioVal == 'Train Station' & document.formx.trainFrom.value == ''){
alert("City you will board train must be entered!");
form.trainFrom.select();
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (radioVal == 'Train Station' & document.formx.trainNum.value == ''){
alert("Train number must be entered!");
form.trainNum.select();
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (radioVal == 'Train Station' & document.formx.trainHour.value == ''){
alert("Train arrival time hour must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (radioVal == 'Train Station' & document.formx.trainMin.value == ''){
alert("Train arrival time minute must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (radioVal == 'Train Station' & document.formx.trainAmpm.value == ''){
alert("Train arrival time ampm must be selected!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (radioVal == 'Apartment' & document.formx.aptAddr.value == ''){
alert("Apartment street address must be entered!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (radioVal == 'Hotel' & document.formx.hotel.value == ''){
alert("Hotel name must be entered!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

if (radioVal == 'Other' & document.formx.other.value == ''){
alert("Other street address must be entered!");
form.submit.disabled = false;
form.submit.value = "Submit Reservation";
return false;
}

else {
return true;
}
}

function set_dcode()
{	
if(document.formx.destination.value == "Airport"){
document.formx.destAddr.value = "Prague Ruzyne Intl. Airport";
}
else{
if(document.formx.destination.value == "Hlavni Nadrazi"){
document.formx.destAddr.value = "Prague Main Train Station";
}
else{
if(document.formx.destination.value == "Nadrazi Holesovice"){
document.formx.destAddr.value = "Prague Train Station Holesovice";
}
else{
if(document.formx.destination.value == "Nadrazi Smichov"){
document.formx.destAddr.value = "Prague Train Station Smichov";
}
else{
if(document.formx.destination.value == "Apartment"){
document.formx.destAddr.value = "";
}
else{
if(document.formx.destination.value == "Hotel"){
document.formx.destAddr.value = "";
}
else{
if(document.formx.destination.value == "Other"){
document.formx.destAddr.value = "";
}
}
}
}
}
}
}
}

function hide(){
document.getElementById('airportBox').style.display = "none";
document.getElementById('stationBox').style.display = "none";
document.getElementById('apartmentBox').style.display = "none";
document.formx.aptAddr.value = "";
document.formx.aptDistrict.value = "";
document.getElementById('hotelBox').style.display = "none";
document.getElementById('otherBox').style.display = "none";
}

function airConflict() {
if (document.formx.destination.value == "Airport") {
alert("Warning - Pickup place and destination cannot be the same!");

document.getElementById('airportBox').style.display = "none";
document.getElementById('stationBox').style.display = "none";
document.getElementById('apartmentBox').style.display = "none";
document.formx.aptAddr.value = "";
document.formx.aptDistrict.value = "";
document.getElementById('hotelBox').style.display = "none";
document.getElementById('otherBox').style.display = "none";
}
}

function airConflict1() {
if (radioVal == 'Airport' & document.formx.transfer.value == 'Airport'){
alert("Warning - Pickup place and destination cannot be the same!");
document.getElementById('airportBox').style.display = "none";
document.getElementById('stationBox').style.display = "none";
document.getElementById('apartmentBox').style.display = "none";
document.formx.aptAddr.value = "";
document.formx.aptDistrict.value = "";
document.getElementById('hotelBox').style.display = "none";
document.getElementById('otherBox').style.display = "none";

}
}

function setCursorPos( x ) {
    var txtRange = x.createTextRange();
    txtRange.moveStart( "character", x.value.length - 0 );
    txtRange.moveEnd( "character", 0 );
    txtRange.select();
}

function limitText(limitField, limitCount, limitNum) {
if (limitField.value.length > limitNum) {
limitField.value = limitField.value.substring(0, limitNum);
} else {
limitCount.value = limitNum - limitField.value.length;
}
}

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;
}

