<!--
var countrydef="";
var citydef="";

function resetfromto()
{
  document.formr.localita.options.length = 0;
  document.formr.form_arrival_destination.options.length = 0;
  document.formr.localita.options[0] = new Option('Please select...','0');
  document.formr.form_arrival_destination.options[0] = new Option('Please select...','0');
  document.formr.localita.selectedIndex=0; 
  document.formr.form_arrival_destination.selectedIndex=0;
  document.formr.book_btn.disabled = true;
  if( document.getElementById('LABELPRICE') )
   document.getElementById('LABELPRICE').innerHTML = '';
  if( document.getElementById('LABELONPRICE') )
   document.getElementById('LABELONPRICE').innerHTML = '-';
  if( document.getElementById('LABELDES') )
   document.getElementById('LABELDES').innerHTML = ' ';
  if( document.getElementById('LABELBAG') )
   document.getElementById('LABELBAG').innerHTML = '';

   document.getElementById('triptime').innerHTML = "";
   document.getElementById('code').value = "";

}

function selupdate( selnum,val )
{
  var xmlHttp;
  try
  {
    /* Firefox, Opera 8.0+, Safari */                             
    xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
    /* newer IE */
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      /* older IE */
      try
      {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e)
      {
       alert("Your browser is old and does not have AJAX support!");
       return false;
      }
    }
  }

xmlHttp.onreadystatechange=function()
  {
    if(xmlHttp.readyState==4)
    {
     //alert (xmlHttp.responseText);
	 var reparr=xmlHttp.responseText.split(",");

	 if( reparr[0] == 0 )
	 {
	  document.formr.state_region.options.length = 0;
      document.formr.state_region.options[0] = new Option('Please select...','0');
      x=1;
	  for(i = 1;i < reparr.length;i+=2)
	  {
    	  document.formr.state_region.options[x] = new Option(reparr[i+1],reparr[i]);

   		   if( countrydef.length > 0 && reparr[i].substring(0, countrydef.length) == countrydef )		  
		    document.formr.state_region.selectedIndex = x;

		  x++;
	  }
	 } // 0
	 else if( reparr[0] == 1 )
	 {
 	  selectMenu = document.getElementById('form_arrival_location');
	  clearoptgroup(selectMenu);	
 	  selectMenu = document.getElementById('form_arrival_destination');
	  clearoptgroup(selectMenu);	

	  document.formr.localita.options.length = 0;
      document.formr.localita.options[0] = new Option('Please select...','0');
  	  document.formr.form_arrival_location.options.length = 0;
      document.formr.form_arrival_location.options[0] = new Option('Please select...','0');
	  document.formr.form_arrival_destination.options.length = 0; 
      document.formr.form_arrival_destination.options[0] = new Option('Please select...','0');
      x=1; 
	  for(i = 1;i < reparr.length;i+=2)
	  {
    	   document.formr.localita.options[x] = new Option(reparr[i+1],reparr[i]);
		   
   		   if( citydef.length > 0 && reparr[i+1].substring(0, citydef.length) == citydef )
		    document.formr.localita.selectedIndex = x;

		   x++;
	  } 	   
	 } // 1
	 else if( reparr[0] == 2 )
	 {
  	  //document.body.style.cursor = 'wait';
	  var appendnow = false;
	  var appendbefore = 0;
      var tot_optgroup = 0;
 	  selectMenu = document.getElementById('form_arrival_destination');
	  clearoptgroup(selectMenu);	
	  selectMenu = document.getElementById('form_arrival_location');
	  clearoptgroup(selectMenu);	
	  document.formr.form_arrival_location.options.length = 0;
      document.formr.form_arrival_location.options[0] = new Option('Please select...','0');
	  document.formr.form_arrival_destination.options.length = 0; 
      document.formr.form_arrival_destination.options[0] = new Option('Please select...','0');
	  x=1;
	  for(i = 1;i < reparr.length;i+=3)
	  {
	     if( reparr[i] == 1 )
		 {
    	   document.formr.form_arrival_location.options[x] = new Option(reparr[i+2],reparr[i+1]);
   		   x++;
		 } 
		 else if( reparr[i] == 0 )
		 {
		      var optgroup = document.createElement('optgroup');
			  if (reparr[i+2]=="null")
			  {
			  	optgroup.label = "---"; //'label';
			  }
			  else
			  {
			  	optgroup.label = reparr[i+2]; //'label';
			  }
			  optgroup.style.color = '#cc0000';
			  appendbefore = x+tot_optgroup;
			  appendnow = true;
			  tot_optgroup++;
		 }  

		 if( reparr[i] == 1 && appendnow  )
		 {
		  selectMenu.insertBefore(optgroup,selectMenu.childNodes[appendbefore]);
		  appendnow = false;
		 }  
	  }
	 } // 2
	 else if( reparr[0] == 3 )
	 {
      var appendbefore = 0;
      var tot_optgroup = 0;

		 /* if( val.indexOf('irport') > 0 )
		 lbtime = "Flight scheduled arrival time";
			else
		 lbtime = "Pickup time";
		 document.getElementById('arrtimelb').innerHTML = lbtime; */

	  selectMenu = document.getElementById('form_arrival_destination');
	  clearoptgroup(selectMenu);
	  document.formr.form_arrival_destination.options.length = 0;
      document.formr.form_arrival_destination.options[0] = new Option('Please select...','0');
      x=1;
	  for(i = 1;i < reparr.length;i+=3)
	  {
	     if( reparr[i] == 1 )
		 {
    	   document.formr.form_arrival_destination.options[x] = new Option(reparr[i+2],reparr[i+1]);
   		   x++;
		 }
		 else if( reparr[i] == 0 )
		 {
		      var optgroup = document.createElement('optgroup');
			  if (reparr[i+2]=="null")
			  {
			  	optgroup.label = "---"; //'label';
			  }
			  else
			  {
			  	optgroup.label = reparr[i+2]; //'label';
			  }
			  optgroup.style.color = '#cc0000';
			  appendbefore = x+tot_optgroup;
			  appendnow = true;
			  tot_optgroup++;
		}

		if( reparr[i] == 1 && appendnow  )
		{
		  selectMenu.insertBefore(optgroup,selectMenu.childNodes[appendbefore]);
		  appendnow = false;
		}  
	  }
	 } // 3

	 if( reparr[0] == 0 || reparr[0] == 6 )
	  return;

	 ckprice();
    }
  }

