/* open window */
	function open_win(url_add)
   {
	   window.open(url_add, "my_window", 'width=800,height=600,menubar=yes,status=no, location=yes,toolbar=yes,scrollbars=yes');
   }

$(document).ready(function() {
	var imgURL;
	/*var slideshow = 0;
	
	var sArray = new Array();
	sArray[0] = {src:"url(../img/jam_bg.png)", spot:"Wednesday Was a Good Day",  link:"http://bit.ly/GoodDay1", spot2:" ", link2:" "};
	sArray[1] = {src:"url(../img/kai_bg.jpg)", spot:"WHITE COLLAR BRAWLER",  link:"http://whitecollarbrawler.com", spot2:"Season 2 Trailer", link2:"http://blip.tv/whitecollarbrawler"};
	sArray[2] = {src:"url(../img/ash_bg.jpg)", spot:"\"Don't Stop Believing\" Goes Viral",  link:"http://www.youtube.com/watch?v=AyVdbfyvwso", spot2:" ", link2:" "};*/
	
	function switchSlide(num){
		$("#home").css("background-image", sArray[num].src);
		$("#spotID").text(sArray[num].spot);
		$("spotA").attr("href",sArray[num].link);
		$("#spotID2").text(sArray[num].spot2);
		$("spotA2").attr("href",sArray[num].link2);
    	$("#content").delay(800).animate({ opacity: 1}, 2000);
	}
	

	function preload(arrayOfImages) {
	    $(arrayOfImages).each(function(){
	        $('<img/>')[0].src = this;
	        // Alternatively you could use:
	        // (new Image()).src = this;
    	});
	}
	
	// Usage:
	
	preload([
	    //'../img/beach_bg.jpg',
	    //'../img/bike_bg.jpg',
	    //'../img/ash_bg.jpg',
	    //'../img/kai_bg.jpg',
	    '../img/jam_bg.png',
	    //'../img/skyline_bg.jpg',
	    //'../img/water_bg.jpg',
	]);
	
	$(".menu_box").hover(function() {
		$(this).stop().animate({ backgroundColor: "#29ABE2"}, 100);
		},function() {
		$(this).stop().animate({ backgroundColor: "#0c0c0c" }, 300);
	});
	$(".menu_box").click(function(){
		$(".menu_box").css("border-top","2px solid white");
		$(this).css("border-top","2px solid #29ABE2");
		
		$("#theTitle").click(function(){
			$(".menu_box").css("border-top","2px solid white");
		});
	});
	
	$(".menu_item").click(function(){
		var theLink = $(this).attr("href");
		checkLink(theLink);
	});
	
	function checkLink(myLink){
		if(myLink == "#about"){
			$(".menu_box").css("border-top","2px solid white");
			$('#one').css("border-top","2px solid #29ABE2");
			$('.scroll-pane').jScrollPane();
		}else if(myLink == "#clients"){
			$(".menu_box").css("border-top","2px solid white");
			$('#two').css("border-top","2px solid #29ABE2");
			$('.scroll-pane').jScrollPane();
		}else if(myLink == "#press"){
			$(".menu_box").css("border-top","2px solid white");
			$('#three').css("border-top","2px solid #29ABE2");
			$('.scroll-pane').jScrollPane();
		}else if(myLink == "#projects"){
			$(".menu_box").css("border-top","2px solid white");
			$('#four').css("border-top","2px solid #29ABE2");
			$('.scroll-pane').jScrollPane();
		}else if(myLink == "#video"){
			$(".menu_box").css("border-top","2px solid white");
			$('#five').css("border-top","2px solid #29ABE2");
			$('.scroll-pane').jScrollPane();
		}else if(myLink == "#contact"){
			$(".menu_box").css("border-top","2px solid white");
			$('#six').css("border-top","2px solid #29ABE2");
		}else if(myLink == "#home"){
			$(".menu_box").css("border-top","2px solid white");
		}else{
			$(".menu_box").css("border-top","2px solid white");
			$('.scroll-pane').jScrollPane();
		}
		$("#home").css("display","none");
		$("#about").css("display","none");
		$("#clients").css("display","none");
		$("#press").css("display","none");
		$("#projects").css("display","none");
		$("#video").css("display","none");
		$("#contact").css("display","none");
		
		$(myLink).fadeIn();

	}
	
	if (location.href.indexOf("#") != -1) {
		var theHash = location.href.substr(location.href.indexOf("#"));
		// Your code in here accessing the string like this
		// location.href.substr(location.href.indexOf("#"))
		checkLink(theHash);
    } else {
    	/*$("#home").css("visibility","visible");
		$('#content').css('background-image', 'url(img/kai_bg.jpg)');
    	$("#content").css("opacity","0");
    	$("#content").stop().delay(800).animate({ opacity: 1}, 1000);*/
    	$(".menu_box").css("border-top","2px solid white");
    	checkLink("#home");
    	$("#content").css("opacity","0");
    	$("#content").stop().delay(800).animate({ opacity: 1}, 1000);
    }
    
    $(window).bind('hashchange', function () {
		if (location.href.indexOf("#") != -1) {
		var theHash = location.href.substr(location.href.indexOf("#"));
		// Your code in here accessing the string like this
		// location.href.substr(location.href.indexOf("#"))
		checkLink(theHash);
	    } else {
	    	/*$("#home").css("visibility","visible");
			$('#content').css('background-image', 'url(img/kai_bg.jpg)');
	    	$("#content").css("opacity","0");
	    	$("#content").stop().delay(800).animate({ opacity: 1}, 1000);*/
	    	$(".menu_box").css("border-top","2px solid white");
	    	checkLink("#home");
	    	$("#content").css("opacity","0");
    		$("#content").stop().delay(800).animate({ opacity: 1}, 1000);
	    }
	});
	
	$('.scroll-pane').jScrollPane({contentWidth: 680});
	
	/* fancybox */
	$(".samp_link").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	
	$(".samp_title").css("display","none");
	
	$(".samp_box").hover(
		function(){
			$(".samp_title", this).fadeIn();
		},
		function(){
			$(".samp_title", this).fadeOut();
		}
	);
	
	/* slideshow */
	$('#slideshow').fadeSlideShow();

});

