//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Your Browser doesn't support AJAX!\nIt's about time to upgrade don't you think?");
	}
}

//Our XmlHttpRequest object to get the auto suggest
var searchReq = getXmlHttpRequestObject();
var requestFrom;

<!--------------------------------- BEGIN TRACK CHANGES for Reference NO------------------------------------------>
//Called from keyup on the search textbox.
//Starts the AJAX request.
function nameinit(val) {
	
	if (searchReq.readyState == 4 || searchReq.readyState == 0) {
	// alert(val);
		  searchReq.open('post', 'searchbyname10.asp');
	
	    searchReq.onreadystatechange = nameSearch;
  
	     var N 
	
		 if((val == "Button2") || (val == "Button1")){
		  
		       //  alert("inside button");
				N = escape(document.namesearch.firstname.value);

                 //   if(N.toUpperCase() == "SAUDI%20ARABIA"   || N.toUpperCase() == "SAUDI" || N.toUpperCase() == "DAMMAM") {
                  //         return ;
                  //          }
 		      
			
				if((N.toUpperCase() == "USA") || (N.toUpperCase() == "US") || (N.toUpperCase() == "AMERICA")) {
			   
	               N = "united%20states%20of%20america" ;
				 //  alert("N :"+N);
			   
        } else if (N.toUpperCase() == "MADRAS") {
										
				    N = "chennai";	
					
				} else if (N.toUpperCase() == "DELHI") {
										
				    N = "NEW%20DELHI";	
					
				}
								
				if((N == "") || (N.length < 2) ) {
			    redirect();
		      return	
				}
								
		   } else {
			   
			   N = val  ;
			 
			   requestFrom = "SubPage"; 
		   }
		   
		   if(val == "Button1")
		   {
			requestFrom = "MainPage";   
			document.location.href = "subpage_agencysearch2.asp?" + N;
		   } else if(val == "Button2")
		   {
			requestFrom = "SubPage";   
		   } else 
		   {
			   requestFrom = "SubLink"; 
		   }
		   
		 // alert("Value of N : "+N);
	    //without the header the post will not be read by the server
	    searchReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');  
		searchReq.send('last_value=' + N );	
		
	}		
}

//Called when the AJAX response is returned.
function nameSearch() {

	if (searchReq.readyState == 4) {
		  var response = searchReq.responseText;

		  // alert(requestFrom);
		   
		   
		   
		  // document.location.href = "subpage_agencysearch2.asp";
		   
 		//   document.getElementById("persondetails").innerHTML = response;

         //  document.getElementById("Layer1").style.visibility = "visible";
		
//alert("Emirates Shipping Line");
		/*
		  // alert(response);
		   	  var windowW=800 // wide
			  var windowH=500 // high
			  var windowX = 260 // from left
			  var windowY = 100 // from top
          // alert(windowW);
		   s = "width="+windowW+",height="+windowH;
            //window.open("sample.html",null, "height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");
                var title =  "Emirates Shipping Line"
				NFW = window.open("","popFrameless","height=800,width=950,status=no,toolbar=no,menubar=no,scrollbars=yes");
				NFW.blur();
				window.focus();
      		    NFW.resizeTo(windowW,windowH);
		        NFW.moveTo(windowX,windowY);
		      var frameString=""+
		"<html>"+
		"<head>"+
		"<title>"+title+"</title>"+
		"</head>"+
		"<LINK href='css/style.css' type=text/css rel=stylesheet>"+
		"<style type='text/css'>  body {  margin-left: 0px; margin-top: 0px; }</style>"+
		"<body> "+response+"<p><a href='javascript:self.close()' class='txtboxsm'>Close</a></p></body>"+
"</html>";
NFW.document.open();
NFW.document.write(frameString);
NFW.focus();
//NFW.document.close();
//redirect();
		*/	
			
    loadwindow('index.html',600,400)
    Show(response);
			
	}
}

<!--------------------------------- End of Reference No ------------------------------------------>




function redirect()
{
  document.location.href = "subpage_agencysearch2.asp";
}

function Show(val)
{	
  var testFrame = document.getElementById("cframe");
        		
  var doc = testFrame.contentDocument;

  if (doc == undefined || doc == null)
    doc = testFrame.contentWindow.document;
    
  doc.open();
  doc.write(val);
  doc.close();     

  document.getElementById('cframe').style.visibility="visible";
}


function ButtonShowMsg_onclick() {
  var v = document.all("txtContent").value;
  Show(v);
}
