jQuery.preloadImages = function() {
  for(var i = 0; i<arguments.length; i++) {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

$(document).ready(function(){
	// Preload menu images											 
	$.preloadImages("images/btn-home-over.jpg","images/btn-about-us-over.jpg","images/btn-products-and-application-over.jpg","images/btn-contact-us-over.jpg");

	$(".menuBtn").each(function() {
		// automatically change to hover images on menu buttons
		$("#"+$(this).attr("id")).hover(function() {
			if ($(this).attr("src").indexOf("-over.jpg") == -1)
				$(this).attr("src",$(this).attr("src").replace(".jpg","-over.jpg"));
		},
		function(){
			if ($(this).attr("src").indexOf("-over.jpg") != -1)
				$(this).attr("src",$(this).attr("src").replace("-over.jpg",".jpg"));
			highlightSection();
		});
	});

	// highlight cuurent section
	highlightSection();
	
	$(".sectionBox").hover(function(){
		$(this).stop().animate({
			opacity: "0.8"
		},250);
	},
	function(){
		$(this).stop().animate({
			opacity: "1"
		},250);
	});
	
	$("a.gridLink").hover(function(){
		$(this).children("img.photoBorder").stop().animate({opacity: "0.8"},125).animate({opacity: "1"},125).animate({opacity: "0.9"},125);
	},
	function(){
		$(this).children("img.photoBorder").stop().animate({opacity: "1"},250);
	});

	//giveDropShadows();

});

// highlights current section if a section is defined by adding/removing "-over".jpg
function highlightSection() {
	if (typeof(section)!="undefined") {
		if ($("#btn"+section).attr("src").indexOf("-over") == -1)
			$("#btn"+section).attr("src",$("#btn"+section).attr("src").replace(".jpg","-over.jpg"));
	}
}

function giveDropShadows() {
	$("img.photoBorder").dropShadow({
		left    : -2,
		top     : -2,
		blur    : 2,
		opacity : 1,
		color   : "black",
		swap    : false
	});
}
function getById(id) {
	return document.getElementById(id);
}