// JavaScript Document
//#######################################################
//#     No matter what happened, God is always be in    # 
//# our side. A man will not succeed without sacrifices #
//# to be made which are the basis on how strong enough #
//# he was.                                             # 
//#    Faith makes us stronger, Responsibility makes as #
//# humane. In every decisions you will make, Do it     # 
//# wisely. It must both your mind and heart will       #
//# aggree. Otherwise, you will regret it. -APH         # 
//#######################################################
$(document).ready(function(){$("#loading").hide(); $("#resultbox").hide();


$("#keyword_text2").keypress(function(e){
		
		if(e.which==13){ 
		alert("request sent");
		return false;
		//$("#key_sub").trigger('click'); 
		} 
		
									  });

$("#states select").change(function(){
									$("#searchtitle").remove();$("#results").remove();$(".fBlue").remove();$("#paging").remove();$("#resultbox").hide();});

$("#key_sub").click(function(){	
var stitle='';var type=$("input:radio[@checked]",kywrd_srch).val();
var txt=$("#keyword_text2",kywrd_srch).val();
var srch="Submit";
var states2=$("#states select option:selected").text();
var states=$("#states select").val(); 
	if(states2=="All States") { states='*';}$("#loading").show();
	


	$.ajax({type: "POST",url: "results.php",data: { keytext:txt, types: type, gosearch:srch,st:states} , 
		   success: function(data){$("#searchtitle").remove();
		   $("#results").remove();    
		   $(".fBlue").remove(); 
		   $("#paging").remove();
		   $("#resultbox").show();
		   $("#loading").hide();
	 
		if(txt!='' && states!=''){ stitle= '<div id="searchtitle"><span class="fHeaderBlack" >Search Result for </span><i style="font-size:125%;">'+txt+','+states2+'</i></div><br>'; 
 }
else if(states=='' && txt!=''){
stitle= '<div id="searchtitle"><span class="fHeaderBlack" >Search Result for </span><i style="font-size:125%;">'+txt+'</i></div><br>';
}
else if(txt=='' && states!=''){
stitle= '<div id="searchtitle"><span class="fHeaderBlack">Search Result for </span><i style="font-size:125%;">'+states2+'</i></div><br>';
}/*
else
{
stitle= '<div id="searchtitle"><span class="fHeaderBlack">Search Result for </span><i style="font-size:125%;">Nothing..</i></div><br>';
}		*/
		
		
          data=stitle+data; $("#dealerinfo").prepend(data);} });
	return false; }); 
							 
});


	
						 
//this is not inlcuded
 /* $("#states select").change(function(){
   var st=$("#states select").val();
  
   $.ajax({
   type: "POST",
   url: "results.php",
   data: "st="+st,
   success: function(states){
   
    $("#dealer option").remove();
	if(states!="null")
	{
	  
    $("#dealer select").prepend(states);
	$("#manual_search").removeAttr("disabled");
    }
	else { alert("No Dealers found on selected state!"); 
	 $("#dealer select").prepend("<option>Please select another states</option>");
	 $("#manual_search").attr("disabled","disabled");
	}
   }
 });
	 
   });*/
  /* 
   $("#manual_search").click(function()
   {
   var id=$("#dealer select").val();
   
   $("#loading").show();
 
   
   $.ajax({
   type: "POST",
   url: "results.php",
   data: "id="+id,
 
   success: function(result){
    
	//$("#keyword_text2").empty();
	$("#resultbox").show();
    $("#results").remove();
	$(".fBlue").remove();
	$("#paging").remove();
	$("#loading").hide();
	$("#dealerinfo").prepend(result);
      }
	
 });
 
    return false;
   });
   */
 
