// JavaScript Document

function openpricelist()
	{
	window.open("pricelist.htm","blank","toolbar=no,width=500, height=500")
	}
	
function openpricelistCR()
	{
	window.open("pricelist_CzechRepublicTours.htm","blank","toolbar=no, width=940, height=800")
	}

function openpricelistCR_DE()
	{
	window.open("Preis_AusflugeTschechien.htm","blank","toolbar=no, width=940, height=800")
	}	


function openpricelist_NL()
	{
	window.open("Prijzen.htm","blank","toolbar=no,width=500, height=500")
	}

function openpricelist_DE()
	{
	window.open("Preis.htm","blank","toolbar=no,width=500, height=500")
	}

function openpricelist_ski()
	{
	window.open("pricelist_ski.htm","blank","toolbar=no,width=500, height=600")
	}

function openpricelist_ski_DE()
	{
	window.open("pricelist_ski_DE.htm","blank","toolbar=no,width=500, height=600")
	}
	
function openpricelist_ski_NL()
	{
	window.open("pricelist_ski_NL.htm","blank","toolbar=no,width=500, height=600")
	}
function openinfolist()
	{
	window.open("pricelist.htm","blank","toolbar=no,width=500")
	}

function validate_form()
	{
	if (document.bookingform.firstname.value == "")
		{alert ("Please enter your first name");
		document.bookingform.firstname.focus();
		return false;
		}	
	if (document.bookingform.surname.value == "")
		{alert ("Please enter your surname");
		document.bookingform.surname.focus();
		return false;
		}	
	if (document.bookingform.address1.value == "")
		{alert ("Please enter the first line of your address");
		document.bookingform.address1.focus();
		return false;
		}
	if (document.bookingform.postcode.value == "")
		{alert ("Please enter your postcode");
		document.bookingform.postcode.focus();
		return false;
		}	
	if (document.bookingform.town.value == "")
		{alert ("Please enter your town");
		document.bookingform.town.focus();
		return false;
		}
	if (document.bookingform.country.value == "")
		{alert ("Please enter your country");
		document.bookingform.country.focus();
		return false;
		}	
	if ((document.bookingform.tele.value == "")&&(document.bookingform.mobile.value == ""))
		{alert ("Please enter a contact telephone number");
		document.bookingform.tele.focus();
		return false;
		}
	if (document.bookingform.email.value == "")
		{alert ("Please enter a contact email address to which we can confirm your booking");
		document.bookingform.email.focus();
		return false;
		}
	if (document.bookingform.email.value != "")
		{
		i=document.bookingform.email.value.indexOf("@")
	 	j=document.bookingform.email.value.indexOf(".",i)
	 	k=document.bookingform.email.value.indexOf(",")
	 	kk=document.bookingform.email.value.indexOf(" ")
	 	jj=document.bookingform.email.value.lastIndexOf(".")+1
	 	len=document.bookingform.email.value.length
			if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)) 
			{
 			}
 			else 
			{alert ("Please enter a valid email address to which we can confirm your booking");
			document.bookingform.email.focus();
			return false;
			}
 		}
	if (document.bookingform.party.value == 0)
		{alert ("Please indicate the number of adults in your party");
		document.bookingform.party.focus();
		return false;
		}
	if (document.bookingform.day.value == "dd")
		{alert ("Please indicate for which day you wish to book a tour");
		document.bookingform.day.focus();
		return false;
		}
	if (document.bookingform.month.value == "mm")
		{alert ("Please indicate for which month you wish to book a tour");
		document.bookingform.day.focus();
		return false;
		}
	var iChars = "#%^*+=[]\\\/{}|\<>";
	for (var i = 0; i < document.bookingform.comments.value.length; i++)
	{
  	if (iChars.indexOf(document.bookingform.comments.value.charAt(i)) != -1) 
		{
  	alert ("Your comments message has some special characters. \nThese are not allowed,\n please amend your message.");
  	document.bookingform.comments.focus();
	return false;
  		}
  	}
		
	
	}
	
