$(document).ready(function(){

	$("#main-menu li ul").hide();
	
	
	if (document.all&&document.getElementById) {
	navRoot = document.getElementById("main-menu");
	for (i=0; i<navRoot.childNodes.length; i++) {
	node = navRoot.childNodes[i];
	if (node.nodeName=="LI") {
	
	/*
	node.onmouseover=function() {
	this.className+=" over";
	  }
	  node.onmouseout=function() {
	  this.className=this.className.replace(" over", "");
	   }
	*/
	
		node.onmouseover=function() {
		//$(this).show(200);
		this.className+=" over";
	 	}
		
		  node.onmouseout=function() {
		  this.className=this.className.replace(" over", "");
		   }
	  }
	 }
	}
	
	
	$("#main-menu/li").hover(function(){
		$(this).addClass("bg-list-ie");
	}, function(){
		$(this).removeClass("bg-list-ie");
		}
	)
	
	
	/*
	$("#main-menu a").hover(function(){
		//alert(this).next(".over-list");
		$(this).next().show(200);
	}, function(){
		$(this).next().hide(200);
		}
	)
	*/
	
	
	$("#sec-nav li a").hover(function(){
		$(this.parentNode).addClass("bg-sec-list");
	}, function(){
		$(this.parentNode).removeClass("bg-sec-list");
		}
	)
	
	$("#foot-nav li a").hover(function(){
		$(this.parentNode).addClass("footer-list-over");
	}, function(){
		$(this.parentNode).removeClass("footer-list-over");
		}
	)
	
	//WHERE TO BY CODE
	
	function setTeritory() {
		$.get("repListRequest.php",
		   { a: "gc", state: this.options[this.selectedIndex].text },
		   function(data){
		     $('#countries').html(data);
		      document.getElementById('countries').selectedIndex = 0;
		   }
		 );
	}
	
	function FindRepList() {
		if($('#state').val() == 0 || $('#countries').val()==0) {
			return;
		}
		$('#replist_content').html('<img src="images/preloading.gif" alt="loading..."/>');
		$.get("repListRequest.php",
		   { a: "s", state: $('#state').val(), country: $('#countries').val() },
		   function(data){
		     $('#replist_content').html(data);
		   }
		 );
	}
	/*
	function FindRepListCode() {
		if($('#zip_code').val() == 0 ) {
			return;
		}
		$('#replist_content').html('<img src="images/preloading.gif" alt="loading..."/>');
		$.get("repListRequestCode.php",
		   { a: "z", zip_code: $('#zip_code').val() },
		   function(data){
		     $('#replist_content').html(data);
		   }
		 );
	}
	*/
	

	
	function FindRepListCountry() {
		

		if (document.getElementById($("input[@name=country][@checked]"))==false)
		{
			return;
		}

		$('#replist_content').html('<img src="images/preloading.gif" alt="loading..."/>');
		
		$.get("repListRequestCountry.php",
		   { a: "c", country:  $("input[@name=country][@checked]").val() , zip_code: $('#zip_code').val()  },
		   function(data){
		     $('#replist_content').html(data);
			 
		   }
		
		 );
	}
	
	/*
	function FindRepListCountry() {
	($('#zip_code').val() == 0 ) || ()  (document.getElementById($("input[@name=country][@checked]"))==false)
	{
	return; 
	}
	$('#replist_content').html('<img src="images/preloading.gif" alt="loading..."/>');
		$.get("repListRequestCountry.php",
		   { a: "c", country:  $("input[@name=country][@checked]").val() , zip_code: $('#zip_code').val() },
		   function(data){
		     $('#replist_content').html(data);
		   }
		   
		 );
	}
	*/
	function FindRepListNone() {
	
		if ( ($('#state').val() == 0 || $('#countries').val()==0) && $('#zip_code').val() == 0   && document.getElementById($("input[@name=country][@checked]")).checked==false )
		{
			$('#replist_content').html('<img src="images/preloading.gif" alt="loading..."/>');
			$.get("repListRequest.php",
		  	 { a: "" },
		  	 function(data){
		     $('#replist_content').html(data);
		   }
		 );
		}
		
	}
	
	 $('#state').change(setTeritory);
	$('#RLSearch').click(FindRepList); 
	
	/* $('#RLFind').click(FindRepListCode);*/
	
	$('#RLFind').click(FindRepListCountry);
	

	 
	/*$('#RLFind').click(FindRepListCountry);*/
	/*$('#RLFind').click(FindRepListNone);*/
	
});