// JavaScript Document

// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}






function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (err2) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (err3) {
      req = false;
    }
  }
}
return req;
}

var http = getXMLHTTPRequest();

function change_location(location_id,type) {
	
  var location_id = trim(location_id);
  var type = trim(type);
  
  
  
  if(location_id != "no"){
//alert(uname);
  var myurl = 'change_transfer_locations.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand+"&location_id="+location_id+"&type="+type;
  http.open("GET", modurl, true);
  http.onreadystatechange = locationResponse;
  http.send(null);
  
  
  }else{
	  
	 	  
	  if(location_id == "no"){
	  		
	  		if(type == "starting"){
		  		alert("Select Starting Location !");
		  	}else if(type == "ending"){
		  		alert("Select Ending Location !");
		  	}
		  }
	  
	  }
	  


function locationResponse() {
   if (http.readyState == 4) {
    if(http.status == 200) {
       var mytext = http.responseText;

       
       if(type == "starting"){
		  	document.getElementById('d_ending').innerHTML = mytext;
	   }else if(type == "ending"){
		  	document.getElementById('d_starting').innerHTML = mytext;
	   }
	   
	  
    }
  } 
  
}
	  
	  

}//end of function change_location(location_id,type) {


function valid_location(location_id,type){

	if(location_id == "no"){
	  		
	  		if(type == "starting"){
		  		alert("Select Starting Location !");
		  	}else if(type == "ending"){
		  		alert("Select Ending Location !");
		  	}
		  }

}


function valid_start_end_loc(starting,ending){


			if(starting == "no"){
		  		alert("Select Starting Location !");
		  		return false;
		  	}else if(ending == "no"){
		  		alert("Select Ending Location !");
		  		return false;
		  	}else{
		  		return true;
		  	}

}

  