function checkdate() {
	
	if ((document.bookingform.month.value < 8)&&(document.bookingform.year.value ==2007))
		{alert ("This date is in the past.\n Please amend your selection")
		document.bookingform.month.focus();
		}
	if ((document.bookingform.month.value == 2)&&(document.bookingform.day.value > 29))
		{alert ("In February, there are only 29 days, please amend your selection");
		document.bookingform.day.focus();
		return false;
		}
	if ((document.bookingform.month.value == 4)&&(document.bookingform.day.value == 31))
		{alert ("In April, there are only 30 days, please amend your selection");
		document.bookingform.day.focus();
		return false;
		}
	if ((document.bookingform.month.value == 6)&&(document.bookingform.day.value == 31))
		{alert ("In June, there are only 30 days, please amend your selection");
		document.bookingform.day.focus();
		return false;
		}
	if ((document.bookingform.month.value == 9)&&(document.bookingform.day.value == 31))
		{alert ("In September, there are only 30 days, please amend your selection");
		document.bookingform.day.focus();
		return false;
		}
	if ((document.bookingform.month.value == 11)&&(document.bookingform.day.value == 31))
		{alert ("In November, there are only 30 days, please amend your selection");
		document.bookingform.day.focus();
		}
	else
		{
		return true;
		}
}

function validate_contactform()
	{
errmsg = new Array();
	if (document.contactform.email.value == "")
		{
		errmsg.push("- please enter your email address");
		}
	if (document.contactform.email.value != "")
		{
		i=document.contactform.email.value.indexOf("@")
	 	j=document.contactform.email.value.indexOf(".",i)
	 	k=document.contactform.email.value.indexOf(",")
	 	kk=document.contactform.email.value.indexOf(" ")
	 	jj=document.contactform.email.value.lastIndexOf(".")+1
	 	len=document.contactform.email.value.length
			if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)) 
			{
 			}
 			else {
 			errmsg.push("- please enter a valid email address");
 				}
		}
	
	if (document.contactform.name.value == "")
		{
		errmsg.push("- please enter your name");
		}
	if (document.contactform.phone.value == "")
		{
		errmsg.push("- please enter a phonenumber");
		}
	if (document.contactform.message.value == "")
		{
		errmsg.push("- please enter your message");
		}
	var iChars = "#{}<>";
	for (var i = 0; i < document.contactform.message.value.length; i++) 
		{
  		if (iChars.indexOf(document.contactform.message.value.charAt(i)) != -1) 
			{
  			errmsg.push("- Your message has some invalid characters (only letters and numbers, no signs allowed). Please review your message.");
			}
		}
	if (errmsg.length > 0) 
		{
		alert(("Your form can not be submitted:\n") + errmsg.join(",\n") + ("."));
	//	{
	//	alert(errmsg);
		return false
		}
	else
		{
		return true;
		}
	}

