

//ordonare
  
  
  //-------- adauga elemente din partea stanga in partea dreapta
  function stanga_dreapta(m1, m2) {
  m1len = m1.length ;
    for ( i=0; i<m1len ; i++){
      if (m1.options[i].selected == true ) {
        m2len = m2.length;
        m2.options[m2len]= new Option(m1.options[i].text, m1.options[i].value);
      }
    }
  
    for ( i = (m1len -1); i>=0; i--){
      if (m1.options[i].selected == true ) {
        m1.options[i] = null;
      }
    }
  }
  
  //-------- adauga elemente din partea dreapta in partea stanga
  function dreapta_stanga(m1, m2) {
  m2len = m2.length ;
    for ( i=0; i<m2len ; i++){
      if (m2.options[i].selected == true ) {
        m1len = m1.length;
        m1.options[m1len]= new Option(m2.options[i].text, m2.options[i].value);
      }
    }
    for ( i=(m2len-1); i>=0; i--) {
      if (m2.options[i].selected == true ) {
        m2.options[i] = null;
      }
    }
  }
  
  //-------- selecteaza elementele din "selectul" din dreapta si din stanga; +validari
  function selecteaza(m1, m2) {
    if(m1.length > 0 && m2.length == 0) {
      alert ('Nu ai selectat nimic!');
      m1.focus();
      return false;
    }
    else {
      //face ca toate elementele din meniul "select" din dreapta sa fie selctate
      for (i=0; i<m2.length; i++) {
        m2.options[i].selected = true;
      }
      //face ca toate elementele din meniul "select" din stanga sa fie selctate
      for (i=0; i<m1.length; i++) {
        m1.options[i].selected = true;
      }
    }
  }



//redirect functions

function ChangeUrl(url)
{
	location.href=url;
}

function MM_openBrWindow(theURL,winName,features)
{ 
  window.open(theURL,winName,features);
}

function BRB_PHP_DelWithCon(deletepage_url,field_name,field_value,messagetext) 
{ 
  if (confirm(messagetext)==1)
  {
  	location.href = eval('\"'+deletepage_url+'?'+field_name+'='+field_value+'\"');
  }
}

function BRB_PHP_DelWithCon_2_variables(deletepage_url,field_name, field_name2 ,field_value,field_value2,messagetext) 
{ 
  if (confirm(messagetext)==1)
  {
  	location.href = eval('\"'+deletepage_url+'?'+field_name+'='+field_value+'&'+field_name2+'='+field_value2+'\"');
  }
}

function BRB_PHP_DelWithCon_ajax(field_value,messagetext) 
{ 
  if (confirm(messagetext)==1)
  {
  	//location.href = eval('\"'+deletepage_url+'?'+field_name+'='+field_value+'\"');
	restore_backup(field_value);  
  }
}