if( selnum == 0 )
  a = xmlHttp.open("GET","/getquote_ext.php?q=0&p="+new Date().getTime(),true);
else if( selnum < 3 )
	     a = xmlHttp.open("GET","/getquote_ext.php?q="+selnum+"&l="+val+"&p="+new Date().getTime(),true);
else if ( selnum == 3 )
{
    fromloc  = document.getElementById('localita').value;
    a = xmlHttp.open("GET","/getquote_ext.php?q="+selnum+"&l="+fromloc+"&f="+val+"&p="+new Date().getTime(),true);
}

  xmlHttp.send(null);

}

function ckprice()
{
	var pricepaxelement=null;
	pricepaxelement=document.getElementById('priceperpax');
		 
    from = document.getElementById('form_arrival_location').value;
	to = document.getElementById('form_arrival_destination').value;
	pax = document.getElementById('form_total_passengers').value;
	bag_1 = document.getElementById('bag_1').value;
	bag_2 = document.getElementById('bag_2').value;
	bag_3 = document.getElementById('bag_3').value; 

/*if( to.indexOf('irport') > 0 )
	  lbtime = "Flight scheduled arrival time";
	  else
	  lbtime = "Pickup time";
	 document.getElementById('rtimelb').innerHTML = lbtime;*/

    onewayreturn = 1;   
    if( document.formr.onewayreturn[1].checked )
     onewayreturn = 2;
    form_arrival_time_h = document.getElementById('form_arrival_time_h').value;
    form_return_time_h = document.getElementById('form_return_time_h').value;

	if( onewayreturn == 1 )
	{
	 document.getElementById('form_return_time_h').disabled = true;
 	 document.getElementById('form_return_time_m').disabled = true;
	}
	else
	{
	 document.getElementById('form_return_time_h').disabled = false;
 	 document.getElementById('form_return_time_m').disabled = false;
	}


//b = parseInt(bag_1) + parseInt(bag_2) + parseInt(bag_3);
//alert(from+'\n'+to+pax+'\n'+b+'\n'+form_arrival_time_h);

if( from != '0' && to != '0' && pax > 0 && parseInt(bag_1) + parseInt(bag_2) + parseInt(bag_3) > 0 && form_arrival_time_h != -1 )
	{
      if( onewayreturn == 2 && form_return_time_h == -1 )
	  {
		 if (pricepaxelement != null)
		 {
			 pricepaxelement.innerHTML="(please enter return time)";
		 }
		 document.getElementById('LABELONPRICE').innerHTML = "-";
 	 	 document.getElementById('LABELDES').innerHTML = "";
 	 	 document.getElementById('LABELBAG').innerHTML = "";
		 document.getElementById('triptime').innerHTML = "";
 	 	 document.getElementById('code').value = "";
   		 document.formr.book_btn.disabled = true;
		 document.formr.action = "/";

	     return;
	  }

	  var xmlHttp;
	  try
	  {
    	/* Firefox, Opera 8.0+, Safari */
	    xmlHttp=new XMLHttpRequest();
	  }
	  catch (e)
	  {
    	/* newer IE */
	    try
	    {
	      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    }
	    catch (e) 
	    {
	      /* older IE */
	      try
	      {
	        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	      }
	      catch (e)
	      {
	        alert("Your browser is old and does not have AJAX support!");
	        return false;
	      }
	    }
	  }

	  xmlHttp.onreadystatechange=function()
	  {
	    if(xmlHttp.readyState==4)
	    {
	     //alert  (xmlHttp.responseText);
		 var reparr=xmlHttp.responseText.split(",");

		 if(reparr[0]== '99')
		  return;

		 document.getElementById('LABELONPRICE').innerHTML = reparr[1];
 	 	 document.getElementById('LABELDES').innerHTML = reparr[2];
 	 	 document.getElementById('LABELBAG').innerHTML = reparr[3];
		 document.getElementById('triptime').innerHTML = reparr[4];
 	 	 document.getElementById('code').value = reparr[6];
  		 document.formr.book_btn.disabled = false;
		 document.formr.action = reparr[5];
		 
		 if (pricepaxelement != null)
		 {
			if (reparr[1].length>2)
			{
				var currency;
				var price;
					
				price=reparr[1].substring(0,reparr[1].search(" "));
				currency=reparr[1].substring(reparr[1].search(" ")+1,reparr[1].length);
				pricepaxelement.innerHTML="<strong>(" + Math.round((price/pax)*Math.pow(10,2))/Math.pow(10,2) + " " + currency + " per person)</strong>";
			}
		 }
			
     	}
	  }

	  a = xmlHttp.open("GET","/getquote_ext.php?q=6&f="+from+"&t="+to+"&pa="+pax+"&b1="+bag_1+"&b2="+bag_2+"&b3="+bag_3+"&or="+onewayreturn+"&at="+form_arrival_time_h+"&rt="+form_return_time_h+"&p="+new Date().getTime(),true);
	  xmlHttp.send(null);
 }
else
 {
		 if (pricepaxelement != null)
		 {
			 if (from == 0) pricepaxelement.innerHTML="(please enter pickup place)";
			 else if (to == 0) pricepaxelement.innerHTML="(please enter destination place)";
			 else if (pax == 0) pricepaxelement.innerHTML="(please enter passengers)";
			 else if (parseInt(bag_1) + parseInt(bag_2) + parseInt(bag_3) == 0) pricepaxelement.innerHTML="(please enter luggage)";
			 else if (form_arrival_time_h == -1)
			 	{
					if (onewayreturn == 2) pricepaxelement.innerHTML="(please enter going time)"; else pricepaxelement.innerHTML="(please enter one way time)"
				}
			 else 
			 pricepaxelement.innerHTML="(please fill-out the form above)";
		 }
	 	 document.getElementById('LABELONPRICE').innerHTML = "-";
 	 	 document.getElementById('LABELDES').innerHTML = "";
 	 	 document.getElementById('LABELBAG').innerHTML = "";
		 document.getElementById('triptime').innerHTML = "";
 	 	 document.getElementById('code').value = "";
  		 document.formr.book_btn.disabled = true;

		 document.formr.action = "/";
 }
}