var hour_price_CZK = 600;
var tour_time = 0;
var tour_price_CZK = 0;
var total_price = 0;
var e_price = 0;
var total_party = 3;
var young = 0;
function selectPrice() 
{
var total_party = parseInt(document.bookingform.party.value) + parseInt(document.bookingform.child12.value);
var young = parseInt(document.bookingform.youngchild.value);	
	if ((document.bookingform.tour.value == "PCT") || (document.bookingform.tour.value == "BPT"))
	{
		tour_price_CZK = 600*4;
		tour_time = 4;
	}
	else if ((document.bookingform.tour.value == "SKT")|| (document.bookingform.tour.value == "CLH")|| (document.bookingform.tour.value == "KAR")|| (document.bookingform.tour.value == "KON")|| (document.bookingform.tour.value == "HLU")|| (document.bookingform.tour.value == "KUH")|| (document.bookingform.tour.value == "KRI")|| (document.bookingform.tour.value == "CKR")|| (document.bookingform.tour.value == "CBU"))
	{
		tour_price_CZK = "tba";
		tour_time = 0;
		total_price = "tba";	
		e_price = "tba";
	}
	else if (document.bookingform.tour.value == "BCT")
	{
	tour_price_CZK = 790;
	e_base_price = 33;
	tour_time = 0;
		if (total_party <11)
		{
		tour_price_CZK = total_party*tour_price_CZK+1900;
		e_price = total_party*e_base_price+79;
		}
		else if ((total_party > 10) && (total_party <20))
		{
		tour_price_CZK = total_party*tour_price_CZK+2900;
		e_price = total_party*e_base_price+121;
		}
		else
		{
		tour_price_CZK = "tba";
		e_price = "tba";
		}
		if (young != 0)
		{
		if (tour_price_CZK != "tba")
			{
		tour_price_CZK = tour_price_CZK + (young*500);
		e_price = e_price + (young*21);
			}
		else
			{
			tour_price_CZK = "tba";
			e_price = "tba";
			}
		}
		total_price = tour_price_CZK;
	}
	else if ((document.bookingform.tour.value == "CBT")|| (document.bookingform.tour.value == "GMT") || (document.bookingform.tour.value == "EVT") || (document.bookingform.tour.value == "JGT"))
	{
		tour_price_CZK = 600*3;
		tour_time = 3;
	}
	else
	{
		tour_price_CZK = 600*2;
		tour_time = 2;
	}
		if (document.bookingform.tour.value != "BCT")
	{
		if (total_party <4)
		{
		total_price = tour_price_CZK;	
		}
		else if ((total_party > 3) && (total_party <7))
		{
		total_price = (tour_price_CZK) + (tour_time * 100);	
		}
		else if ((total_party > 6) && (total_party <10))
		{
		total_price = (tour_price_CZK) + (tour_time * 200);	
		}
		else if ((total_party > 9) && (total_party <15))
		{
		total_price = (tour_price_CZK) + (tour_time * 400);	
		}
		else if ((total_party > 14) && (total_party <20))
		{
			if (tour_time == 2)
			{
			total_price = 2400;	
			}
			else if (tour_time == 3)
			{
			total_price = 3800;	
			}
			else
			{
			total_price = 4800;	
			}
		}
		else 
		{
		total_price = "tba";	
		}
	if (total_price == 1200)
		{e_price = 50;}
	else if (total_price == 1400)
		{e_price = 58;}
	else if (total_price == 1600)
		{e_price = 67;}
	else if (total_price == 1800)
		{e_price = 75;}
	else if (total_price == 2000)
		{e_price = 83;}
	else if (total_price == 2100)
		{e_price = 88;}
	else if (total_price == 2400)
		{e_price = 100;}
	else if (total_price == 2800)
		{e_price = 117;}
	else if (total_price == 3000)
		{e_price = 125;}
	else if (total_price == 3200)
		{e_price = 133;}
	else if (total_price == 3800)
		{e_price = 158;}	
	else if (total_price == 4000)
		{e_price = 167;}	
	else if (total_price == 4600)
		{e_price = 192;}
	else if (total_price == 4800)
		{e_price = 199;}
	else if (total_price == 5600)
		{e_price = 233;}
	else if (total_price == "tba")
		{e_price = "tba";}
	}
		
	
	document.getElementById('price').value = total_price;
	document.getElementById('euro_price').value = e_price;
}

function writePrice()
{
document.getElementById('price').value = total_price;
}

function openmailfriend(mypage) 
	{
win = window.open(mypage,"blank","toolbar=yes, width=500, height=500");
win.window.focus();
}

