﻿//------------------------------------- Body Load Function ----------------------------------------------------

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function submitMarinArea(txtId)
{
    var Id = txtId.id;
    var Name = txtId.title;
    document.getElementById("txtIdVar").value=Id;
    document.getElementById("txtNameVar").value=Name;
    document.frmTreeMain.action="treeMarinArea.aspx";
    document.frmTreeMain.submit();
}

function submitRegion(txtId)
{
    var Id = txtId.id;
    var Name = txtId.title;
    document.getElementById("txtIdVar").value=Id;
    document.getElementById("txtNameVar").value=Name;
    document.frmTreeMain.action="treeRegion.aspx";
    document.frmTreeMain.submit();
}

function showCountryList()
    {
        var Id=document.getElementById("txtId");
        return FetchCRegion(Id);
    }
    
function showPortList()
    {
        //var Id=document.getElementById("txtId");
        return FetchDataPort(document.getElementById("txtId"));
    }
    
function showDetail(prid) 
    {
     mywindow =window.open("viewDetail.aspx?pstring=" + prid ,"","menubar=0,resizable=1,width=980,height=635,toolbar=0,location=0,directories=0,status=1,scrollbars=1");     
     mywindow.moveTo(20,25);
    }
    
function showYDetail(prid) 
    {
     mywindow =window.open("viewDetail.aspx?ystring=" + prid ,"","menubar=0,resizable=1,width=980,height=635,toolbar=0,location=0,directories=0,status=1,scrollbars=1");     
     mywindow.moveTo(20,25);
    }

//---------------------------------------------- Other Important function ------------------------------------------------
    function doneAreaSearch()
     {
       if(document.getElementById("checkbox")==null) {alert("No Port is selected for result!");}
       else if(document.getElementById("txtSelectedPort").value=='0') {alert("Please select Port from list!");}
       else { document.location.href="search_Result.aspx?Splatform=" + document.getElementById("Splatform").value + "&PortString=a.PortId%20in%20("+document.getElementById("txtSelectedPort").value+")"; }
     }
     
     
    function validate() {
        var total="";
        
        if(document.getElementById("checkbox")==null)
        {
            alert("No any Port is selected for result!");            
        }
        else
        {
            for(var i=0,j=0; i < document.frmTreeMarin.checkbox.length; i++)
            {
                if(document.frmTreeMarin.checkbox[i].checked)
                {
                    if(j++ >0)
                    {
                    total +=",";
                    }
                    total +=document.frmTreeMarin.checkbox[i].value;
                }
            }   
                  
            if(total==""){
            alert("Select any Port checkbox!");            
            }
            else {
            if(document.getElementById("checkbox") != null)
            {
//                document.frmTreeMarin.method="Post";
//                document.frmTreeMarin.action="search_Result.aspx?PortString=a.PortId%20in%20("+total+")";
//                document.frmTreeMarin.submit();
                  document.location.href="search_Result.aspx?Splatform=Area&PortString=a.PortId%20in%20("+total+")"
            }else
            {
            alert('Value not present');
            }
        }
       }
    }
    
    function validate1(form) { 
        var total="";
        if(document.getElementById("checkbox")==null)
        {
            alert("No any Port is selected for result!");
            return false;
        }
        else
        {
            for(var i=0,j=0; i < document.frmTreeRegion.checkbox.length; i++)
            {
                if(document.frmTreeRegion.checkbox[i].checked)
                {
                    if(j++ >0)
                    {
                    total +=",";
                    }
                    total +=document.frmTreeRegion.checkbox[i].value;
                }
            }
        }
        if(total==""){
            alert("Select any checkbox!");
            return false; 
            }
            else {
            document.frmTreeRegion.method="Post";
            document.frmTreeRegion.action="search_Result.aspx?PortString=a.PortId%20in%20("+total+")";
            document.frmTreeRegion.submit();
        }
    }
    
 function GotoResult(plist)
   {
     document.location.href="search_Result.aspx?PortString=a.PortId%20in%20("+plist+")"   
   }
   
//--------------------------------------------------------------------------------------------------------------------

// JScript File

var XmlHttp;
//Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
function CreateXmlHttp(){
	//Creating object of XMLHTTP in IE
	try{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	   }
	catch(e){
		try{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		   } 
		catch(oc){
			XmlHttp = null;
		   }
	   }	   
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp && typeof XMLHttpRequest != "undefined"){
		XmlHttp = new XMLHttpRequest();
	  }
	  //alert(XmlHttp);
  }

//----------------------------------- For Port Load on Tree Search (treeMarinArea Page)----------------------------------
 
  function FetchDataPort(tmpObj,ObjName){    
    var tmpIdVar;
    var tmpIdVar1=tmpObj;
    var tmpIdVar2=tmpObj;   
    
    if(isNaN(tmpIdVar1)){tmpIdVar = tmpIdVar2;}
    else{tmpIdVar = tmpIdVar1;}    
    document.getElementById('txtSelectedName').value=ObjName;
     
	// URL to get data from server    
	var requestUrl = "dispPort.aspx?S=M&ID=" + encodeURIComponent(tmpIdVar) ;
	CreateXmlHttp();	
	
	if(XmlHttp){ 	
		XmlHttp.onreadystatechange = LoadDataPort;	
		XmlHttp.open("GET", requestUrl,  true);				
		XmlHttp.send(null);		
	 }
	}
  
  