//ajax
var menu=1;
var limba='ro';
function show_form(id) {
	if(document.getElementById('form_rest_'+id).style.display=="none") document.getElementById('form_rest_'+id).style.display="block";
	else document.getElementById('form_rest_'+id).style.display="none";
}
function show_form_en(id) {
	if(document.getElementById('form_rest_en_'+id).style.display=="none") document.getElementById('form_rest_en_'+id).style.display="block";
	else document.getElementById('form_rest_en_'+id).style.display="none";
}
function show_right(id) {
	if(limba=='ro') {
		lng='';
	}
	else lng='_en';
	for(i=1;i<=3;i++)
	{
		document.getElementById('lnk_r'+i).className="inactive";
		document.getElementById('div_r'+i).style.display="none";
		document.getElementById('div_r_en'+i).style.display="none";
	}
	document.getElementById('lnk_r'+id).className="activeblue";
	document.getElementById('div_r'+lng+id).style.display="block";
	menu=id;
}
function switch_lang(lng) {
	limba=lng;
	if(limba=='ro') {
		lng_tb='';
	}
	else lng_tb='_en';
	if(lng=="ro") {
		for(i=1;i<=3;i++) {
			document.getElementById('div_r'+i).style.display="none";
			document.getElementById('div_r_en'+i).style.display="none";
		}
	document.getElementById('div_r'+lng_tb+menu).style.display="block";
	document.getElementById('lnk_ro').className="active_lb";
	document.getElementById('lnk_en').className="inactive_lb";
	}
	else if(lng=="en") {
		for(i=1;i<=3;i++) {
			document.getElementById('div_r_en'+i).style.display="none";
			document.getElementById('div_r'+i).style.display="none";
		}
	document.getElementById('div_r'+lng_tb+menu).style.display="block";
	document.getElementById('lnk_ro').className="inactive_lb";
	document.getElementById('lnk_en').className="active_lb";
	}
}
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
function MM_openBrWindow(theURL,winName,features)
{ 
  newWindow=window.open(theURL,winName,features);
  newWindow.focus();
}

	  function getXmlHttpRequestObject() 
	  {
			if (window.XMLHttpRequest) 
			{
				return new XMLHttpRequest(); //Not IE
			} 
			else if(window.ActiveXObject) 
			{
				return new ActiveXObject("Microsoft.XMLHTTP"); //IE
			} 
			else 
			{
				alert("Your browser doesn't support the XmlHttpRequest object.  Better upgrade to Firefox.");
			}
	  }			
	  
      var http = getXmlHttpRequestObject();

	  function abonare_newsletter(email, name) 
	  {
		  document.getElementById('newslttr').innerHTML='<b>Va rugam asteptati</b><br><img src=\'images/loading.gif\' border=\'0\' align=\'middle\'><br>';
		  http.open('get', 'newsletter.php?email='+email+'&nume='+name, true);
          http.onreadystatechange = handleResponse_newsletter;
          http.send(null);
      }
       
      function handleResponse_newsletter() 
	  {
          if(http.readyState == 4)
		  {
              var response = http.responseText;
			  document.getElementById('newslttr').innerHTML = response;
          }
      }
	  
	  var what="";
      function change(value,where,hotel) 
	  {
		  what=where;
		  if(document.getElementById('city_'+what))
		  {
			  document.getElementById('city_'+what).innerHTML='';
			   if(document.getElementById('aerop_'+what)) document.getElementById('aerop_'+what).innerHTML='<select name="aerop_'+what+'" class="input" disabled></select>';
			  if(hotel=='1')
			  {
				  if(document.getElementById('hotel')) document.getElementById('hotel').innerHTML='<select name="hotel" class="input" disabled></select>';
			  	  http.open('get', 'sel_city.php?id='+value+"&where=arr&hotel=1", true);
			  }
			  else if(hotel=='2')
			  {
				  if(document.getElementById('sejur')) document.getElementById('sejur').innerHTML='<select name="sejur" class="input" disabled></select>';
			  	  http.open('get', 'sel_city.php?id='+value+"&where=arr&hotel=2", true);
			  }
			  else
			  {
			  	  http.open('get', 'sel_city.php?id='+value+"&where="+what, true);
			  }
			  http.onreadystatechange = handleResponse_change;
			  http.send(null);
		  }
      }
       
      function handleResponse_change() 
	  {
          if(http.readyState == 4)
		  {
              var response = http.responseText;
			  document.getElementById('city_'+what).innerHTML = response;
          }
      }
	  var what="";
      function change_2(value,where) 
	  {
		  what=where;
		  if(document.getElementById('aerop_'+what))
		  {
			  document.getElementById('aerop_'+what).innerHTML='';
			  http.open('get', 'sel_aerop.php?id='+value+"&where="+what, true);
			  http.onreadystatechange = handleResponse_change_2;
			  http.send(null);
		  }
      }
       
      function handleResponse_change_2() 
	  {
          if(http.readyState == 4)
		  {
              var response = http.responseText;
			  document.getElementById('aerop_'+what).innerHTML = response;
          }
      }
	  var what="";
      function change_3(value,where,hotel) 
	  {
		  what=where;
		  if(document.getElementById('country_'+what))
		  {
			  if(document.getElementById('city_'+what)) document.getElementById('city_'+what).innerHTML='<select name="city_'+what+'" class="input" disabled></select>';
			  if(document.getElementById('aerop_'+what)) document.getElementById('aerop_'+what).innerHTML='<select name="aerop_'+what+'" class="input" disabled></select>';
			  if(document.getElementById('country_'+what)) document.getElementById('country_'+what).innerHTML='';
			  if(hotel=='1')
			  {
				  if(document.getElementById('hotel')) document.getElementById('hotel').innerHTML='<select name="hotel" class="input" disabled></select>';
				  http.open('get', 'sel_country.php?id='+value+"&where="+what+"&hotel=1", true);
			  }
			  else if(hotel=='2')
			  {
				  if(document.getElementById('sejur')) document.getElementById('sejur').innerHTML='<select name="sejur" class="input" disabled></select>';
				  http.open('get', 'sel_country.php?id='+value+"&where=arr&hotel=2", true);
			  }
			  else
			  {
				  http.open('get', 'sel_country.php?id='+value+"&where="+what, true);
			  }
			  http.onreadystatechange = handleResponse_change_3;
			  http.send(null);
		  }
      }
       
      function handleResponse_change_3() 
	  {
          if(http.readyState == 4)
		  {
              var response = http.responseText;
			  document.getElementById('country_'+what).innerHTML = response;
          }
      }

      function select_transport(value) 
	  {
		  document.getElementById('transport_div').innerHTML='';
	      http.open('get', 'transport.php?value='+value, true);
		  http.onreadystatechange = handleResponse_select_transport;
		  http.send(null);
      }
       
      function handleResponse_select_transport() 
	  {
          if(http.readyState == 4)
		  {
              var response = http.responseText;
			  document.getElementById('transport_div').innerHTML = response;
          }
      }

      function change_hotel(value,where) 
	  {
		  what=where;
		  if(document.getElementById('hotel'))
		  {
			  document.getElementById('hotel').innerHTML='';
			  http.open('get', 'sel_hotel.php?id='+value, true);
			  http.onreadystatechange = handleResponse_change_hotel;
			  http.send(null);
		  }
      }
       
      function handleResponse_change_hotel() 
	  {
          if(http.readyState == 4)
		  {
              var response = http.responseText;
			  document.getElementById('hotel').innerHTML = response;
          }
      }
	  
      function sel_sejur() 
	  {
		  if(document.getElementById('city_arr'))
		  {
			  if(document.getElementById('city_arr').value!="0")
			  {
				  change_sejur(document.getElementById('city_arr').value);
			  }
		  }
	  }
	  
	  function change_sejur(value) 
	  {
		  if(document.getElementById('sejur'))
		  {
			  document.getElementById('sejur').innerHTML='';
			  http.open('get', 'sel_sejur.php?id='+value+"&tip="+document.getElementById('tip_sej').value, true);
			  http.onreadystatechange = handleResponse_change_sejur;
			  http.send(null);
		  }
      }
       
      function handleResponse_change_sejur() 
	  {
          if(http.readyState == 4)
		  {
              var response = http.responseText;
			  document.getElementById('sejur').innerHTML = response;
          }
      }
	  
      function change_to_sejur(value) 
	  {
		  if(document.getElementById('pret'))
		  {
			  document.getElementById('pret').value='';
			  http.open('get', 'sel_sejur_pret.php?id='+value, true);
			  http.onreadystatechange = handleResponse_change_to_sejur;
			  http.send(null);
		  }
      }
       
      function handleResponse_change_to_sejur() 
	  {
          if(http.readyState == 4)
		  {
              var response = http.responseText;
			  arr=response.split("_");
			  document.getElementById('pret').value = arr[0];
			  if(arr[1]=="Eur")
			  {
				   document.getElementById('moneda_eur').checked=true;
				   document.getElementById('moneda_ron').checked=false;
			  }
			  else
			  {
				   document.getElementById('moneda_eur').checked=false;
				   document.getElementById('moneda_ron').checked=true;
			  }
          }
      }
function ajax(strURL,ar) {qstr='';for(var i in ar){if(qstr!=''){qstr+='&';};qstr+=String('a'+i+'='+ar[i]);};var xmlHttpReq=false;var self=this;if(window.XMLHttpRequest){self.xmlHttpReq=new XMLHttpRequest();}else if(window.ActiveXObject){self.xmlHttpReq=new ActiveXObject("Microsoft.XMLHTTP");};self.xmlHttpReq.open('POST',strURL,true);self.xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');self.xmlHttpReq.onreadystatechange=function(){if (self.xmlHttpReq.readyState==4){eval(self.xmlHttpReq.responseText);}};self.xmlHttpReq.send(qstr);}