$(document).ready(function () {
    preload([//PRELOADS IMAGES
        'http://yukonpartners.com/wordpress/wp-content/themes/boilerplate/images/ShadowLeft.png',
        'http://yukonpartners.com/wordpress/wp-content/themes/boilerplate/images/ShadowRight.png',
        'http://yukonpartners.com/wordpress/wp-content/themes/boilerplate/images/menubg.png',
        'http://yukonpartners.com/wordpress/wp-content/themes/boilerplate/images/bullet.png',
        'http://yukonpartners.com/wordpress/wp-content/themes/boilerplate/images/homeHeader.jpg',
        'http://yukonpartners.com/wordpress/wp-content/themes/boilerplate/images/homeImage.jpg',
        'http://yukonpartners.com/wordpress/wp-content/themes/boilerplate/images/homeBackground.jpg',
        'http://yukonpartners.com/wordpress/wp-content/themes/boilerplate/images/subpageHeader.jpg',
        'http://yukonpartners.com/wordpress/wp-content/themes/boilerplate/images/extendableBG.jpg',
        'http://yukonpartners.com/wordpress/wp-content/themes/boilerplate/images/investmentParameters.jpg',
        'http://yukonpartners.com/wordpress/wp-content/themes/boilerplate/images/philosophyImage.jpg',
        'http://yukonpartners.com/wordpress/wp-content/themes/boilerplate/images/contactUsImage.jpg',
        'http://yukonpartners.com/wordpress/wp-content/themes/boilerplate/images/newsImage.jpg',
        'http://yukonpartners.com/wordpress/wp-content/themes/boilerplate/images/teamImage.jpg'
        ]);
    function preload(arrayOfImages) {   
        $(arrayOfImages).each(function () {
            $('<img/>')[0].src = this;
        });
    }//ENDS PRELOADING
	
	//SETS HEIGHT OF SIDE SHADOWS	
	var hContentWrapper = $("#contentWrapper").height(); // Get height of Content Wrapper
	$("#shadowLeft, #shadowRight").css("height",hContentWrapper);  // Set left and right shadows to height of contentWrapper
	if ($.browser.msie && $.browser.version.substr(0,1)<7) { // hide side shadows in IE versions older than 7
		$("#shadowLeft, #shadowRight").hide();
	}	
	//END SHADOW HEIGHTS
	
	//MENU FIX FOR TOUCHSCREEN DEVICES
	$('ul.menu li').click(function() { 
		if($('ul', this)){
			$(this).css('display', 'block'); 
		}
	});
	//END MENU FIX
	
	//TEAM PAGE--------------------------------------------------------------------------
	var currentID = $("#teamLeft").find(":nth-child(1)").attr("id");//Finds div ID of first employee thumbnail listed
    $("#right" + currentID).show();//Shows div on right for the employee div found on line above
	$(".thumbImage").css({ opacity:"1"});//Sets all thumbnail images to be visible
	jQuery(".thumbImage", "#" + currentID).css({ opacity:"0"});//sets thumbnail hover image to transparent/selected according to div found above

	$(".thumbFrame").hover(
		function() {
		hoveNum = this.id.toString();
		if (hoveNum != currentID){
			jQuery(".thumbImage", this).stop().animate({"opacity": "0"}, "fast");
			}
		},
		function() {
		if (hoveNum != currentID){
			jQuery(".thumbImage", this).stop().animate({"opacity": "1"}, "fast");
			}
		});
	
	 $(".thumbFrame").click(function () { //WHEN THUMBNAIL IS CLICKED, THIS HAPPENS
		clickNum = this.id.toString(); //TAKES THE ID NUMBER FROM IMAGE CLICKED
        if (clickNum != currentID){ //If it's not currently active...
		$("#right" + currentID).fadeOut('fast', function() {//we fade out and hide the currently displayed panel on right
			$("#right" + clickNum).fadeIn('slow');//and then fade in and show the new, clicked upon panel
		});
		jQuery(".thumbImage", "#" + currentID).css({ opacity:"1"});		//the old active thumbnail is shown, giving a 'deactivating' effect		
        currentID = clickNum; //sets the currentID to the one new one that was clicked on
		}
    });
});