function LoadDataPort(){
	if(XmlHttp.readyState == 4){
	    var a=XmlHttp.responseText;
        var ni = document.getElementById('Div_PList');
        ni.innerHTML="";		
		if(XmlHttp.status == 200){			
		if(a.length>1){  
		    addPortRow(a,"Selected Martime Area");
		    enableTooltips();		    
		    return true;}
		else{			
			alert("There is no any Port in database in this Marin Area. Please try another!" );
			return false;}
	  }
		else{
			alert("There was a problem retrieving data from the server. Please try again!" );
			return false; }
	  }
  }
  
  
  function addPortRow(str,label)
    {     
        var plist=""        
        var strRowValue = str;
		var ni = document.getElementById('Div_PList');
		ni.innerHTML="";
		var img="";
		var img1=""
		var tip="";
		var tip1="";
		var isSelected="";		

		
		var tmpSqlString="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
		tmpSqlString+="<tr><td class=\"Title\" width=\"65%\" height=\"40\" valign=\"bottom\" style=\"font: bold  12px 'Arial'; padding-bottom:5px;\">"+ label +":&nbsp;&nbsp;"
		tmpSqlString+="<span style=\"padding-left:12px;\" id=\"txtName\"></span></td>"        
        tmpSqlString +="<td class=\"Title\" width=\"20%\" align=\"center\" >&nbsp;</td>"             
        tmpSqlString +="<td width=\"15%\" align=\"center\" >&nbsp;</td></tr>"
        
        tmpSqlString +="<tr><td height=\"2\" colspan=\"4\" style=\"background-color:white\"><img  src=\"images/blank.gif\" width=\"1\" height=\"2\" alt=\"\" /></td></tr>"
        tmpSqlString +="</table>"
        
        var newdiv = document.createElement('div');
		var divIdName = 'HDMyDiv';
		newdiv.setAttribute('id',divIdName);
		newdiv.innerHTML =newdiv.innerHTML +tmpSqlString ;
		ni.appendChild(newdiv);

		var tmpstr=strRowValue.split('&');
		var tmpMainValue=tmpstr[0].split('|');
		var tmpSubPort=tmpstr[1].split('|');
		
		for(i=0,k=0; i< tmpMainValue.length -1 ;i++)
			{   
			    var tmpMainValueF=tmpMainValue[i].split('~');			    
			    if (tmpMainValueF[2]=="1") {
			      img="sp.gif";
			      tip="Speciality Port"; }
			    else {
			      img="blank.gif";	
			      tip=""; }
			    
			    if (tmpMainValueF[3]=="1") {
			      img1="cru.gif";
			      tip1="Cruise Port"; }
			    else {
			      img1="blank.gif";	
			      tip1=""; }	  
			          
    			if(findPort(tmpMainValueF[0])) 
    			    isSelected   ="checked";
    			else
    			    isSelected="";
    			    
			        var tmpSqlString = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
			        tmpSqlString+="<tr><td width=\"65%\" align=\"left\" style=\"height: 26px; border:#FFFFFF solid; border-width: 0px 2px 0px 0px; padding-left:5px\"> <a href=\"javascript:showDetail('" + tmpMainValueF[0] + "')\" class=\"Plist\"><span>" + tmpMainValueF[1]+ " </span></a></td>";
			        tmpSqlString+="<td align=\"center\" style=\"width:20%; height: 23px; border:#FFFFFF solid; border-width: 0px 2px 0px 0px; \">"
			   
			        if (tmpMainValueF[2]=="1") { tmpSqlString+="<label title=\"Speciality Port\"><img src=\"images/sp.gif\" width=\"19px\" height=\"23px\" alt=\"\"/></label>"; }
			        else if((tmpMainValueF[4]=="True") && (!isNaN(tmpMainValueF[5])) && (tmpMainValueF[5].length >0)){tmpSqlString+="<label title=\"Port Star Rating\">"; for(j=1; j<=tmpMainValueF[5]; j++){tmpSqlString+="<img src=\"images/b_star.gif\" width=\"11px\" height=\"10px\" alt=\"\"/>";} tmpSqlString+="</label>";  if(tmpMainValueF[5]=0) {tmpSqlString+="&nbsp;";}}
			        else {tmpSqlString+="&nbsp;";}
			        
			        
			        tmpSqlString+="</td>";			        
			        tmpSqlString+="<td align=\"center\" style=\"width:15%; height: 23px;\"><input type=\"checkbox\" id=\"checkbox\" name=\"checkbox\" value=\""+tmpMainValueF[0]+"\" onclick=\"addToList(this);\" " + isSelected + " /></td></tr>";
			            
			        tmpSqlString+="<tr><td height=\"2\" style=\"background-color:white;\" colspan=\"4\"><img src=\"images/blank.gif\" width=\"1\" height=\"2\" alt=\"\" /></td></tr>"
			        tmpSqlString+="</table>";
			        
			       if (plist.length >0) { plist+=","; }
			        plist+= tmpMainValueF[0]
			        
			        var newdiv = document.createElement('div');
			        var divIdName = 'MyDiv' + k++;
			        newdiv.setAttribute('id',divIdName);
			        newdiv.innerHTML =newdiv.innerHTML +tmpSqlString ;
			        ni.appendChild(newdiv);
			        
			        if(tmpSubPort.length > 1){
			        for(j=0; j < tmpSubPort.length -1; j++)
			        {
			            var tmpSubPortF=tmpSubPort[j].split('~');
			            if(tmpMainValueF[0]==tmpSubPortF[2])
    			         {
			                var tmpSqlString = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr style=\"background-color:white;\"><td width=\"65%\" align=\"left\" class=\"normalblue_space\" style=\"padding-left:45px; height: 22px; border:#FFFFFF solid; border-width: 0px 2px 0px 0px; font-weight:normal;\">~&nbsp;"+ tmpSubPortF[1]+"</td><td style=\"width:20%\" class=\"TitleAS\"><img src=\"images/blank.gif\" width=\"1\" height=\"2\" alt=\"\" /></td><td style=\"width:15%\"><img src=\"images/blank.gif\" width=\"1\" height=\"2\" alt=\"\" /></td></tr></table>";
			                var newdiv1 = document.createElement('div');
			                var divIdName1 = 'MyDiv' + k++;
			                newdiv1.setAttribute('id',divIdName1);
			                newdiv1.setAttribute('style',"padding-left:8px;");
			                newdiv1.innerHTML =newdiv1.innerHTML +tmpSqlString ;
			                ni.appendChild(newdiv1);
			             }
                        tmpSqlString = "";
                    }
                 }		    
			}
		
//		tmpSqlString = "<table width=\"500px\" height=\"50px\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"float:right\"><tr>";
//		tmpSqlString+= "<td style=\"width:160px; height:30px;\"><a href=\"javascript:ClearAll();\" class=\"b-newsearch\">New Search</a></td>";
//      tmpSqlString+= "<td style=\"width:140px; height:30px;\"><a href=\"javascript:SelectAll();\" class=\"b-small\">Select All</a></td>";
//      tmpSqlString+= "<td style=\"width:200px; height:30px;\"><a href=\"javascript:doneAreaSearch();\" class=\"b-big\">Go to Search Results</a></td>";
//		tmpSqlString+= "</tr></table>"
//		
//		var newdiv = document.createElement('div');
//		var divIdName = 'MyDivfoot';
//		newdiv.setAttribute('id',divIdName);
//		newdiv.innerHTML =newdiv.innerHTML +tmpSqlString ;
//		ni.appendChild(newdiv);		
		document.getElementById("txtName").innerHTML=document.getElementById("txtSelectedName").value;
   }
   
 function addYardRow(str,label,level)
    {     
        var plist=""        
        var strRowValue = str;
		var ni = document.getElementById('Div_PList');
		ni.innerHTML="";
		var img="";
		var img1=""
		var tip="";
		var tip1="";
		var isSelected="";		

		
		var tmpSqlString="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
		tmpSqlString+="<tr><td class=\"Title\" width=\"65%\" height=\"40\" valign=\"bottom\" style=\"font: bold  12px 'Arial'; padding-bottom:5px;\">"+ label +":&nbsp;&nbsp;"
		tmpSqlString+="<span style=\"padding-left:12px;\" id=\"txtName\"></span></td></tr>"; 
        
        tmpSqlString +="<tr><td height=\"2\" colspan=\"2\" style=\"background-color:white\"><img  src=\"images/blank.gif\" width=\"1\" height=\"2\" alt=\"\" /></td></tr>"
        tmpSqlString +="</table>"
        
        var newdiv = document.createElement('div');
		var divIdName = 'HDMyDiv';
		newdiv.setAttribute('id',divIdName);
		newdiv.innerHTML =newdiv.innerHTML +tmpSqlString ;
		ni.appendChild(newdiv);
				
		var tmpMainValue=strRowValue.split('|');		
		for(i=0,k=0; i< tmpMainValue.length -1 ;i++)
			{       var tmpMainValueF=tmpMainValue[i].split('~');
			        var tmpSqlString = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
			        tmpSqlString+="<tr><td width=\"65%\" align=\"left\" style=\"height: 26px; padding-left:5px\">"
			        
			        if (level==0){ tmpSqlString+="<a href=\"javascript:showYDetail('" + tmpMainValueF[2] + "')\" class=\"Plist\"><span>" + tmpMainValueF[1]+ " </span></a>";}
			        else if (level==1){ tmpSqlString+="<a href=\"javascript:FetchYard('" + tmpMainValueF[0] + "','"+ tmpMainValueF[1]+ "')\" class=\"Plist\"><span>" + tmpMainValueF[1]+ " </span></a>"; }
			        
			        tmpSqlString+="</td></tr>";	        			            
			        tmpSqlString+="<tr><td height=\"2\" style=\"background-color:white;\" colspan=\"2\"><img src=\"images/blank.gif\" width=\"1\" height=\"2\" alt=\"\" /></td></tr>"
			        tmpSqlString+="</table>";
			        
			        var newdiv = document.createElement('div');
			        var divIdName = 'MyDiv' + k++;
			        newdiv.setAttribute('id',divIdName);
			        newdiv.innerHTML =newdiv.innerHTML +tmpSqlString ;
			        ni.appendChild(newdiv);	                   
			}		

		document.getElementById("txtName").innerHTML=document.getElementById("txtSelectedName").value;
   }
   
  //--------------------------------------------- For Couuntry Load on Tree Search (treeRegion Page)----------------------------------
  
 function FetchCRegion(tmpObj,ObjName){
 
     var tmpRegId;
     var tmpRegId1 = tmpObj;
     var tmpRegId2 = tmpObj; 
     document.getElementById('txtSelectedName').value=ObjName;
     
     if(isNaN(tmpRegId1)){tmpRegId = tmpRegId2;}
     else{tmpRegId = tmpRegId1;}
      
	// URL to get data from server	
	var requestUrl = "dispPort.aspx?S=R&Id=" + encodeURIComponent(tmpRegId) ;
	CreateXmlHttp();	
	
	if(XmlHttp){ 
		XmlHttp.onreadystatechange = LoadCountry;	
		XmlHttp.open("GET", requestUrl,  true);	
		XmlHttp.send(null);		
	 }
 }
   
  function LoadCountry(){	
	if(XmlHttp.readyState == 4){
	    var a = XmlHttp.responseText;
        var ni = document.getElementById('Div_PList');
        ni.innerHTML="";
        
		if(XmlHttp.status == 200){
		if(a.length>0){
		    addCountry(a);
		    return true;}
		else{		
			alert("There is no any Port in database in this Marin Area. Please try another!" )
			return false;}
	 }
		else{
			alert("There was a problem retrieving data from the server. Please try again!" )
			return false;}
	  }
  }
  
  function FetchSRegion(tmpObj,ObjName){
 
     var tmpRegId;
     var tmpRegId1 = tmpObj;
     var tmpRegId2 = tmpObj;         
     
     document.getElementById('txtSelectedName').value=ObjName;     
     if(isNaN(tmpRegId1)){tmpRegId = tmpRegId2;}
     else{tmpRegId = tmpRegId1;}
      
	// URL to get data from server	
	var requestUrl = "dispSyard.aspx?S=R&Id=" + encodeURIComponent(tmpRegId) ;
	CreateXmlHttp();	
	
	if(XmlHttp){ 
		XmlHttp.onreadystatechange = LoadSCountry;		
		XmlHttp.open("GET", requestUrl,  true);			
		XmlHttp.send(null);		
	 }
 }   
  
  function LoadSCountry(){	
	if(XmlHttp.readyState == 4){
	    var a = XmlHttp.responseText;
        var ni = document.getElementById('Div_PList');
        ni.innerHTML="";
        
		if(XmlHttp.status == 200){
		if(a.length>0){
		    addSCountry(a,1);
		    return true;}
		else{		
			alert("There is no any Port in database in this Marin Area. Please try another!" )
			return false;}
	 }
		else{
			alert("There was a problem retrieving data from the server. Please try again!" )
			return false;}
	  }
  }
  
  function FetchSARegion(tmpObj,ObjName){
 
     var tmpRegId;
     var tmpRegId1 = tmpObj;
     var tmpRegId2 = tmpObj;         
     
     document.getElementById('txtSelectedName').value=ObjName;     
     if(isNaN(tmpRegId1)){tmpRegId = tmpRegId2;}
     else{tmpRegId = tmpRegId1;}
      
	// URL to get data from server	
	var requestUrl = "dispSyard.aspx?S=R&Id=" + encodeURIComponent(tmpRegId) ;
	CreateXmlHttp();	
	
	if(XmlHttp){ 
		XmlHttp.onreadystatechange = LoadSACountry;		
		XmlHttp.open("GET", requestUrl,  true);			
		XmlHttp.send(null);		
	 }
 }   
  
  function LoadSACountry(){	
	if(XmlHttp.readyState == 4){
	    var a = XmlHttp.responseText;
        var ni = document.getElementById('Div_PList');
        ni.innerHTML="";
        
		if(XmlHttp.status == 200){
		if(a.length>0){
		    addSCountry(a,2);
		    return true;}
		else{		
			alert("There is no any Port in database in this Marin Area. Please try another!" )
			return false;}
	 }
		else{
			alert("There was a problem retrieving data from the server. Please try again!" )
			return false;}
	  }
  }

