// JavaScript Document

function bookmark(address,sitename) {
  if (window.sidebar) {
    window.sidebar.addPanel(sitename, address,"");
  } else if( document.all ) {
    window.external.AddFavorite(address, sitename);
  } else if( window.opera && window.print ) {
    return true;
  }
}

function showtext(id){
   if (id == 1) document.getElementById("maptext").innerHTML = "Afrika";
   if (id == 2) document.getElementById("maptext").innerHTML = "Asia";
   if (id == 3) document.getElementById("maptext").innerHTML = "Australia";
   if (id == 4) document.getElementById("maptext").innerHTML = "Central South America";
   if (id == 5) document.getElementById("maptext").innerHTML = "Europe";
   if (id == 6) document.getElementById("maptext").innerHTML = "India & Ocean";
   if (id == 7) document.getElementById("maptext").innerHTML = "Middle East";
   if (id == 8) document.getElementById("maptext").innerHTML = "North America";
   if (id == 9) document.getElementById("maptext").innerHTML = "South East Asia";
   if (id == 0) document.getElementById("maptext").innerHTML = "Klik op de map en selecteer een bestemming";
}

function showeurope(id){
   if (id == 0) document.getElementById("maptexteu").innerHTML = "Klik op de map en selecteer een bestemming";
    if (id == 1) document.getElementById("maptexteu").innerHTML = "Portugal";
    if (id == 2) document.getElementById("maptexteu").innerHTML = "Spanje";
    if (id == 3) document.getElementById("maptexteu").innerHTML = "Zwitserland";
    if (id == 4) document.getElementById("maptexteu").innerHTML = "Italie";
    if (id == 5) document.getElementById("maptexteu").innerHTML = "Oostenrijk";
    if (id == 6) document.getElementById("maptexteu").innerHTML = "Slowenie";
    if (id == 7) document.getElementById("maptexteu").innerHTML = "Kroatie";
    if (id == 8) document.getElementById("maptexteu").innerHTML = "Bulgarije";
    if (id == 9) document.getElementById("maptexteu").innerHTML = "Griekenland";
    if (id == 10) document.getElementById("maptexteu").innerHTML = "Turkije";
    if (id == 11) document.getElementById("maptexteu").innerHTML = "Hongarije";
    if (id == 12) document.getElementById("maptexteu").innerHTML = "Slowakije";
    if (id == 13) document.getElementById("maptexteu").innerHTML = "Tsjechie";
    if (id == 14) document.getElementById("maptexteu").innerHTML = "Polen";
    if (id == 15) document.getElementById("maptexteu").innerHTML = "Nederland";
    if (id == 16) document.getElementById("maptexteu").innerHTML = "Belgie";
    if (id == 17) document.getElementById("maptexteu").innerHTML = "Denemarken";
    if (id == 18) document.getElementById("maptexteu").innerHTML = "Duitsland";
    if (id == 19) document.getElementById("maptexteu").innerHTML = "Frankrijk";
    if (id == 20) document.getElementById("maptexteu").innerHTML = "Groot-Brittannie";
    if (id == 21) document.getElementById("maptexteu").innerHTML = "Ierland";
    if (id == 22) document.getElementById("maptexteu").innerHTML = "Noorwegen";
    if (id == 23) document.getElementById("maptexteu").innerHTML = "Zweden";
    if (id == 24) document.getElementById("maptexteu").innerHTML = "Finland";
    if (id == 25) document.getElementById("maptexteu").innerHTML = "Litauen";
    if (id == 26) document.getElementById("maptexteu").innerHTML = "Servie en Montenegro";
    if (id == 27) document.getElementById("maptexteu").innerHTML = "Rusland";
}

function hideDiv(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showDiv(id) {		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}


function changemap(id){
	if (id == 2) {
		hideDiv('subme_1');
		showDiv('subme_2');
		hideDiv('mapworld');
		showDiv('mapeuropa');
	}
	else {
		hideDiv('subme_2');
		showDiv('subme_1');
		hideDiv('mapeuropa');
		showDiv('mapworld');
	}
}

function checkItem(txF, dvName_) {	
	ret = 1;
	style_ = 'stFormCellText';
	item_ = document.getElementById(dvName_);
	if(txF.value == '') {
		style_ = "stFormCellTextError";		
		ret = 0;
	}
	item_.className = style_;
	return ret;
}

function setDVstyle(dv, st){
	item_ = document.getElementById(dv);
	item_.className = st;
}

function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)

	 if (str.indexOf(at)==-1) return false
	 if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false
 	 if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || ldot+1==lstr) return false
	 if (str.indexOf(at,(lat+1))!=-1) return false
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false
	 if (str.indexOf(dot,(lat+2))==-1) return false		
	 if (str.indexOf(" ")!=-1) return false
	
	return true					
}

function validateMail(frm){
	var t = 0;	
	t+=checkItem(frm.emailfrom, 'inpEmailFrom');
	t+=checkItem(frm.emailto, 'inpEmailTo');
	
	if (echeck(frm.emailfrom.value))
		t++;
		else
			setDVstyle("inpEmailFrom", "stFormCellTextError");		
	
	if (echeck(frm.emailto.value))
		t++;
		else
			setDVstyle("inpEmailTo", "stFormCellTextError");				
		
	if (t == 4) 
		frm.submit();
	return false;
}

function checkDestination(frm){
	var t = 0;	
	setDVstyle("destination", "stFormCellTextwh");
	t+=checkItem(frm.dest, 'destination');
	
	if (frm.dest.value.length <3) 
		setDVstyle("destination", "stFormCellTextError");
		else t++;
		
	if (t == 2) {
		frm.action="search-hotels.php?id=1&amp;ss=1";
		frm.submit();
	}
	return false;
}

function submitsearch(){
	document.clock.action="main-search.php";
	document.clock.submit();
}

function checkSend(frm){
	t=0;
	if (frm.fname.value == "") {
		setDVstyle("inpFirst", "stFormCellTextError");
		t=500;
	}
		else
		setDVstyle("inpFirst", "stFormCellText");
	if (frm.lname.value == "") {
		setDVstyle("inpLast", "stFormCellTextError");
		t=500;
	}
		else
		setDVstyle("inpLast", "stFormCellText");
	if (frm.email.value == "") {
		setDVstyle("inpEmail", "stFormCellTextError");
		t=500;
	}
		else {
			if	(echeck(frm.email.value))
				setDVstyle("inpEmail", "stFormCellText");
				else{
					setDVstyle("inpEmail", "stFormCellTextError");
					t=500;
				}
		}
	if (t == 0) return true;
		else return false;
}

function LoadPopup(doc, w, h) {
	if (!w) w=800;
	if (!h) h=600;
	win = window.open(doc, "BC", 'status=no,toolbar=0,scrollbars=1,menubar=0,titlebar=0,resizable=0,width='+w+',height='+h);
	win.moveTo(screen.width/2-w/2, screen.height/2-h/2);
	win.focus();
}
