if (document.images)
{
  preload_image_object = new Image();
  // set image url
  image_url = new Array();
  image_url[0] = "/images/layout/homeRoll.jpg";
  image_url[1] = "/images/layout/aboutRoll.jpg";
  image_url[2] = "/images/layout/portfolioRoll.jpg";

   var i = 0;
   for(i=0; i<=3; i++) 
	 preload_image_object.src = image_url[i];
}


//Smooth Scrolling Function
function smoothScroll(){
	$('a[href*=#]').click(function() {
	  if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
	  && location.hostname == this.hostname) {
		var target = this.hash;
		var i = 0;
		
		if (target == '#about-us') {
			i =960;
			if(firefox == 2) {
				$('#aboutContent').show();
			}
		} else if (target == '#portfolio') {
			i = 1920;
			if(firefox == 2) {
				$('#aboutContent').hide();
			}
		} else {
			i = 0;
			if(firefox == 2) {
				$('#aboutContent').show();
			}
		}		 
		
		$('#container').animate({scrollLeft: i}, 1000, function(){ location.hash = target;});
		 return false;
	  }
	});
}

//Hover States
$("#nav li").hover(
	function(){
		var iconName = $(this).find("img").attr("src");
		var original = iconName.split(".")[0];
		$(this).find("img").attr({src: "" + original + "Roll.jpg"});
	}, 
	
	function(){
		var iconName = $(this).find("img").attr("src");
		var original = iconName.split("Roll.")[0];
		$(this).find("img").attr({src: "" + original + ".jpg"});
	});

//Gallery Menu
$('.galleryIcon').hover(
	function(){
		$(this).animate({width:131}, 200);
		$(this).addClass("on");
		$(this).removeClass("off");
		$('.off').animate({width:76}, 200);
	},
	
	function (){
		$(this).addClass("off");
		$(this).removeClass("on");
	});

//Lightbox
$('.galleryIcon a').click(
	function(){
		$src = $(this).attr("href");
		$('#galleryFrame').attr({src:$src}); 
		$('#lightbox').show();
		$('#close').show(); 
		$('#galleryFrame').show();
		$('#background').show();
		$top = $(this).offset().top - $('#wrapper').offset().top - 150;
		$left = $(this).offset().left - $('#wrapper').offset().left;
		$('#lightbox').css({ 
			top:$top, 
			left:$left 
		});
		
		$('#lightbox').animate({
			top:90,
			left:80,
			width:799,
			height:540
		});
		return false;
		$('div.close').pngFix();
	});

$('#background, #close').click(
	function(){
		$('#lightbox').animate({
			top:$top,
			left:$left,
			width:10,
			height:10
		}, function(){ $('#lightbox').hide(); $('#close').hide(); $('#galleryFrame').hide(); })
		$('#background').hide();
		return false;
	});

//Set up smooth scroll and pngFix when pages are ready
jQuery(document).ready(function(){
	smoothScroll();
	if (jQuery.fn.pngFix) $('div.contentArea').pngFix();
});

var firefox = (navigator.userAgent.indexOf('Firefox') > -1) ? parseFloat(navigator.userAgent.match(/Firefox[\/\s](\d+)/)[1]) : false;


$("#footer li").hover(
	function(){
		$divPos = -(400 - $(this).width()) /2 ;
		$(this).find("div").css({left:$divPos});
		$(this).find("div").animate({opacity: "show", top: "-300"}, "normal");
		
	}, 
	
	function(){
		$(this).find("div").animate({opacity: "hide"}, "fast", function(){$("#footer li div").css({top:-200})});
	});