function FetchCSRegion(tmpObj,ObjName){
 
     var tmpRegId;
     var tmpRegId1 = tmpObj;
     var tmpRegId2 = tmpObj; 
     document.getElementById('txtSelectedName').value=ObjName;
     
     if(isNaN(tmpRegId1)){tmpRegId = tmpRegId2;}
     else{tmpRegId = tmpRegId1;}
      
	// URL to get data from server	
	var requestUrl = "dispPort.aspx?S=CR&Id=" + encodeURIComponent(tmpRegId) ;
	CreateXmlHttp();	
	
	if(XmlHttp){ 
		XmlHttp.onreadystatechange = LoadCSCountry;	
		XmlHttp.open("GET", requestUrl,  true);	
		XmlHttp.send(null);		
	 }
 }
   
  function LoadCSCountry(){	
	if(XmlHttp.readyState == 4){
	    var a = XmlHttp.responseText;
        var ni = document.getElementById('Div_PList');
        ni.innerHTML="";
        
		if(XmlHttp.status == 200){
		if(a.length>0){
		    addCSCountry(a);
		    return true;}
		else{		
			alert("There is no any Port in database in this Marin Area. Please try another!" )
			return false;}
	 }
		else{
			alert("There was a problem retrieving data from the server. Please try again!" )
			return false;}
	  }
  }
  
  function FetchAddress(ObjName){     
      
	// URL to get data from server	
	var requestUrl = "dispPort.aspx?S=A&Id=" + encodeURIComponent(ObjName) ;
	CreateXmlHttp();	
	
	if(XmlHttp){ 
		XmlHttp.onreadystatechange = LoadAddress;	
		XmlHttp.open("GET", requestUrl,  true);	
		XmlHttp.send(null);		
	 }
 }
   
  function LoadAddress(){	
	if(XmlHttp.readyState == 4){
	    var a = XmlHttp.responseText;
        var ni = document.getElementById('Div_PList');
        ni.innerHTML="";
        
		if(XmlHttp.status == 200){
		if(a.length>0){
		    addAddress(a);
		    return true;}
		else{		
			alert("There is no any Port in database in this Marin Area. Please try another!" )
			return false;}
	 }
		else{
			alert("There was a problem retrieving data from the server. Please try again!" )
			return false;}
	  }
  }
