function divHiliteSelf(odiv)
{
	odiv.oldcolor=odiv.style.backgroundColor;
	odiv.style.backgroundColor='#F4F3F1';
}

function divUnHiliteSelf(odiv)
{
	odiv.style.backgroundColor=odiv.oldcolor;
}


function onEditBlock(nID,nAction,column_number,item_order){

	window.parent.tgmodal(nID,nAction,column_number,item_order);

	return false;
}


/*
start destination	
*/



var XmlHttpObj;
var curobj;
curobj=0;
var langid;
langid=0;



function CreateXmlHttpObj()
{
	try
	{
		XmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpObj = null;
		}
	}
	if(!XmlHttpObj && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpObj = new XMLHttpRequest();
	}
}

function ContinentListOnChange(obj) 
{

	curobj=obj;

	var objselect = "countryList" + (curobj-1);

    var continentList = document.getElementById(objselect);
    
    var selectedContinent = continentList.options[continentList.selectedIndex].value;
    
    var requestUrl;
     requestUrl = "/lib/_ajaxdata.php" + "?map_id=" + encodeURIComponent(selectedContinent) + "&langid=" + langid;
    
	CreateXmlHttpObj();
	
	if(XmlHttpObj)
	{
		XmlHttpObj.onreadystatechange = StateChangeHandler;
		
		XmlHttpObj.open("GET", requestUrl,  true);
		
		XmlHttpObj.send(null);		
	}
}


function StateChangeHandler()
{
	if(XmlHttpObj.readyState == 4)
	{
		if(XmlHttpObj.status == 200)
		{			
			PopulateCountryList(XmlHttpObj.responseXML.documentElement);
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
		}
	}
}

function PopulateCountryList(countryNode)
{


        var ocon = document.getElementById("map-con");


	for (var i = (curobj); i <4; i++){

		curdiv = "test" + i;
		var olddiv = document.getElementById(curdiv);
  		if(olddiv!=null){

	  		ocon.removeChild(olddiv);
	  	}	

	}

	var countryNodes = countryNode.getElementsByTagName('country');
	idValue = countryNodes[0].getAttribute("id");
	if(idValue==0){
		return;
	}

	curdiv = "test" + curobj;


        var odiv    = document.createElement('div');
  	odiv.setAttribute('id',curdiv);


        temp="countryList"+curobj;
	odiv.innerHTML=	'<select name="' +  temp + '" id="' + temp + '" onChange="return ContinentListOnChange('+(curobj+1)+')" ></select>';
        ocon.appendChild(odiv);

    	var countryList = document.getElementById("countryList"+curobj);

	curobj++;



	for (var count = countryList.options.length-1; count >-1; count--)
	{
		countryList.options[count] = null;
	}

	var idValue;
	var textValue; 
	var optionItem;

	optionItem = new Option( "", "",  false, false);
	countryList.options[countryList.length] = optionItem;


	for (var count = 0; count < countryNodes.length; count++)
	{
   		textValue = GetInnerText(countryNodes[count]);
		idValue = countryNodes[count].getAttribute("id");
		optionItem = new Option( textValue, idValue,  false, false);
		countryList.options[countryList.length] = optionItem;
	}
}

function GetInnerText (node)
{
	 return (node.textContent || node.innerText || node.text) ;
}

/*
end destination	
*/

function mshow(id,idm){
	//debugger;
	document.getElementById(id).className='visible';
	if(document.getElementById(idm+id).className.search("current")>0)
		document.getElementById(idm+id).className='minus current';
	else
		document.getElementById(idm+id).className='minus';
}

function mhide(id,idm){
	//debugger;
	if(document.getElementById(id)!=null)
		document.getElementById(id).className='invisible';
	if(document.getElementById(idm+id)!=null){
			if(document.getElementById(idm+id).className.search("current")>0)
				document.getElementById(idm+id).className='plus current';
			else
				document.getElementById(idm+id).className='plus';
		}	
}

