	function initMenu(element,sub){	
		for(var i=0; i<element.childNodes.length; i++) {
			node = element.childNodes[i];
			node.myparent=element;
			if (node.nodeName=="LI") {
					node.sub=sub;
					node.onmouseover=function() {
						try {
							for( var x = 0; this.childNodes[x]; x++ ){
								if( this.childNodes[x].tagName == 'UL' ) { 
									this.childNodes[x].style.display="block";
									if(IE6){
										if(this.childNodes[x].childNodes[0].childNodes[0].innerHTML=="Profiles"){
											this.childNodes[x].style.marginLeft="-43px";
										}
										if(this.childNodes[x].childNodes[0].childNodes[0].innerHTML=="Grad Scheme"){
											this.childNodes[x].style.marginLeft="-123px";
										}
									}
									this.childNodes[x].style.zIndex="30"; 
								}
							}
						} 
						catch(e) {}
					}
					node.onmouseout=function() {
						try {
							for( var x = 0; this.childNodes[x]; x++ ){
								if( this.childNodes[x].tagName == 'UL' ) { 
									this.childNodes[x].style.display="none"; 
								}
							}
						} 
						catch(e) {}
					}
					
					for( var x = 0; x<node.childNodes.length; x++ ){
						if( node.childNodes[x].tagName == 'A'){ 
							node.childNodes[x].myparent=node;
							if(sub){
								node.childNodes[x].onmouseover=function(){
								}	
								node.childNodes[x].onmouseout=function(){
								}
								node.childNodes[x].onclick=function(){
									this.myparent.myparent.myparent.onmouseout(); 
								}
								
							}
							else{
								node.childNodes[x].onmouseover=function(){
								}	
								node.childNodes[x].onmouseout=function(){
								}
					
							}		
						}
						if( node.childNodes[x].tagName == 'UL' ) { 
							node.childNodes[x].myparent=node;
							initMenu(node.childNodes[x],true);
						}						
					}			

			}	
		}
	}
	function clearLinks(){
		if (document.links) {
			try {
				for (var i=0;i < document.links.length;i++) {
					document.links[i].onfocus=function(){
						this.blur();
					}
				}
			} 
			catch(e) {}
		}
	}	
	startList = function() {
			navRoot = document.getElementById("nav");
			initMenu(navRoot,false);
			clearLinks();
	}
	window.onload=startList;

if (window.external && (typeof window.XMLHttpRequest == "undefined")) {
	var IE6=true;
}	
else{
	var IE6=false;
}



function over_map(but, img) {
  if (document.images) {
    var map_over = new Image();
    map_over.src = "http://www.bgtraveller.com/img/maps/"+img;
    document[but].src = map_over.src
  }
} 
function out_map(but, img) {
  if (document.images) {
    var map_out = new Image();
	map_out.src = "http://www.bgtraveller.com/img/maps/"+img;
    document[but].src = map_out.src
  }
} 


function imgRoll(imgName, imgSrc) {
   document[imgName].src = imgSrc;
}


function butRoll(butName, bgImage, fontColor) {
   document[butName].style.backgroundImage = bgImage;
   document[butName].style.color = fontColor;
}


function createPopUp(rank, lat, lon, posTop) {
	var div = document.createElement('div');
	div.setAttribute("id","popUp");
	//div.setAttribute("style","width: 870px; height: 480px; padding: 0;");
	div.style.width = "704px";
	div.style.height = "480px";
	div.style.padding = "0px";
	div.style.top = posTop+"%";
	div.style.border = "1px solid #000";
	//div.appendChild(document.createTextNode('Hello World'));
	document.body.appendChild(div);
				
	var mapframe = document.createElement('iframe');
	mapframe.setAttribute("src","http://www.bgtraveller.com/gmap.php?rank="+rank+"&lat="+lat+"&lon="+lon);
	mapframe.setAttribute("width","704px");
	mapframe.setAttribute("height","454px");
	mapframe.setAttribute("framespacing","0");
	mapframe.setAttribute("frameborder","0");
	mapframe.frameBorder = 0; //sets frameborder for IE

	mapframe.setAttribute("marginheight","0");
	mapframe.setAttribute("marginwidth","0");
	mapframe.setAttribute("scrolling","no");
	div.appendChild(mapframe);
				
	var markerA = document.createElement('a');
	markerA.setAttribute("onclick","this.parentNode.parentNode.removeChild(this.parentNode);");
	markerA.style.cursor = "pointer";
	//markerA.setAttribute("href",page);
	markerA.appendChild(document.createTextNode("Затворете картата"));
	div.appendChild(markerA);
}