//---------------------------------------------- for Country -------------------------------------------------------
function addAddress(str)
{   
        var strRowVal = str;
    	var newdiv = document.createElement('div');
		var ni = document.getElementById('Div_PList');
		ni.innerHTML="";
                
//		var tmpSqlString="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"73%\" height=\"40\" valign=\"bottom\" style=\"padding-left:10px;font: bold  12px 'Arial'; padding-bottom:10px;\">Selected Region:&nbsp;&nbsp;"
//        tmpSqlString +="<span id=\"txtName\" style=\"padding-left:12px;\"></span></td></tr></table>"
//        
//        var newdiv = document.createElement('div');
//		var divIdName = 'HDMyDiv';
//		newdiv.setAttribute('id',divIdName);
//		newdiv.innerHTML =newdiv.innerHTML +tmpSqlString ;
//		ni.appendChild(newdiv);
		
		var tmpGetValue=strRowVal;
		var tmpGetValue1=tmpGetValue.split('|');
		
		var tmpGetValue2="";
		var tmpSqlString = "<table width=\"100%\" border=\"0\" cellpadding=\"2px\" cellspacing=\"2px\">";
		//for(i=0; i< tmpGetValue1.length -1 ; i++)
		//{					
		    tmpGetValue2=tmpGetValue1[0].split('~');
		    
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td width=\"40%\" style=\"padding-left:20px;padding-top:20px;\" class=\"txtgryhd\">Office:</td>";		    
		    tmpSqlString += "<td width=\"60%\" style=\"padding-left:10px;padding-top:20px;\" class=\"big\">" +tmpGetValue2[0]+"</td>";		    
		    tmpSqlString += "</tr>";
		    
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">Street:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\">" +tmpGetValue2[1]+"</td>";		    
		    tmpSqlString += "</tr>";
		    
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">City:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\">" +tmpGetValue2[2]+"</td>";		    
		    tmpSqlString += "</tr>";
		    
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">Country:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\">" +tmpGetValue2[4]+"</td>";		    
		    tmpSqlString += "</tr>";
		    
		    tmpSqlString=tmpSqlString+"<tr style=\"height:30px; vertical-align:bottom;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">Business Hours:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\">" +tmpGetValue2[5]+"</td>";		    
		    tmpSqlString += "</tr>";
		    
		    tmpSqlString=tmpSqlString+"<tr style=\"height:30px; vertical-align:top;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\"></td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"medium\"><i>" +tmpGetValue2[18]+"</i></td>";		    
		    tmpSqlString += "</tr>";
		    
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">Toll free telephone:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\">" +tmpGetValue2[6]+"</td>";		    
		    tmpSqlString += "</tr>";
		    
		    if(tmpGetValue2[7].length >0){
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">Phone 1:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\">" +tmpGetValue2[7]+"</td>";		    
		    tmpSqlString += "</tr>";	}	 
		    if(tmpGetValue2[8].length >0){   
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">Phone 2:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\">" +tmpGetValue2[8]+"</td>";		    
		    tmpSqlString += "</tr>"; }
		    if(tmpGetValue2[9].length >0){
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">Phone 3:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\">" +tmpGetValue2[9]+"</td>";		    
		    tmpSqlString += "</tr>";}
		    if(tmpGetValue2[10].length >0){		    
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">Phone 4:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\">" +tmpGetValue2[10]+"</td>";		    
		    tmpSqlString += "</tr>";}
		    if(tmpGetValue2[11].length >0){
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">Phone 5:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\">" +tmpGetValue2[11]+"</td>";		    
		    tmpSqlString += "</tr>";}
		    
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">E-mail:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\"><a href='mailto:"+tmpGetValue2[12]+ "'>" +tmpGetValue2[12]+"</a></td>";		    
		    tmpSqlString += "</tr>";
		    
		    tmpSqlString=tmpSqlString+"<tr style=\"height:28px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px; vertical-align:bottom;\" class=\"txtgryhd\" colspan=\"2\">After Hours:</td>";		    		    
		    tmpSqlString += "</tr>";
		    
		    if(tmpGetValue2[13].length >0){
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">Phone 1:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\">" +tmpGetValue2[13]+"</td>";		    
		    tmpSqlString += "</tr>"; }
		    
		    if(tmpGetValue2[14].length >0){
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">Phone 2:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\">" +tmpGetValue2[14]+"</td>";		    
		    tmpSqlString += "</tr>"; }
		    
		    if(tmpGetValue2[15].length >0){
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">Phone 3:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\">" +tmpGetValue2[15]+"</td>";		    
		    tmpSqlString += "</tr>"; }
		    
		    if(tmpGetValue2[16].length >0){
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">Phone 4:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\">" +tmpGetValue2[16]+"</td>";		    
		    tmpSqlString += "</tr>"; }
		    
		    if(tmpGetValue2[17].length >0){
		    tmpSqlString=tmpSqlString+"<tr style=\"height:18px;\">";
		    tmpSqlString += "<td style=\"padding-left:20px;\" class=\"txtgryhd\">Phone 5:</td>";		    
		    tmpSqlString += "<td style=\"padding-left:10px;\" class=\"big\">" +tmpGetValue2[17]+"</td>";		    
		    tmpSqlString += "</tr>"; }
		    
		    
		    
		// }
		    tmpSqlString += "</table>";
			var divIdName = 'MyDiv0';
		    newdiv.setAttribute('id',divIdName);
		    newdiv.innerHTML =newdiv.innerHTML +tmpSqlString ;
		    ni.appendChild(newdiv);			
			//document.getElementById("txtName").innerHTML=document.getElementById("txtSelectedName").value;
}