function showHide(id,idm){



	if(document.getElementById(id).className=='visible'){
		mhide(id,idm);
	}
	else{

		var parent_ul=document.getElementById(id).parentElement.parentElement;	
		for (var i = 0; i < parent_ul.childNodes.length; i++) {
			if(parent_ul.childNodes[i].className=="minus" || parent_ul.childNodes[i].className=="plus current"){
				mhide(parent_ul.childNodes[i].id.substr( parent_ul.childNodes[i].id.length-2 ,2),idm);
			}
		}


		i=1;
		while(document.getElementById(id+"_"+i)){
			mhide(id+"_"+i,idm);
			i++;
		}
		mshow(id,idm);

		


	}
	return false;
}


var DomYes=document.getElementById?1:0;



function getsel(attr,opt)
{
   var selected = new Array();
   var index = 0;
   for (var intLoop = 0; intLoop < opt.length; intLoop++) {
      if ((opt[intLoop].selected) || (opt[intLoop].checked)) {
         index = selected.length;
         selected[index] = new Object;
         selected[index].value = opt[intLoop].value;
         selected[index].index = intLoop;
      }
   }

   var strSel = "";
   for (var item in selected)       
      strSel += selected[item].value + ",";

   return "*" + attr + ";" + strSel;
}



function GetParameter(querystring, param)
{
 var sValue;

 
 var start = querystring.indexOf(param) +
  param.length + 1;


if (querystring.indexOf(param)==-1)
	return "";

  var length = querystring.indexOf("&", start);

 if (length == -1)
 {
  sValue = querystring.substr(start);
 }
 else
 {
  sValue = querystring.substr(start, length - start);
 }

 sValue = sValue.replace(/\+/g, " ");

 return sValue;
}

function  DisplayImage(what,picWidth,picHeight)
{

   var done=false;
   if (!done)
   {

	var writePop = window.open('','_blank','resizable,width=50,height=50');
	
	var popTop = '';
	popTop += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n';
	popTop += '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n';
	popTop += '\n';
	popTop += '<html xmlns="http://www.w3.org/1999/xhtml" lang="sk" xml:lang="sk">\n';
	popTop += '<head>\<\script>\n';
	popTop += 'function resizeZoomer(){\n';
	popTop += 'document.getElementById(\'loading\').style.display=\'none\';\n';
	popTop += 'document.getElementById(\'image\').style.visibility=\'visible\';\n';
	popTop += 'var sizeX = document.getElementById(\'image\').offsetWidth+32;\n';
	popTop += 'var sizeY = document.getElementById(\'image\').offsetHeight+52;\n';
	popTop += 'window.resizeTo(sizeX,sizeY);\n';
	popTop += '}\<\/script>\n';
	popTop += '<title>'+document.title+'</title>\n';
	popTop += '</head>\n';
	popTop += '<body style="margin: 10px; background: #fff;" onload="resizeZoomer();">\n';
	popTop += '<img id="loading" style="display: block; margin: 10px;" src="/images/loading.gif" width="43" height="5" alt="loading" />\n';
	popTop += '<a href="javascript:window.close();"><img id="image" style="visibility: hidden;" src="' + what + '" alt="" border="0" /></a>\n';
	popTop += '</body>\n';
	popTop += '</html>\n';
	
	popRocks = writePop.document;
	popRocks.open();
	popRocks.write(popTop);
	popRocks.close();
 }
 return done;

}

