
$(function() {
	
	if(page != "" && page != "home" && page != "gallery") {
		$('#btn_'+page).toggleClass("selected");
		$('#tHeader').css({background:"url(images/headers/main.jpg)"});
	} else {
		$('#tContent').hide();
		$('#tSelected').hide();
		//$('#tHeader').css({height:"297px"});
		$('body').css({background:"#000 url(images/bg.jpg) repeat-x top"});
		if(page == 'gallery') {
			$('#tHeader').css({height:"297px"});
			$('#tHeader').css({background:"url(images/headers/gallery.jpg)"});
			$('#btn_gallery').toggleClass("selected");
			$('#tContent').show();
		}
	}
	
	$('#tHeader').mouseover(function() {
		if(page == 'gallery') {
			$('#tLogo:not(:animated)').fadeTo("fast", 0.33);
		}
	});
	
	$('#tHeader').mouseout(function() {
		if(page == 'gallery') {
			$('#tLogo:not(:animated)').fadeTo("fast", 1);
		}
	});
	
	var currentimg;
	var current;
	
	$('#thumbnails img').mouseover(function() {
		$(this).css({border:"1px solid red"});
	});
	
	$('#thumbnails img').mouseout(function() {
		if($(this).attr("rel") != currentimg) {
			$(this).css({border:"1px solid white"});
		}
	});
	
	$('#thumbnails img').click(function() {
		if(currentimg != '') {
			$(current).css({border:"1px solid white"});
		}
		target = $(this).attr("rel");
		currentimg = target;
		current = $(this);
		$('#tHeader').css({background:"url(images/gallery/large_"+target+".jpg)"});
		$(this).css({border:"1px solid red"});
	});
	
	/*$('#gallery td:has(img) img').css("opacity",0);
	$('#gallery td:has(img)').css({background:"#FFFFFF"});
	$('#gallery td:has(img)').css("opacity",.2);
	$('#transparent').css("opacity",0);
	
	$('#gallery td:has(img)').mouseover(function() {
		$(this).find("img").css("opacity",1);
		$(this).css("opacity",1);
		
		if(!(jQuery.browser.msie && jQuery.browser.version == '6.0')) {
			$('#gallery').css({background:"url(images/gallery/transparent.png)"});
		}
	});
	
	$('#gallery td:has(img)').mouseout(function() {
		$(this).find("img").css("opacity",0);
		$(this).css("opacity",.2);
		$('#gallery').css({background:"transparent"});
	});
	
	$('#gallery td img').click(function() {
		target = $(this).attr("rel");
		$('#tHeader').css({background:"url(images/gallery/"+target+".jpg)"});
	});*/
	
	var preloaded = new Array();
	function preload_images() {
		for (var i = 0; i < arguments.length; i++){
			preloaded[i] = document.createElement('img');
			preloaded[i].setAttribute('src',arguments[i]);
		};
	};
	
	preload_images('images/gallery/large_1.jpg','images/gallery/large_2.jpg','images/gallery/large_3.jpg','images/gallery/large_4.jpg','images/gallery/large_5.jpg'
	,'images/gallery/large_6.jpg','images/gallery/large_7.jpg','images/gallery/large_8.jpg','images/gallery/large_9.jpg','images/gallery/large_10.jpg'
	,'images/gallery/large_11.jpg','images/gallery/large_12.jpg');
			
});