function addCSCountry(str)
{   
        var strRowVal = str;
    	var newdiv = document.createElement('div');
		var ni = document.getElementById('Div_PList');
		ni.innerHTML="";
                
		var tmpSqlString="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"73%\" height=\"40\" valign=\"bottom\" style=\"padding-left:10px;font: bold  12px 'Arial'; padding-bottom:10px;\">Selected Region:&nbsp;&nbsp;"
        tmpSqlString +="<span id=\"txtName\" style=\"padding-left:12px;\"></span></td></tr></table>"
        
        var newdiv = document.createElement('div');
		var divIdName = 'HDMyDiv';
		newdiv.setAttribute('id',divIdName);
		newdiv.innerHTML =newdiv.innerHTML +tmpSqlString ;
		ni.appendChild(newdiv);
		
		var tmpGetValue=strRowVal;
		var tmpGetValue1=tmpGetValue.split('|');
		
		var tmpGetValue2="";
		var tmpSqlString = "<table width=\"100%\" border=\"0\" cellpadding=\"2px\" cellspacing=\"2px\">";
		for(i=0; i< tmpGetValue1.length -1 ;)
		{
			tmpSqlString=tmpSqlString+"<tr style=\"height:20px;\">";
			if(i< tmpGetValue1.length -1 ){
		    tmpGetValue2=tmpGetValue1[i++].split('~');
		    tmpSqlString += "<td width=\"33%\" style=\"padding-left:20px;\"><a href=\"javascript:FetchAddress(" + tmpGetValue2[0] + ")\" class=\"Clist\" id=\""+tmpGetValue2[0]+"\" title=\""+tmpGetValue2[1]+"\">"+ tmpGetValue2[1].replace(/z/i,"") +"</a></td>";
		    }
		    if(i< tmpGetValue1.length -1 ){
		    tmpGetValue2=tmpGetValue1[i++].split('~');
		    tmpSqlString += "<td width=\"33%\" style=\"padding-left:10px;\"><a href=\"javascript:FetchAddress(" + tmpGetValue2[0] + ")\" class=\"Clist\" id=\""+tmpGetValue2[0]+"\" title=\""+tmpGetValue2[1]+"\">"+ tmpGetValue2[1].replace(/z/i,"")  +"</a></td>";
		    }
		    if(i< tmpGetValue1.length -1 ){
		    tmpGetValue2=tmpGetValue1[i++].split('~');
		    tmpSqlString += "<td width=\"34%\" style=\"padding-left:10px;\"><a href=\"javascript:FetchAddress(" + tmpGetValue2[0] + ")\" class=\"Clist\" id=\""+tmpGetValue2[0]+"\" title=\""+tmpGetValue2[1]+"\">"+ tmpGetValue2[1].replace(/z/i,"")  +"</a></td>";
		    }	
		    tmpSqlString += "</tr>";
		 }
		    tmpSqlString += "</table>";
			var divIdName = 'MyDiv0';
		    newdiv.setAttribute('id',divIdName);
		    newdiv.innerHTML =newdiv.innerHTML +tmpSqlString ;
		    ni.appendChild(newdiv);			
			document.getElementById("txtName").innerHTML=document.getElementById("txtSelectedName").value;
}