function openwindow(url,width,height)
{
 window.open(url,"or","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+width+",height="+height);
 return false;
}

function launchViewer(filename,x,y)
 { 
 var done=false;
 if (!done)
 {
  window.imagex=x;
  window.imagey=y;
  window.imagename=filename;
  viewer=window.open('_z.html','VIEWER','scrollbars,status,resizable');
  viewer.opener=window;
  viewer.focus();
 }
 return done;
}

function fixE(e) {
	if (!e && window.event) e = window.event;
	if (!e.target) e.target = e.srcElement;
	return e;
}


var obj_menu = (document.all?document.all["mmenu"]:document.getElementById("mmenu"))
 if (obj_menu) {
   var m_node = obj_menu.getElementsByTagName("a")
   for (x=0;x<m_node.length;x++) {
     var lis = m_node[x].parentNode;
     if (lis ) {
       if (lis.className=="submenu"){
       	var uls = lis.getElementsByTagName("ul");
       	if (uls.length>0) {
         //if (uls[0].id=='') uls[0].style.display = "none";
         m_node[x].onclick = extract_menu;
	}       
       }
     }
   }
 }
 
 
 	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, October 2005
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/	
	var contextMenuObj;
	var MSIE = navigator.userAgent.indexOf('MSIE')?true:false;
	var navigatorVersion = navigator.appVersion.replace(/.*?MSIE (\d\.\d).*/g,'$1')/1;	
	var activeContextMenuItem = false;

	function highlightContextMenuItem()
	{
		this.className='contextMenuHighlighted';
		activeContextMenuItem = this;
	}
	
	function deHighlightContextMenuItem()
	{
		this.className='';
	}
	
	function showContextMenu(e)
	{
		if(activeContextMenuItem)activeContextMenuItem.className='';
		if(document.all)e = event;
		var xPos = e.clientX;
		if(xPos + contextMenuObj.offsetWidth > (document.documentElement.offsetWidth-20)){
			xPos = xPos + (document.documentElement.offsetWidth - (xPos + contextMenuObj.offsetWidth)) - 20;	
		}
		
		var yPos = e.clientY;
		if(yPos + contextMenuObj.offsetHeight > (document.documentElement.offsetHeight-20)){
			yPos = yPos + (document.documentElement.offsetHeight - (yPos + contextMenuObj.offsetHeight)) - 20;	
		}		
		contextMenuObj.style.left = xPos + 'px';
		contextMenuObj.style.top = yPos + 'px';
		contextMenuObj.style.display='block';
		return false;	
	}

	function hideContextMenu(e)
	{
		if(document.all) e = event;
		if(e.button==0 && !MSIE){
			
		}else{
			contextMenuObj.style.display='none';
		}
	}
	
	function initContextMenu()
	{
		contextMenuObj = document.getElementById('contextMenu');
		contextMenuObj.style.display = 'block';
		var menuItems = contextMenuObj.getElementsByTagName('LI');
		for(var no=0;no<menuItems.length;no++){
			menuItems[no].onmouseover = highlightContextMenuItem;
			menuItems[no].onmouseout = deHighlightContextMenuItem;
			
			var aTag = menuItems[no].getElementsByTagName('A')[0];
			
			var img = menuItems[no].getElementsByTagName('IMG')[0];
			if(img){
				var div = document.createElement('DIV');
				div.className = 'imageBox';
				div.appendChild(img);
				
				if(MSIE && navigatorVersion<6){
					aTag.style.paddingLeft = '0px';
				}
				
				var divTxt = document.createElement('DIV');	
				divTxt.className='itemTxt';
				divTxt.innerHTML = aTag.innerHTML;
				
				aTag.innerHTML = '';
				aTag.appendChild(div);
				aTag.appendChild(divTxt);
				if(MSIE && navigatorVersion<6){
					div.style.position = 'absolute';
					div.style.left = '2px';
					divTxt.style.paddingLeft = '15px';
				}
				
				if(!document.all){
					var clearDiv = document.createElement('DIV');
					clearDiv.style.clear = 'both';
					aTag.appendChild(clearDiv);		
				}
			}else{
				if(MSIE && navigatorVersion<6){
					aTag.style.paddingLeft = '15px';
					aTag.style.width = (aTag.offsetWidth - 30) + 'px';
				}else{
					aTag.style.paddingLeft = '30px';
					aTag.style.width = (aTag.offsetWidth - 60) + 'px';
				}
			}
		}
		contextMenuObj.style.display = 'none';		
		document.documentElement.oncontextmenu = showContextMenu;
		document.documentElement.onclick = hideContextMenu;
	}

 