jQuery.fn.extend ({
	lToggle: function() {
		return this.each(function() { 
			$(this).toggle(function() { $(this).attr("src","images/menu/"+$(this).attr("alt")+".jpg"); }, function() {  });
			$("#"+this.id+"details").toggle();
		});
	}
});
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

$(document).ready( function() { 
	try {
	var arr = new Array("products", "locations", "promotions", "about", "employment", "faq", "contact");
	$("BUTTON").removeAttr("disabled");
// EVENTS: click
	$("A").mouseover( function() { if (this.id != "") { $("img[alt='"+this.id+"']").attr("src","/images/menu/"+this.id+"_on.jpg"); }} );
	$("A").mouseout( function() { if (this.id != "") { $("img[alt='"+this.id+"']").attr("src","/images/menu/"+this.id+".jpg"); }} );
	$("UL#questions > LI").mouseover( function() { $(this).addClass("ul"); });
	$("UL#questions > LI").mouseout( function() { $(this).removeClass("ul"); });
	$("UL#questions > LI").click( function() { $("DIV.answers").hide(); $("UL#questions > LI").removeClass("selectlist"); $(this).addClass("selectlist"); $('#a'+this.id).toggle(); });
	
	$.preloadImages("images/menu/locations.jpg",
									"images/menu/locations_on.jpg",
									"images/menu/home.jpg",
									"images/menu/home_on.jpg",
									"images/menu/contact.jpg",
									"images/menu/contact_on.jpg",
									"images/menu/products.jpg",
									"images/menu/products_on.jpg",
									"images/menu/promotions.jpg",
									"images/menu/promotions_on.jpg",
									"images/menu/requests.jpg",
									"images/menu/requests_on.jpg",
									"images/menu/services.jpg",
									"images/menu/services_on.jpg");
	$("DIV.answers").hide();
//	var width = ((912-parseInt($("DIV.btmmenu").css("width")))/2)-5;
//	$("DIV.btmmenu").css("padding", "0px " + width + "px");

	$("#contactform").click(function(){ 
		var error = "";
		$(".req:input[name!='']").each(function(i){	if (this.value == "") error += "Missing Information: " + this.name.substring(2) +"\n";	});
		if (error.length > 0) alert(error);
		else {
			$(this).attr("disabled","disabled");
			$.post("c_contact.php",
						 $(":input[name!='']").serialize(),
						 function(data){	
							 $(":input[name!='']").each(function(i){	this.value = "";	});
 							 $(this).removeAttr("disabled")
							 alert("Thank you for contacting us!"); 
						 }
			); // end post	
		} // end else
	});
	
	$("#requestsform").click(function(){ 
		var error = "";
		$(".req:input[name!='']").each(function(i){	if (this.value == "") error += "Missing Information: " + this.name.substring(2) +"\n";	});
		if (error.length > 0) alert(error);
		else {
			$(this).attr("disabled","disabled");
			$.post("c_contact.php",
						 $(":input[name!='']").serialize(),
						 function(data){	
							 $(":input[name!='']").each(function(i){	this.value = "";	});
 							 $(this).removeAttr("disabled");
							 alert("Thank you for contacting us!"); 
						 }
			); // end post	
		} // end else
	});

	$("#employ").click(function(){ 
		var error = "";
		$(".req:input[name!='']").each(function(i){	if (this.value == "") error += "Missing Information: " + this.name.substring(2) +"\n";	});
		if (error.length > 0) alert(error);
		else {
			$(this).val("Please Wait");
			$(this).attr("disabled","disabled");
			$.post("c_employment.php",
						 $(":input[name!='']").serialize(),
						 function(data){	
//							 $(":input[name!='']").each(function(i){	this.value = "";	});
 							 $(this).removeAttr("disabled");
							 alert("Thank you for submitting your application!"); 
							 location.href="index.php";
						 }
			); // end post	
		} // end else
	});
	var bHeight = parseInt($("DIV.banners").css("height"));
	var pHeight = parseInt($("DIV.pagecontent").css("height"));
	if (bHeight > pHeight) { $("DIV#homepagecontent").css("top",(bHeight-pHeight)/2+"px"); }
	} catch (err) { ; } // end try catch
}); // end doc ready

	function printdetails(barcode) {
		var second = "Coupon_Details";
		var third = "location=0,status=0,scrollbars=0,menubar=0,toolbar=0,directories=0,resizeable=0,width=550,height=375";
		details = window.open(barcode,second,third);
		var t=setTimeout("details.print()",2000);
//		details.print();
	} // end function