function addCountry(str)
{   
        var strRowVal = str;
    	var newdiv = document.createElement('div');
		var ni = document.getElementById('Div_PList');
		ni.innerHTML="";
                
		var tmpSqlString="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"73%\" height=\"40\" valign=\"bottom\" style=\"padding-left:10px;font: bold  12px 'Arial'; padding-bottom:10px;\">Selected Region:&nbsp;&nbsp;"
        tmpSqlString +="<span id=\"txtName\" style=\"padding-left:12px;\"></span></td></tr></table>"
        
        var newdiv = document.createElement('div');
		var divIdName = 'HDMyDiv';
		newdiv.setAttribute('id',divIdName);
		newdiv.innerHTML =newdiv.innerHTML +tmpSqlString ;
		ni.appendChild(newdiv);
		
		var tmpGetValue=strRowVal;
		var tmpGetValue1=tmpGetValue.split('|');
		
		var tmpGetValue2="";
		var tmpSqlString = "<table width=\"100%\" border=\"0\" cellpadding=\"2px\" cellspacing=\"2px\">";
		for(i=0; i< tmpGetValue1.length -1 ;)
		{
			tmpSqlString=tmpSqlString+"<tr style=\"height:20px;\">";
			if(i< tmpGetValue1.length -1 ){
		    tmpGetValue2=tmpGetValue1[i++].split('~');
		    tmpSqlString += "<td width=\"33%\" style=\"padding-left:20px;\"><a href=\"javascript:FetchCPort(" + tmpGetValue2[0] + ",\'" + tmpGetValue2[1] + "')\" class=\"Clist\" id=\""+tmpGetValue2[0]+"\" title=\""+tmpGetValue2[1]+"\">"+ tmpGetValue2[1] +"</a></td>";
		    }
		    if(i< tmpGetValue1.length -1 ){
		    tmpGetValue2=tmpGetValue1[i++].split('~');
		    tmpSqlString += "<td width=\"33%\" style=\"padding-left:10px;\"><a href=\"javascript:FetchCPort(" + tmpGetValue2[0] + ",\'" + tmpGetValue2[1] + "')\" class=\"Clist\" id=\""+tmpGetValue2[0]+"\" title=\""+tmpGetValue2[1]+"\">"+ tmpGetValue2[1] +"</a></td>";
		    }
		    if(i< tmpGetValue1.length -1 ){
		    tmpGetValue2=tmpGetValue1[i++].split('~');
		    tmpSqlString += "<td width=\"34%\" style=\"padding-left:10px;\"><a href=\"javascript:FetchCPort(" + tmpGetValue2[0] + ",\'" + tmpGetValue2[1] + "')\" class=\"Clist\" id=\""+tmpGetValue2[0]+"\" title=\""+tmpGetValue2[1]+"\">"+ tmpGetValue2[1] +"</a></td>";
		    }	
		    tmpSqlString += "</tr>";
		 }
		    tmpSqlString += "</table>";
			var divIdName = 'MyDiv0';
		    newdiv.setAttribute('id',divIdName);
		    newdiv.innerHTML =newdiv.innerHTML +tmpSqlString ;
		    ni.appendChild(newdiv);			
			document.getElementById("txtName").innerHTML=document.getElementById("txtSelectedName").value;
}

function addSCountry(str,level)
{   
        var strRowVal = str;
    	var newdiv = document.createElement('div');
		var ni = document.getElementById('Div_PList');
		ni.innerHTML="";
                
		var tmpSqlString="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"73%\" height=\"40\" valign=\"bottom\" style=\"padding-left:10px;font: bold  12px 'Arial'; padding-bottom:10px;\">Selected Region:&nbsp;&nbsp;"
        tmpSqlString +="<span id=\"txtName\" style=\"padding-left:12px;\"></span></td></tr></table>"
        
        var newdiv = document.createElement('div');
		var divIdName = 'HDMyDiv';
		newdiv.setAttribute('id',divIdName);
		newdiv.innerHTML =newdiv.innerHTML +tmpSqlString ;
		ni.appendChild(newdiv);
		
		var tmpGetValue=strRowVal;
		var tmpGetValue1=tmpGetValue.split('|');
		
		var tmpGetValue2="";
		var tmpSqlString = "<table width=\"100%\" border=\"0\" cellpadding=\"2px\" cellspacing=\"2px\">";
		for(i=0; i< tmpGetValue1.length -1 ;)
		{
			tmpSqlString=tmpSqlString+"<tr style=\"height:20px;\">";
			if(i< tmpGetValue1.length -1 ){
		    tmpGetValue2=tmpGetValue1[i++].split('~');
		    if(level == 1) {tmpSqlString += "<td width=\"33%\" style=\"padding-left:20px;\"><a href=\"javascript:FetchCAYard(" + tmpGetValue2[0] + ",\'" + tmpGetValue2[1] + "')\" class=\"Clist\" id=\""+tmpGetValue2[0]+"\" title=\""+tmpGetValue2[1]+"\">"+ tmpGetValue2[1] +"</a></td>";}
		    if(level == 2) {tmpSqlString += "<td width=\"33%\" style=\"padding-left:20px;\"><a href=\"javascript:FetchCYard(" + tmpGetValue2[0] + ",\'" + tmpGetValue2[1] + "')\" class=\"Clist\" id=\""+tmpGetValue2[0]+"\" title=\""+tmpGetValue2[1]+"\">"+ tmpGetValue2[1] +"</a></td>";}
		    }
		    if(i< tmpGetValue1.length -1 ){
		    tmpGetValue2=tmpGetValue1[i++].split('~');
		    if(level == 1) {tmpSqlString += "<td width=\"33%\" style=\"padding-left:10px;\"><a href=\"javascript:FetchCAYard(" + tmpGetValue2[0] + ",\'" + tmpGetValue2[1] + "')\" class=\"Clist\" id=\""+tmpGetValue2[0]+"\" title=\""+tmpGetValue2[1]+"\">"+ tmpGetValue2[1] +"</a></td>";}
		    if(level == 2) {tmpSqlString += "<td width=\"33%\" style=\"padding-left:10px;\"><a href=\"javascript:FetchCYard(" + tmpGetValue2[0] + ",\'" + tmpGetValue2[1] + "')\" class=\"Clist\" id=\""+tmpGetValue2[0]+"\" title=\""+tmpGetValue2[1]+"\">"+ tmpGetValue2[1] +"</a></td>";}
		    }
		    if(i< tmpGetValue1.length -1 ){
		    tmpGetValue2=tmpGetValue1[i++].split('~');
		    if(level == 1) {tmpSqlString += "<td width=\"34%\" style=\"padding-left:10px;\"><a href=\"javascript:FetchCAYard(" + tmpGetValue2[0] + ",\'" + tmpGetValue2[1] + "')\" class=\"Clist\" id=\""+tmpGetValue2[0]+"\" title=\""+tmpGetValue2[1]+"\">"+ tmpGetValue2[1] +"</a></td>";}
		    if(level == 2) {tmpSqlString += "<td width=\"34%\" style=\"padding-left:10px;\"><a href=\"javascript:FetchCYard(" + tmpGetValue2[0] + ",\'" + tmpGetValue2[1] + "')\" class=\"Clist\" id=\""+tmpGetValue2[0]+"\" title=\""+tmpGetValue2[1]+"\">"+ tmpGetValue2[1] +"</a></td>";}
		    }	
		    tmpSqlString += "</tr>";
		 }
		    tmpSqlString += "</table>";
			var divIdName = 'MyDiv0';
		    newdiv.setAttribute('id',divIdName);
		    newdiv.innerHTML =newdiv.innerHTML +tmpSqlString ;
		    ni.appendChild(newdiv);			
			document.getElementById("txtName").innerHTML=document.getElementById("txtSelectedName").value;
}

