

	var b_dom,http
	
	//called by body->onLoad, will not be invoked if javascript is disabled
	function searchinit()
	{
	
		
		http = false;
		b_dom = false;
		
		//got DOM?
		if( document.getElementById && document.createElement )
		{
			//yes!
			b_dom = true
		
			//AJAX only if got DOM
			if( window.ActiveXObject )	//IE
			{
				http = new ActiveXObject("Microsoft.XMLHTTP"); 
			}
			else
			if( window.XMLHttpRequest )	//FF,NS and OP
			{
				http = new XMLHttpRequest();
			}
			//else http remains uninintialised and therefore can't be used
		}
		httpGo2();
 	}
	
	
	function enc(s) 
	{
		s = s.replace(/\+/g, '%2B');
		s = s.replace(/\ /g, '+');
		s = escape(s)
		s = s.replace(/\"/g,'%22');
		s = s.replace(/\'/g, '%27');
		s = s.replace(/\//g,'%2F');
		return s;
	}
	
	
	function httpGo2() 
	{
	    	 var C
		var box = document.ctrySearchForm.txtCountry;
        C = escape(box.options[box.selectedIndex].value);
		
		if (C == escape("UNITED STATES OF AMERICA")) {
		http.open('post', 'searchagency_usa2.asp');
	    http.onreadystatechange = handleResponse2;				
						
		} else {
						
	    http.open('post', 'searchagency4.asp');
	    http.onreadystatechange = handleResponse2;
     // alert("hha");
		}
	 
		/*
		if(C == escape("HONG KONG S.A.R") || C == escape("UNITED STATES OF AMERICA") || C == "BAHRAIN-BH" || C == "BANGLADESH-BD"  || C == "CAMBODIA-KH" || C == "CANADA-CA"  || C == "CHINA-CN"  || C == "EGYPT-EG" || C == "FRANCE-FR" || C == "GERMANY-DE" || C == "JORDAN-JO" || C == "LEBANON-LB"  || C == "MOROCCO-MA" || C == "PAKISTAN-PK" || C == "QATAR-QA" || C == "SOUTH KOREA-KR" || C == "SRI LANKA-LK" || C == "TURKEY-TR") {
		   
		 // alert("Under process for finalization ");
		   
		   
		   var ret = "";
ret = ret + "<table width='100%'><tr><td class='contenttext' >";
ret = ret + "Awaiting announcement of service . ";

ret = ret + "</td></tr></table>";

document.getElementById("errormsg").innerHTML = ret;
//document.getElementById("Layer3").display = bold;
 document.getElementById("Layer3").style.visibility = "visible";
 
 */

   if(C != escape("")) {
			   
	    var L
		var box1 = document.ctrySearchForm.txtLocation;
        L = escape(box1.options[box1.selectedIndex].text);
	//	alert("C : "+C+ "  L : "+L);		
			   	
		var D
		var box2 = document.ctrySearchForm.txtDept;
        D = escape(box2.options[box2.selectedIndex].text);
        
		
		var N
		N = escape(document.ctrySearchForm.txtblno.value);
		
	  //  d = enc(document.forms.f.i_date.value);
	   // m = enc(document.forms.f.i_mssg.value);
	   
	   
	   
	   
	    http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');  
		//http.send('last_value=' + n );	
		//alert("C : "+C+" L : "+L+" D : "+D+" N : "+N);
	    http.send('i_country=' + C + '&i_Location=' + L + '&i_Dept=' + D + '&i_Name=' + N);	
		//alert('i_country=' + C + '&i_Location=' + L + '&i_Dept=' + D + '&i_Name=' + N);
		// var ss = document.getElementById('txtBookingNo_info')
	   // ss.style.visibility = "visible";
	   
   }    else {
	   
			   
			      var ret = "";
                 ret = ret + "<table width='100%'><tr><td class='contenttext' >";
                 ret = ret + "Awaiting announcement of service . ";

                    ret = ret + "</td></tr></table>";

                    document.getElementById("errormsg").innerHTML = ret;
                   
                  document.getElementById("Layer3").style.visibility = "visible";
		   
		   
		   
		   
		   return false;
	     }
	   
	   
	  
	   
	   
	   
	}
	
	function handleResponse2() 
	{
	    if(http.readyState == 4)
	    {
	        var response = http.responseText;
			//alert(http.responseText);
           	//i send pre-formatted HTML back, so we just dump it into the page
	       // document.getElementById('txtBookingNo_info').innerHTML = " <FONT color=#ff0000><b> " + response +"</b></font>";
		 /*
		      var windowW=800 // wide
			  var windowH=800 // high
			  var windowX = 260 // from left
			  var windowY = 100 // from top
         
		      s = "width="+windowW+",height="+windowH;
              var title =  "Emirates shipping Line"
			  NFW = window.open("","popFrameless","height=800,width=800,status=no,toolbar=no,scrollbars=yes,menubar=no");
			  NFW.blur();
			  window.focus();
      		  NFW.resizeTo(windowW,windowH);
		      NFW.moveTo(windowX,windowY);
		      var frameString=""+
  		      "<html>"+
 		      "<head>"+
		      "<title>"+title+"</title>"+
  		      "</head>"+
		      "<body>"+response+"<p><a href='javascript:self.close()'>Close</a></p></body>"+
              "</html>";
              NFW.document.open();
              NFW.document.write(frameString);
              NFW.focus();
            //NFW.document.close();
			*/
				
			loadwindow('index.html',600,400)
Show(response);
	       
	    }
	}

	//generic input checking and highlighting function, depends on consistent naming of form
	//inputs and labels, could easily be changed to work for both the DOM and non DOM cases
	//but really it's just me showing off
	function checkinput( e , b )
	{
		var te;
		te = document.getElementById("l_" + e)
		if( document.forms.f["i_" + e].value == "" )
		{
			te.style.fontWeight = "bold";
			te.style.color = "red";
			return false;
		}
		else
		{
			te.style.fontWeight = "normal";
			te.style.color = "black";
			return b;
		}
	}
	
	//this is where the form checking actually takes place
	function verify()
	{
		httpGo1();
	}	


function Show(val)
{
	
	  //alert("1");
        var testFrame = document.getElementById("cframe");
		
        var doc = testFrame.contentDocument;
	//	  alert("2");
        if (doc == undefined || doc == null)
            doc = testFrame.contentWindow.document;
        doc.open();
	//	  alert("3");
        doc.write(val);
	//	doc.write("hello");
		//  alert("4");
        doc.close();     
		//  alert("5");

      document.getElementById('cframe').style.visibility="visible";
}


function ButtonShowMsg_onclick() {
var v = document.all("txtContent").value;
Show(v);
}
