var xmlhttp;
function ued_encode(arr,current_index) {
	var query = ""
	if(typeof current_index=='undefined') current_index = '';

	if(typeof(arr) == 'object') {
		var params = new Array();
		for(key in arr) {
			var data = arr[key];
			var key_value = key;
			if(current_index) {
				key_value = current_index+"["+key+"]"
			}

			if(typeof(data) == 'object') {
				if(data.length) { //List
					for(var i=0;i<data.length; i++) {
						params.push(key_value+"[]="+ued_encode(data[i],key_value)); //:RECURSION:
					}
				} else { //Associative array
					params.push(ued_encode(data,key_value)); //:RECURSION:
				}
			} else { //String or Number
				params.push(key_value+"="+encodeURIComponent(data));
			}
		}
		query = params.join("&");
	} else {
		query = encodeURIComponent(arr);
	}

	return query;
}
function getport(str)
{	
	xmlhttp=getObject();
	if(xmlhttp==null)
	{
	alert('object not created')
	}
	
	
 	var url="includes/ajax/getport.php?str="+str

  xmlhttp.onreadystatechange=portstateChanged;
  xmlhttp.open('get',url,true)
  xmlhttp.send(null)
 }
  
function portstateChanged() 
{ 
if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete")
 { 
//var sp=xmlhttp.responseText.split(",");
 document.getElementById("port").innerHTML = xmlhttp.responseText;
	  } 
}

function get_result()
{	
	xmlhttp=getObject();
	if(xmlhttp==null)
	{
	alert('object not created')
	}
	 document.getElementById("get_result").innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='includes/ajax/ajax_loading6.gif'>"

	var destination_id=document.getElementById("destination_id").value
	var port_id=document.getElementById("port_id").value
 	var url="includes/ajax/shore_details.php?destination_id="+destination_id+"&port_id="+port_id;
		
  xmlhttp.onreadystatechange=get_resultstateChanged;
  xmlhttp.open('get',url,true)
  xmlhttp.send(null)
 }
  

function show_detail(str)
{	
	xmlhttp=getObject();
	if(xmlhttp==null)
	{
	alert('object not created')
	}
	var destination_id=document.getElementById("destination_id").value
	var port_id=document.getElementById("port_id").value
 	var url="includes/ajax/show_details.php?destination_id="+destination_id+"&port_id="+port_id+"&str="+str;
  xmlhttp.onreadystatechange=show_detailstateChanged;
  xmlhttp.open('get',url,true)
  xmlhttp.send(null)
 }
  
function show_detailstateChanged() 
{ 
if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete")
 { 
//var sp=xmlhttp.responseText.split(",");
 document.getElementById("get_result").innerHTML = xmlhttp.responseText;
	  } 
}


function show_direct(str)
{	
	xmlhttp=getObject();
	if(xmlhttp==null)
	{
	alert('object not created')
	}
	var destination_id=str;
	
 	var url="includes/ajax/show_direct.php?destination_id="+destination_id;
  xmlhttp.onreadystatechange=show_directstateChanged;
  xmlhttp.open('get',url,true)
  xmlhttp.send(null)
 }
  
function show_directstateChanged() 
{ 
if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete")
 { 
//var sp=xmlhttp.responseText.split(",");
 document.getElementById("get_result").innerHTML = xmlhttp.responseText;
	  } 
}

function get_result_direct(loc_id,port_id)
{	
	xmlhttp=getObject();
	if(xmlhttp==null)
	{
	alert('object not created')
	}
	 document.getElementById("get_result").innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='includes/ajax/ajax_loading6.gif'>"
	
	var destination_id=loc_id
	var port_id=port_id
 	var url="includes/ajax/shore_details.php?destination_id="+destination_id+"&port_id="+port_id;
  xmlhttp.onreadystatechange=get_resultstateChanged;
  xmlhttp.open('get',url,true)
  xmlhttp.send(null)
 }
  
function get_resultstateChanged() 
{  
if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete")
 { 
var sp=xmlhttp.responseText.split("~");

 document.getElementById("get_result").innerHTML = sp[0];
 document.getElementById("heading").innerHTML = sp[1];
 document.getElementById("ext").innerHTML = sp[2];


	  } 
}


function getObject(handler)
{
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;
}