function createPopUp2(rank, lat, lon, posTop, url, zl) {
	var div = document.createElement('div');
	div.setAttribute("id","popUp");
	//div.setAttribute("style","width: 870px; height: 480px; padding: 0;");
	div.style.width = "704px";
	div.style.height = "480px";
	div.style.padding = "0px";
	div.style.top = posTop+"%";
	div.style.border = "1px solid #000";
	//div.appendChild(document.createTextNode('Hello World'));
	document.body.appendChild(div);
				
	var mapframe = document.createElement('iframe');
	mapframe.setAttribute("src","http://www.bgtraveller.com/"+url+".php?rank="+rank+"&lat="+lat+"&lon="+lon+"&zl="+zl);
	mapframe.setAttribute("width","704px");
	mapframe.setAttribute("height","454px");
	mapframe.setAttribute("framespacing","0");
	mapframe.setAttribute("frameborder","0");
	mapframe.frameBorder = 0; //sets frameborder for IE

	mapframe.setAttribute("marginheight","0");
	mapframe.setAttribute("marginwidth","0");
	mapframe.setAttribute("scrolling","no");
	div.appendChild(mapframe);
				
	var markerA = document.createElement('a');
	markerA.setAttribute("onclick","this.parentNode.parentNode.removeChild(this.parentNode);");
	markerA.style.cursor = "pointer";
	//markerA.setAttribute("href",page);
	markerA.appendChild(document.createTextNode("Затворете картата"));
	div.appendChild(markerA);
}


function createPopUp3(rank, lat, lon, posTop, url, zl) {
	var div = document.createElement('div');
	div.setAttribute("id","popUp");
	//div.setAttribute("style","width: 870px; height: 480px; padding: 0;");
	div.style.width = "704px";
	div.style.height = "480px";
	div.style.padding = "0px";
	div.style.top = posTop+"%";
	div.style.border = "1px solid #000";
	//div.appendChild(document.createTextNode('Hello World'));
	document.body.appendChild(div);
				
	var mapframe = document.createElement('iframe');
	mapframe.setAttribute("src","http://www.bgtraveller.com/"+url+".php?rank="+rank+"&lat="+lat+"&lon="+lon+"&zl="+zl);
	mapframe.setAttribute("width","704px");
	mapframe.setAttribute("height","454px");
	mapframe.setAttribute("framespacing","0");
	mapframe.setAttribute("frameborder","0");
	mapframe.frameBorder = 0; //sets frameborder for IE

	mapframe.setAttribute("marginheight","0");
	mapframe.setAttribute("marginwidth","0");
	mapframe.setAttribute("scrolling","no");
	div.appendChild(mapframe);
				
	var markerA = document.createElement('a');
	markerA.setAttribute("onclick","this.parentNode.parentNode.removeChild(this.parentNode);");
	markerA.style.cursor = "pointer";
	//markerA.setAttribute("href",page);
	markerA.appendChild(document.createTextNode("Close map"));
	div.appendChild(markerA);
}



// Hotel Enquiry Form
function new_captcha()
{
var c_currentTime = new Date();
var c_miliseconds = c_currentTime.getTime();

document.getElementById('captcha').src = 'http://www.bgtraveller.com/formenq/image.php?x='+ c_miliseconds;
}


function validate(field_name, field_value)
{
switch (field_name)
{
	// E-MAIL

    case "email":
	
	
	if (field_value == null || field_value == "")
    {
    document.getElementById("email_status").innerHTML = '<div class="field_error">'+ email_enter +'</div>';
    }
    else 
	{
        if(!regIsEmail(field_value)) 
	    {
        document.getElementById("email_status").innerHTML = '<div class="field_error">'+ email_not_valid +'</div>';
        }
	    else
		{
		document.getElementById("email_status").innerHTML = '';
		}
    }
    break;

    // NAME

	case "name":



    if (field_value == null || field_value == "")
    {
    document.getElementById("name_status").innerHTML = '<div class="field_error">'+ name_enter +'</div>';
    }
    else 
	{
    document.getElementById("name_status").innerHTML = '';
    }
    break;

	// SUBJECT

	case "subject":


    if (field_value == null || field_value == "")
    {
    document.getElementById("subject_status").innerHTML = '<div class="field_error">'+ subject_enter +'</div>';
    }
    else 
	{
    document.getElementById("subject_status").innerHTML = '';
    }
    break;

    // MESSAGE

	case "message":


    if (field_value == null || field_value == "")
    {
    document.getElementById("message_status").innerHTML = '<div class="field_error">'+ message_enter +'</div>';
    }
    else 
	{
    document.getElementById("message_status").innerHTML = '';
    }
    break;
}

return true;
}

function regIsEmail(field_value)
{
var reg = new RegExp("^[0-9a-zA-Z]+@[0-9a-zA-Z]+[\.]{1}[0-9a-zA-Z]+[\.]?[0-9a-zA-Z]+$");
return reg.test(field_value);
}


function goToHP(page) {
       url = 'http://www.bgtraveller.com/'+page+'.php';
       location.href=url;
}

function showCitySubP(page) {
       url = 'http://www.bgtraveller.com/'+page+'.html';
       location.href=url;
}

function goBookingP(hn) {
       url = 'http://www.bgtraveller.com/sc/hotelpage.php?hn='+hn;
       location.href=url;
}

function goBookingPen(hn) {
       url = 'http://www.bgtraveller.com/sc/hotelpageen.php?hn='+hn;
       location.href=url;
}


function goExtW(name, dom) {
	   var domTypes = ['com', 'net', 'info', 'bg'];
       url = 'http://www.'+name+'.'+domTypes[dom];
	   window.open(url)
       //location.href=url;
}

function goExtW2(url) {
       url2 = 'http://'+url;
	   window.open(url2)
       //location.href=url;
}