//---------------------------------------------- for Country Port List ------------------------------------------
function FetchCPort(tmpObj,ObjName){ 
     var tmpPortId = tmpObj;    
    document.getElementById('txtSelectedName').value=ObjName; 
 
	// URL to get data from server	
	var requestUrl = "dispPort.aspx?S=C&Id=" + encodeURIComponent(tmpPortId) ;
	
	CreateXmlHttp();		
	if(XmlHttp){ 
		XmlHttp.onreadystatechange = LoadCPort;		
		XmlHttp.open("GET", requestUrl,  true);	
		XmlHttp.send(null);		
	 }
	 
 }
 
function LoadCPort(){
	if(XmlHttp.readyState == 4){
	    var a = XmlHttp.responseText;
        var ni = document.getElementById('Div_PList');
		ni.innerHTML="";
				
		if(XmlHttp.status == 200){		
		if(a.length>1){
		    addPortRow(a,"Selected Country");
		    enableTooltips();
		    return true;}
		else{			
			alert("There is no any Port in database in this Marin Area. Please try another!" );
			return false;}
	}
		else{
			alert("There was a problem retrieving data from the server. Please try again!" );
			return false;}
	  }
  }

function FetchCAYard(tmpObj,ObjName){ 
     var tmpPortId = tmpObj;
     document.getElementById('txtSelectedName').value=ObjName; 
 
	// URL to get data from server	
	var requestUrl = "dispSyard.aspx?S=C&Id=" + encodeURIComponent(tmpPortId) ;
	
	CreateXmlHttp();		
	if(XmlHttp){
		XmlHttp.onreadystatechange = LoadCAYard;	
		XmlHttp.open("GET", requestUrl,  true);			
		XmlHttp.send(null);		
	 }
	 
 }

function LoadCAYard(){
	if(XmlHttp.readyState == 4){
	    var a = XmlHttp.responseText;
        var ni = document.getElementById('Div_PList');
		ni.innerHTML="";
		
		if(XmlHttp.status == 200){				
		if(a.length>1){
		    addYardRow(a,"Selected Country",1);		  
		    return true;}
		else{			
			alert("There is no any Port in database in this Marin Area. Please try another!" );
			return false;}
	 }
		else{
			alert("There was a problem retrieving data from the server. Please try again!" );
			return false;}
	  }
  }
   
function FetchCYard(tmpObj,ObjName){ 
     var tmpPortId = tmpObj;
     document.getElementById('txtSelectedName').value=ObjName; 
 
	// URL to get data from server	
	var requestUrl = "dispSyard.aspx?S=CY&Id=" + encodeURIComponent(tmpPortId) ;
	
	CreateXmlHttp();		
	if(XmlHttp){
		XmlHttp.onreadystatechange = LoadCYard;	
		XmlHttp.open("GET", requestUrl,  true);			
		XmlHttp.send(null);		
	 }
	 
 }
 
function LoadCYard(){
	if(XmlHttp.readyState == 4){
	    var a = XmlHttp.responseText;
        var ni = document.getElementById('Div_PList');
		ni.innerHTML="";
		
		if(XmlHttp.status == 200){				
		if(a.length>1){
		    addYardRow(a,"Selected Country",0);		  
		    return true;}
		else{			
			alert("There is no any Port in database in this Marin Area. Please try another!" );
			return false;}
	 }
		else{
			alert("There was a problem retrieving data from the server. Please try again!" );
			return false;}
	  }
  }

function FetchYard(tmpObj,ObjName){ 
     var tmpPortId = tmpObj;
     document.getElementById('txtSelectedName').value=ObjName; 
 
	// URL to get data from server	
	var requestUrl = "dispSyard.aspx?S=Y&Id=" + encodeURIComponent(tmpPortId) ;
	
	CreateXmlHttp();		
	if(XmlHttp){
		XmlHttp.onreadystatechange = LoadYard;	
		XmlHttp.open("GET", requestUrl,  true);			
		XmlHttp.send(null);		
	 }
	 
 }
 
