function getHTTPObject() 
{
    var xmlhttp; 
	  /*@cc_on
         @if (@_jscript_version >= 5)
          try {  
              xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
              } catch (e) {
              try {
                  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                  } catch (E) {
                  xmlhttp = false;
                  }
              } 
         @else
          xmlhttp = false;
         @end @*/    
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
    {
     	try
     	{
       		xmlhttp = new XMLHttpRequest();
      	}	 
      	catch (e)
      	{
           xmlhttp = false;
      	}
	 }
      return xmlhttp;
}

var http = getHTTPObject(); 



function checkEmpty(field,msg){

	if (field == "")
	{
		alert("Please fill a value for the \"" + msg + "\" field.");
		return false;
	}

	return true;

}

function trim(str) { return str.replace(/^\s+|\s+$/, ''); };

function validateSearch()
{ 
    	
		var cat_id =trim(document.getElementById("cat_id").value);
		if(!checkEmpty(cat_id,"Select a vessel type")){return false;}
		
		
		
		/*var subcat_id =trim(document.getElementById("subcat_id").value);
		if(!checkEmpty(subcat_id,"Select a vessel subtype")){return false;}	
		
		var depth =trim(document.getElementById("depth").value);
		if(!checkEmpty(depth,"Select a depth")){return false;}	


		var cubic =trim(document.getElementById("cubic").value);
		if(!checkEmpty(cubic,"Select a cubic capacity")){return false;}	
		
		var age =trim(document.getElementById("age").value);
		if(!checkEmpty(age,"Select a age capacity")){return false;}	*/

		
		
		return true;
	
}

// Function to get category details 
function getsubcategories()
{
    var url="getFields.php?";
	var cat_id =document.getElementById("cat_id").value;
	
	
	if(cat_id != '')
	{
		
		var myRandom=parseInt(Math.random()*99999999); 
		var params="id="+cat_id+ "&rand=" + myRandom;
	     
		 http.open("POST", url ,true); 
		 http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		 http.onreadystatechange = Response_subcat;
		 http.send(params);    
	}
	else
	{
		
		document.getElementById("dynamic_fields").innerHTML='';

	}	
}

function Response_subcat()
{
	if (http.readyState == 4) 
	{
				
	   	document.getElementById("dynamic_fields").innerHTML= http.responseText;
		
	   	
		
	}
}