function CreateBookmarkLink_EN() 
{
	var title="Guided Tours Prague, Great Tours Great Experiences"
    var url="http://www.guidedtoursprague.com"

    if (window.sidebar) window.sidebar.addPanel(title, url,"");

    else if( window.opera && window.print )
    {
    var mbm = document.createElement('a');
    mbm.setAttribute('rel','sidebar');
    mbm.setAttribute('href',url);
    mbm.setAttribute('title',title);
    mbm.click();
    }

    else if( document.all ) window.external.AddFavorite( url, title);

}

function CreateBookmarkLink_NL() 
{
	var title="Guided Tours Prague, persoonlijke rondleidingen door Praag"
    var url="http://www.guidedtoursprague.com/Rondleidingen_NL/index_NL.htm"

    if (window.sidebar) window.sidebar.addPanel(title, url,"");

    else if( window.opera && window.print )
    {
    var mbm = document.createElement('a');
    mbm.setAttribute('rel','sidebar');
    mbm.setAttribute('href',url);
    mbm.setAttribute('title',title);
    mbm.click();
    }

    else if( document.all ) window.external.AddFavorite( url, title);

}

function CreateBookmarkLink_DE() 
{
	var title="Guided Tours Prague, Persönliche Stadtführungen"
    var url="http://www.guidedtoursprague.com/Stadtfuhrungen_DE/index_DE.htm"

    if (window.sidebar) window.sidebar.addPanel(title, url,"");

    else if( window.opera && window.print )
    {
    var mbm = document.createElement('a');
    mbm.setAttribute('rel','sidebar');
    mbm.setAttribute('href',url);
    mbm.setAttribute('title',title);
    mbm.click();
    }

    else if( document.all ) window.external.AddFavorite( url, title);

}

function validate_mail_friend_EN()
	{
errmsg = new Array();
	if (document.mail_friend.email.value == "")
		{
		errmsg.push("- Please indicate your email address.");
		}
	if (document.mail_friend.email.value != "")
		{
		i=document.mail_friend.email.value.indexOf("@");
	 	j=document.mail_friend.email.value.indexOf(".",i);
	 	k=document.mail_friend.email.value.indexOf(",");
	 	kk=document.mail_friend.email.value.indexOf(" ");
	 	jj=document.mail_friend.email.value.lastIndexOf(".")+1;
	 	len=document.mail_friend.email.value.length;
			if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)) 
			{
 			}
 			else {
 			errmsg.push("- Please enter a valid email address.");
 				}
		}
	if (document.mail_friend.name.value == "")
		{
		errmsg.push("- Please enter your name");
		}
	if (document.mail_friend.email_friend.value == "")
		{
		errmsg.push("- Please indicate your friend's email address.");
		}
	if (document.mail_friend.email_friend.value != "")
		{
		i=document.mail_friend.email_friend.value.indexOf("@");
	 	j=document.mail_friend.email_friend.value.indexOf(".",i);
	 	k=document.mail_friend.email_friend.value.indexOf(",");
	 	kk=document.mail_friend.email_friend.value.indexOf(" ");
	 	jj=document.mail_friend.email_friend.value.lastIndexOf(".")+1;
	 	len=document.mail_friend.email_friend.value.length;
			if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)) 
			{
 			}
 			else {
 			errmsg.push("- Please enter a valid address for your friend's email.");
 				}
		}
	if (document.mail_friend.name_friend.value == "")
		{
		errmsg.push("- Please enter your friend's name");
		}
	if (errmsg.length > 0) 
		{
		alert(("An error has been encountered:\n") + errmsg.join(",\n") + ("."));
		return false
		}
	else
		{
		return true;
		}
	}

var ids=new Array('sightseeingSlide','opinionSlide');

function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
		document.getElementById(id).style.visibility = 'hidden';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
			document.id.visibility='hidden';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
			document.all.id.style.visibility = 'hidden';			
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
		document.getElementById(id).style.visibility = 'visible';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
			document.id.visibility='visible';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
			document.all.id.style.visibility='visible'
		}
	}
}