function LoadYard(){
	if(XmlHttp.readyState == 4){
	    var a = XmlHttp.responseText;
        var ni = document.getElementById('Div_PList');
		ni.innerHTML="";
		
		if(XmlHttp.status == 200){				
		if(a.length>1){
		    addYardRow(a,"Selected Shipyard Area",0);		   
		    return true;}
		else{			
			alert("There is no any Port in database in this Marin Area. Please try another!" );
			return false;}
	 }
		else{
			alert("There was a problem retrieving data from the server. Please try again!" );
			return false;}
	  }
  }
  
function FetchDataYard(tmpObj,ObjName){  
    var tmpIdVar;
    var tmpIdVar1=tmpObj;
    var tmpIdVar2=tmpObj;   
    
    if(isNaN(tmpIdVar1)){tmpIdVar = tmpIdVar2; }
    else{tmpIdVar = tmpIdVar1;}

    document.getElementById('txtSelectedName').value=ObjName;
     
	// URL to get data from server    
	var requestUrl = "dispSyard.aspx?S=M&ID=" + encodeURIComponent(tmpIdVar) ;
	CreateXmlHttp();	
	
	if(XmlHttp){ 
		XmlHttp.onreadystatechange = LoadDataYard;
		XmlHttp.open("GET", requestUrl,  true);	
		XmlHttp.send(null);		
	 }
	}
  
  
function LoadDataYard(){	
	if(XmlHttp.readyState == 4){
	    var a=XmlHttp.responseText;
        var ni = document.getElementById('Div_PList');
        ni.innerHTML="";
		
		if(XmlHttp.status == 200){				
		if(a.length>1){  
		    addPortRow(a,"Selected Martime Area");
		    enableTooltips();		    
		    return true;}
		else{			
			alert("There is no any Port in database in this Marin Area. Please try another!" );
			return false;}
	 }
		else{
			alert("There was a problem retrieving data from the server. Please try again!" );
			return false;}
	  }
  }


//--------------------------------------- for Prodct Categrywise list ------------------------------------------

function FetchProdct(tmpObj){
        
    var tIdVar = tmpObj.value;
    var strSQL = "select PrdId, PrdName from tblProductMaster where PrdStatus=1 and PrdCatId="+tIdVar + "order by 1";

	// URL to get data from server

	var requestUrl = "dispProduct.aspx?strId=" + encodeURIComponent(strSQL) ;
	
	CreateXmlHttp();	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp){ 
	
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = LoadProduct;
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);		
		
		//Sends the request to server
		XmlHttp.send(null);		
	 }
 }

function LoadProduct(){
	// To make sure receiving response data from server is completed
	
	if(XmlHttp.readyState == 4){
	var a = XmlHttp.responseText;

		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200){		
		//Save successfully
		if(a.length>0)
		{
		    addProduct(a);
		    return true;
		}
		else{
			alert("There was a problem retrieving data from the server. Please try again!" )
			return false;
		 }
		 }
		else{
			alert("There was a problem retrieving data from the server. Please try again!" )
			return false;
		 }
	  }
  }

function addProduct(str)
{
        var strRowValue = str;
        var tmpGetValue = strRowValue;
        var oOption = "";
        var newOption1=document.getElementById('lstProd');
        newOption1.innerHTML="";
        var tmpGetValue1 = tmpGetValue.split(',');
        for(i=0; i < tmpGetValue1.length-1; i++)
        {
            var tmpGetValue2=tmpGetValue1[i].split('~');
            var newOption=tmpGetValue2[1];
             if(newOption.length>0)
             {  
                oOption=document.createElement("option");
                oOption.appendChild(document.createTextNode(newOption));
                oOption.setAttribute("value",tmpGetValue2[0]);
                document.all['lstProd'].appendChild(oOption);
            }
        }
 }
        
//------------------------------------------------ End of the Section -------------------------------------------


function getUnit(){
    var day = new Date();
    var requestUrl = "Cookeypage.aspx?GUN="+ day.toString();
	CreateXmlHttp();	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp){        
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = ReadUnit;
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);		
		//Sends the request to server
		XmlHttp.send(null);		
 }
 }
 
 function ReadUnit(){  
    if(XmlHttp.readyState == 4){	    
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200){
		    var a=XmlHttp.responseText;	
		    //alert(a);	
		    //Save successfully
		    if (a=="L"){
		        if (document.getElementById("Op1")!=null)
                    document.getElementById("Op1").checked= true;}
            if (a=="G"){ 
                if (document.getElementById("Op2")!=null)
                    document.getElementById("Op2").checked= true; }
		    }		
		else{
			alert("There was a problem retrieving data from the server. Please try again! " + XmlHttp.readyState );
			return false;
		    }
		}  
	
}
 
function changeUnit(un){
    var day = new Date();
    var requestUrl = "Cookeypage.aspx?tmp=" + day.toString() + "&UN=" + un ;
	CreateXmlHttp();	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp){ 

		//Setting the event handler for the response
		XmlHttp.onreadystatechange = SaveUnit1;
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);		
		//Sends the request to server
		XmlHttp.send(null);	
}
}

function SaveUnit1(){
    if(XmlHttp.readyState == 4){	    
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200){
		var a=XmlHttp.responseText;	
		window.location.reload();
		//alert(a);	
		//getUnit();
		//Save successfully
		if(a!='True'){					
			alert("There is a problem for storing unit" );
			return false;		
		  }		
		}		
		else{
			alert("There was a problem retrieving data from the server. Please try again!" );
			return false;
		 }
	  }	
}


function setUnit(un){ 
    var day = new Date();
    var requestUrl = "Cookeypage.aspx?tmp=" + day.toString() + "&UN=" + un ;
	CreateXmlHttp();	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp){ 

		//Setting the event handler for the response
		XmlHttp.onreadystatechange = SaveUnit;
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);		
		//Sends the request to server
		XmlHttp.send(null);		
 }
 }

function SaveUnit(){
    if(XmlHttp.readyState == 4){	    
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200){
		var a=XmlHttp.responseText;			
		//Save successfully
		if(a!='True'){					
			alert("There is a problem for storing unit" );
			return false;		
		  }		
		}		
		else{
			alert("There was a problem retrieving data from the server. Please try again!" );
			return false;
		 }
	  }
	
}