var xmlHttp

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}


function show_send_friend_panel(oid)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	
	var url="actions/req_send_to_friend.php";

	url=url+"?oid="+oid;
	url=url+"&sid="+Math.random();
	
	xmlHttp.onreadystatechange=function()
		{
			show_form_send_friend();
		}
	xmlHttp.open("POST",url,true);
	xmlHttp.send(null);
}

function show_form_send_friend() 
{ 
if (xmlHttp.readyState==4)
{
	response=xmlHttp.responseText;
	elsendfriend=locate_el('sendtofriend');
	
	elsendfriend.innerHTML=response;
}
}


function trimiteprieten()
{
	
	elucn=locate_el('ucn');
	elfriendemail=locate_el('friendemail');
	elsendername=locate_el('sendername');
	elcode=locate_el('code');

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	
	var url="actions/act_send_to_friend.php";
	url=url+"?ucn="+elucn.value;
	url=url+"&friendemail="+elfriendemail.value;
	url=url+"&sendername="+elsendername.value;
	url=url+"&code="+elcode.value;
	url=url+"&sid="+Math.random();
	

	xmlHttp.onreadystatechange=function()
		{
			show_sendfrresult();
		}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function show_sendfrresult() 
{ 
if (xmlHttp.readyState==4)
{
	response=xmlHttp.responseText;
	responses=xmlHttp.responseText.split('#ER#');
	elsendfriend=locate_el('sendtofriend');
	elerrors1=locate_el('errors1');
	
	if(responses[0]=='OK')
		{
			elsendfriend.innerHTML=responses[1];	
		}
	else
		{
			elerrors1.innerHTML=responses[1];
		}
	
}
}



function req_regiune(destsel, regsel, ressel)
{
	eldestination=locate_el('destination');

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	 
	var url="actions/req_regiune.php";
	url=url+"?destination="+eldestination.options[eldestination.selectedIndex].value;
	url=url+"&destsel="+destsel;
	url=url+"&regsel="+regsel;
	url=url+"&ressel="+ressel;
	url=url+"&sid="+Math.random();
	
	elregiunea=locate_el('regiunea');

	xmlHttp.onreadystatechange=function()
		{
			show_regiune(destsel, regsel, ressel);
		}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function req_regiune_f(destsel, regsel, ressel)
{
	eldestination=locate_el('destination');

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	 
	var url="actions/req_regiune_f.php";
	url=url+"?destination="+eldestination.options[eldestination.selectedIndex].value;
	url=url+"&destsel="+destsel;
	url=url+"&regsel="+regsel;
	url=url+"&ressel="+ressel;
	url=url+"&sid="+Math.random();
	
	elregiunea=locate_el('regiunea');

	xmlHttp.onreadystatechange=function()
		{
			show_regiune_f(destsel, regsel, ressel);
		}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}



function show_regiune(destsel, regsel, ressel) 
{ 
if (xmlHttp.readyState==4)
{
	response=xmlHttp.responseText;
	responses=xmlHttp.responseText.split('#R#');
	elregiunea=locate_el('regiunea');
	elstatiunea=locate_el('statiunea');
	
	elregiunea.innerHTML=responses[0];

	if(responses[1]=='neselectat')
		{
			memoreaza(0, 'region');
		}
	else
		{
			memoreaza(regsel, 'region');
		}
	req_statiune(destsel, regsel, ressel);
}
}


function show_regiune_f(destsel, regsel, ressel) 
{ 
if (xmlHttp.readyState==4)
{
	response=xmlHttp.responseText;
	responses=xmlHttp.responseText.split('#R#');
	elregiunea=locate_el('regiunea');
	elstatiunea=locate_el('statiunea');
	
	elregiunea.innerHTML=responses[0];

	if(responses[1]=='neselectat')
		{
			memoreaza(0, 'region');
		}
	else
		{
			memoreaza(regsel, 'region');
		}
	req_statiune_f(destsel, regsel, ressel);
}
}

function req_statiune(destsel, regsel, ressel)
{
	elregion=locate_el('region2');
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	 
	var url="./actions/req_statiune.php";
	url=url+"?region="+elregion.options[elregion.selectedIndex].value;
	url=url+"&destsel="+destsel;
	url=url+"&regsel="+regsel;
	url=url+"&ressel="+ressel;
	url=url+"&sid="+Math.random();
	
	xmlHttp.onreadystatechange=function()
		{
			show_statiune(destsel, regsel, ressel);
		}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function req_statiune_f(destsel, regsel, ressel)
{
	elregion=locate_el('region2');
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	 
	var url="./actions/req_statiune_f.php";
	url=url+"?region="+elregion.options[elregion.selectedIndex].value;
	url=url+"&destsel="+destsel;
	url=url+"&regsel="+regsel;
	url=url+"&ressel="+ressel;
	url=url+"&sid="+Math.random();
	
	xmlHttp.onreadystatechange=function()
		{
			show_statiune_f(destsel, regsel, ressel);
		}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function show_statiune(destsel, regsel, ressel) 
{ 
if (xmlHttp.readyState==4)
{
	response=xmlHttp.responseText;
	responses=xmlHttp.responseText.split('#R#');
	elstatiunea=locate_el('statiunea');

	elstatiunea.innerHTML=responses[0];
	
	if(responses[1]=='neselectat')
		{
			memoreaza(0, 'resort');
		}
	else
		{
			memoreaza(ressel, 'resort');
		}

}
}

function show_statiune_f(destsel, regsel, ressel) 
{ 
if (xmlHttp.readyState==4)
{
	response=xmlHttp.responseText;
	responses=xmlHttp.responseText.split('#R#');
	elstatiunea=locate_el('statiunea');

	elstatiunea.innerHTML=responses[0];
	
	if(responses[1]=='neselectat')
		{
			memoreaza(0, 'resort');
		}
	else
		{
			memoreaza(ressel, 'resort');
		}

}
}

function memoreaza(x, nume)
{
	camp=locate_el(nume);
	camp.value=x;
}