function clearoptgroup(selectMenu)
{
  //selectMenu = document.getElementById(sel_name);
  optl = selectMenu.offsetWidth;

  while (selectMenu.hasChildNodes())
  {
    selectMenu.removeChild(selectMenu.firstChild);
  }
}


function selupdateandselect( selnum, val, tomatch )
{
  var xmlHttp;
  try
  {
    /* Firefox, Opera 8.0+, Safari */                             
    xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
    /* newer IE */
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      /* older IE */
      try
      {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e)
      {
       alert("Your browser is old and does not have AJAX support!");
       return false;
      }
    }
  }

xmlHttp.onreadystatechange=function()
  {
    if(xmlHttp.readyState==4)
    {
     //alert (xmlHttp.responseText);
	 var reparr=xmlHttp.responseText.split(",");

	 if( reparr[0] == 0 )
	 {
	  document.formr.state_region.options.length = 0;
      document.formr.state_region.options[0] = new Option('Please select...','0');
      x=1;
	  for(i = 1;i < reparr.length;i+=2)
	  {
    	  	document.formr.state_region.options[x] = new Option(reparr[i+1],reparr[i]);
			if(reparr[i+1] == tomatch) document.formr.state_region.selectedIndex = x;
		  	x++;
	  }
	  
	 } // 0
	 else if( reparr[0] == 1 )
	 {
 	  selectMenu = document.getElementById('form_arrival_location');
	  clearoptgroup(selectMenu);	
 	  selectMenu = document.getElementById('form_arrival_destination');
	  clearoptgroup(selectMenu);	

	  document.formr.localita.options.length = 0;
      document.formr.localita.options[0] = new Option('Please select...','0');
  	  document.formr.form_arrival_location.options.length = 0;
      document.formr.form_arrival_location.options[0] = new Option('Please select...','0');
	  document.formr.form_arrival_destination.options.length = 0; 
      document.formr.form_arrival_destination.options[0] = new Option('Please select...','0');
      x=1; 
	  for(i = 1;i < reparr.length;i+=2)
	  {
    	   document.formr.localita.options[x] = new Option(reparr[i+1],reparr[i]);
		   
   		   if(reparr[i+1] == tomatch) document.formr.localita.selectedIndex = x;
		   
		   x++;
	  } 	   
	 } // 1
	 else if( reparr[0] == 2 )
	 {
  	  //document.body.style.cursor = 'wait';
	  var appendnow = false;
	  var appendbefore = 0;
      var tot_optgroup = 0;
 	  selectMenu = document.getElementById('form_arrival_destination');
	  clearoptgroup(selectMenu);	
	  selectMenu = document.getElementById('form_arrival_location');
	  clearoptgroup(selectMenu);	
	  document.formr.form_arrival_location.options.length = 0;
      document.formr.form_arrival_location.options[0] = new Option('Please select...','0');
	  document.formr.form_arrival_destination.options.length = 0; 
      document.formr.form_arrival_destination.options[0] = new Option('Please select...','0');
	  x=1;
	  for(i = 1;i < reparr.length;i+=3)
	  {
	     if( reparr[i] == 1 )
		 {
    	   document.formr.form_arrival_location.options[x] = new Option(reparr[i+2],reparr[i+1]);
   		   if(reparr[i+2] == tomatch) document.formr.form_arrival_location.selectedIndex = x;
		   x++;
		   
		 } 
		 else if( reparr[i] == 0 )
		 {
		      var optgroup = document.createElement('optgroup');
			  if (reparr[i+2]=="null")
			  {
			  	optgroup.label = "---"; //'label';
			  }
			  else
			  {
			  	optgroup.label = reparr[i+2]; //'label';
			  }
			  optgroup.style.color = '#cc0000';
			  appendbefore = x+tot_optgroup;
			  appendnow = true;
			  tot_optgroup++;
		 }  

		 if( reparr[i] == 1 && appendnow  )
		 {
		  selectMenu.insertBefore(optgroup,selectMenu.childNodes[appendbefore]);
		  appendnow = false;
		 }  
	  }
	 } // 2
	 else if( reparr[0] == 3 )
	 {
      var appendbefore = 0;
      var tot_optgroup = 0;

		/* if( val.indexOf('irport') > 0 )
		 lbtime = "Flight scheduled arrival time";
			else
		 lbtime = "Pickup time";
		 document.getElementById('arrtimelb').innerHTML = lbtime; */

	  selectMenu = document.getElementById('form_arrival_destination');
	  clearoptgroup(selectMenu);
	  document.formr.form_arrival_destination.options.length = 0;
      document.formr.form_arrival_destination.options[0] = new Option('Please select...','0');
      x=1;
	  for(i = 1;i < reparr.length;i+=3)
	  {
	     if( reparr[i] == 1 )
		 {
    	   document.formr.form_arrival_destination.options[x] = new Option(reparr[i+2],reparr[i+1]);
   		   if(reparr[i+2] == tomatch) document.formr.form_arrival_destination.selectedIndex = x;
   		   x++;
		 }
		 else if( reparr[i] == 0 )
		 {
		      var optgroup = document.createElement('optgroup');
			  if (reparr[i+2]=="null")
			  {
			  	optgroup.label = "---"; //'label';
			  }
			  else
			  {
			  	optgroup.label = reparr[i+2]; //'label';
			  }
			  optgroup.style.color = '#cc0000';
			  appendbefore = x+tot_optgroup;
			  appendnow = true;
			  tot_optgroup++;
		}

		if( reparr[i] == 1 && appendnow  )
		{
		  selectMenu.insertBefore(optgroup,selectMenu.childNodes[appendbefore]);
		  appendnow = false;
		}  
	  }
	 } // 3

	 if( reparr[0] == 0 || reparr[0] == 6 )
	  return;

	 ckprice();
    }
  }

if( selnum == 0 )
  a = xmlHttp.open("GET","/getquote_ext.php?q=0&p="+new Date().getTime(),true);
else if( selnum < 3 )
	     a = xmlHttp.open("GET","/getquote_ext.php?q="+selnum+"&l="+val+"&p="+new Date().getTime(),true);
else if ( selnum == 3 )
{
    fromloc  = document.getElementById('localita').value;
    a = xmlHttp.open("GET","/getquote_ext.php?q="+selnum+"&l="+fromloc+"&f="+val+"&p="+new Date().getTime(),true);
}

  xmlHttp.send(null);

}


-->
