


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){
	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 fixE(e) {
	if (!e && window.event) e = window.event;
	if (!e.target) e.target = e.srcElement;
	return e;
}


 