//Check what browser is being used.
var browser = navigator.appName;
var articleID = '';

// Set variables for Vimeo
var vimeoAlbum = 'album/219865';
var videoCallback = 'latestVideo';
var videosUrl = 'http://www.vimeo.com/api/v2/' + vimeoAlbum + '/videos.json?callback=' + videoCallback;
var videoID = '';
var videoThumbnail = '';
var moogaloop = false;

//no conflict jquery 
jQuery.noConflict();

jQuery(document).ready(function(){  
	
	//Set the initial heights for content windows and positions of containers
	var pageContentHeight = jQuery("#main_page_content").height();
	var pageHeight = jQuery("#page-wrap").height();
	var pageWidth = jQuery(window).width();
	var windowHeight = jQuery(window).height();
	var footerHeight = jQuery("#footer").height();

	if (footerHeight == 0) {
		var leftFooterHeight = jQuery("#bottom-left").height();
		var rightLooterHeight = jQuery("#bottom-right").height();
		if(rightLooterHeight > leftFooterHeight) {
			footerHeight = rightLooterHeight;
		} else {
			footerHeight = leftFooterHeight;
		}
		if (footerHeight == 0) {
			footerHeight = 45;		
		}
	}
	//alert(windowHeight);
	var bkgndWidth = '';
	
	//Adjust the height of the footer based on its content
	var negHeight = footerHeight * -1;
	jQuery("#page-wrap").css("margin-bottom", negHeight);
	jQuery("#footer-spacer").css("height", footerHeight);
	jQuery("#footer").css("height", footerHeight);
	jQuery("#footer-box").css("margin-top", footerHeight-45);
				
	//Adjust the width of the background header images
	if (pageWidth > 1280) {
		bkgndWidth = pageWidth - 1285;
		if(browser != 'Microsoft Internet Explorer' && pageContentHeight < windowHeight) {
			bkgndWidth = bkgndWidth + 17;
		}
		jQuery("#grey_bkgnd").css("width", bkgndWidth);
		jQuery("#subnav_bkgnd").css("width", bkgndWidth);
	} else {
		bkgndWidth = 0;
		jQuery("#grey_bkgnd").css("width", bkgndWidth);
		jQuery("#subnav_bkgnd").css("width", bkgndWidth);
	}
	
	
	//If the User resizes the window, adjust the #container height
	jQuery(window).bind("resize", resizeWindow);
	function resizeWindow( e ) {
		pageContentHeight = jQuery("#main_page_content").height();
		pageHeight = jQuery("#page-wrap").height();
		pageWidth = jQuery(window).width();
				
		if (pageWidth > 1280) {
			bkgndWidth = pageWidth - 1285;
			//if(browser != 'Microsoft Internet Explorer' && pageHeight < 575) {
			//	bkgndWidth = bkgndWidth + 17;
			//}
			jQuery("#grey_bkgnd").css("width", bkgndWidth);
			jQuery("#subnav_bkgnd").css("width", bkgndWidth);
		} else {
			bkgndWidth = 0;
			jQuery("#grey_bkgnd").css("width", bkgndWidth);
			jQuery("#subnav_bkgnd").css("width", bkgndWidth);
		}
	} 
	
	//If not IE, use JQuery Blend
	if(browser != 'Microsoft Internet Explorer') {
	
		//Sponsor Logos
		jQuery(".sm-facebook a").blend();
		jQuery(".sm-twitter a").blend();
		jQuery(".sm-myspace a").blend();
		
		jQuery(".kk-signature a").blend();
		jQuery(".kkr-logo a").blend();
		jQuery(".kkf-logo a").blend();
		jQuery(".kks-logo a").blend();
		jQuery(".klub-btn a").blend();
		jQuery(".fk-btn a").blend();
		
		jQuery(".menu-news a").blend();
		jQuery(".menu-profile a").blend();
		jQuery(".menu-team a").blend();
		jQuery(".menu-schedule a").blend();
		jQuery(".menu-gallery a").blend();
		jQuery(".menu-partners a").blend();
		jQuery(".menu-about a").blend();
		jQuery(".menu-donate a").blend();
		jQuery(".menu-events a").blend();
					
	}
	
	/**
	* Highlight the submenu item that is active 
	* on the page with it's rollover effect
	*/
	var currentPage = window.location.pathname;
	var activePageArray = currentPage.split("/");
	var activePage = activePageArray[2];
	
	if(activePage == "news") { 
		jQuery("#menu-news-link").css("background-position", "0 -9px");
	}
	if(activePage == "profile") { 
		jQuery("#menu-profile-link").css("background-position", "0 -9px");
	}
	if(activePage == "team") { 
		jQuery("#menu-team-link").css("background-position", "0 -9px");
	}
	if(activePage == "gallery") { 
		jQuery("#menu-gallery-link").css("background-position", "0 -9px");
	}
	if(activePageArray[1] == "photos") { 
		jQuery("#menu-gallery-link").css("background-position", "0 -9px");
	}
	if(activePage == "partners") { 
		jQuery("#menu-partners-link").css("background-position", "0 -9px");
	}
	
	/**
	* KK menu Effect (News, Profile, Team, Gallery, Partners)
	* Hovering over main menu items (KK, KKF, KKR, KKS)
	* will change background background of menu
	*/
	jQuery(".kkr-logo").hover(function() {
	    jQuery("#menu_bkgnd_1").addClass("red");
		jQuery("#menu_bkgnd_2").addClass("red");
		jQuery("#menu_bkgnd_3").addClass("red");
		jQuery("#menu_bkgnd_4").addClass("red");
		jQuery("#menu_bkgnd_5").addClass("red");
	}, function() {
    	jQuery("#menu_bkgnd_1").removeClass("red");
		jQuery("#menu_bkgnd_2").removeClass("red");
		jQuery("#menu_bkgnd_3").removeClass("red");
		jQuery("#menu_bkgnd_4").removeClass("red");
		jQuery("#menu_bkgnd_5").removeClass("red");
    });
	
	jQuery(".kkf-logo").hover(function() {
	    jQuery("#menu_bkgnd_1").addClass("blue");
		jQuery("#menu_bkgnd_2").addClass("blue");
		jQuery("#menu_bkgnd_3").addClass("blue");
		jQuery("#menu_bkgnd_4").addClass("blue");
		jQuery("#menu_bkgnd_5").addClass("blue");
	}, function() {
    	jQuery("#menu_bkgnd_1").removeClass("blue");
		jQuery("#menu_bkgnd_2").removeClass("blue");
		jQuery("#menu_bkgnd_3").removeClass("blue");
		jQuery("#menu_bkgnd_4").removeClass("blue");
		jQuery("#menu_bkgnd_5").removeClass("blue");
    });
	
	jQuery(".kks-logo").hover(function() {
	    jQuery("#menu_bkgnd_1").addClass("green");
		jQuery("#menu_bkgnd_2").addClass("green");
		jQuery("#menu_bkgnd_3").addClass("green");
		jQuery("#menu_bkgnd_4").addClass("green");
		jQuery("#menu_bkgnd_5").addClass("green");
	}, function() {
    	jQuery("#menu_bkgnd_1").removeClass("green");
		jQuery("#menu_bkgnd_2").removeClass("green");
		jQuery("#menu_bkgnd_3").removeClass("green");
		jQuery("#menu_bkgnd_4").removeClass("green");
		jQuery("#menu_bkgnd_5").removeClass("green");
    });
	
	/**
	 * Tooltips for KK Sites
	 */
	jQuery("#video_control").tooltip({
		tip: '#vc_tooltip',
		effect: "fade",
		offset: [0, 125],
		onShow: function() {
			this.getTip().delay(5000).fadeTo("slow", 0);
		}
	});
	jQuery("#news_small_submenu").tooltip({
		tip: '#news_tooltip',
		effect: "fade",
		offset: [0, 0],
		onShow: function() {
			this.getTip().delay(5000).fadeTo("slow", 0);
		}
	});
	jQuery("#archive_small_submenu").tooltip({
		tip: '#news_tooltip',
		effect: "fade",
		offset: [0, 0],
		onShow: function() {
			this.getTip().delay(5000).fadeTo("slow", 0);
		}
	});
	jQuery("#partners_small_submenu").tooltip({
		tip: '#partners_tooltip',
		effect: "fade",
		offset: [0, 0],
		onShow: function() {
			this.getTip().delay(5000).fadeTo("slow", 0);
		}
	});
	jQuery("#profile_small_submenu").tooltip({
		tip: '#profile_tooltip',
		effect: "fade",
		offset: [0, 0],
		onShow: function() {
			this.getTip().delay(5000).fadeTo("slow", 0);
		}
	});
	jQuery("#highlights_small_submenu").tooltip({
		tip: '#highlights_tooltip',
		effect: "fade",
		offset: [0, 0],
		onShow: function() {
			this.getTip().delay(5000).fadeTo("slow", 0);
		}
	});
	jQuery("#team_small_submenu").tooltip({
		tip: '#team_tooltip',
		effect: "fade",
		offset: [0, 0],
		onShow: function() {
			this.getTip().delay(5000).fadeTo("slow", 0);
		}
	});
	jQuery("#gallery_small_submenu").tooltip({
		tip: '#gallery_tooltip',
		effect: "fade",
		offset: [0, 0],
		onShow: function() {
			this.getTip().delay(5000).fadeTo("slow", 0);
		}
	});
	jQuery("#video_small_submenu").tooltip({
		tip: '#video_tooltip',
		effect: "fade",
		offset: [0, 0],
		onShow: function() {
			this.getTip().delay(5000).fadeTo("slow", 0);
		}
	});
	
	
	
	/**
	 * Rotates sponsors logos in bottom right corner of page
	 * Loops through sponsors for continuous flow
	 */
	jQuery(".sponsor-rotator").jCarouselLite({
		visible: 3,
		vertical: true,
		auto: 2500,
		speed: 1500,
		easing: "backinout"
	});
	
	jQuery('#kk_banner_ads').cycle({ 
		timeout: 5000,
    	speed: 1000
	});
	
	//Hide video controls initially
	if(browser != 'Microsoft Internet Explorer') {
		jQuery("#controls-box").fadeTo(0, 0);
	} else {
		jQuery("#controls-box").css("display", 'none');
	}

	//Fade Background image on home page
	jQuery("#video_thumb").click(function () {
		jQuery("#posterwall").fadeTo(2500, 0, embedVideo(videoID));
	});
		
	//Initialize the Background Video
	jQuery.getScript(videosUrl);
	
	//Show the tooltip with instructions on using the submenu & video controls
	jQuery("#news_small_submenu").tooltip().show();
	jQuery("#archive_small_submenu").tooltip().show();
	jQuery("#profile_small_submenu").tooltip().show();
	jQuery("#team_small_submenu").tooltip().show();
	jQuery("#gallery_small_submenu").tooltip().show();
	jQuery("#video_small_submenu").tooltip().show();
	jQuery("#partners_small_submenu").tooltip().show();
	jQuery("#highlights_small_submenu").tooltip().show();
	
	
    /**
	* KK Submenu Effect (Visual Menu)
	* Hovering over menu bring the menu to the front
	* Above all other content on the page
	*/
	jQuery("#news_small_submenu").hover(function() {
	    jQuery("#main_page_content").css("z-index", 85);
		jQuery("#news_small_submenu").css("z-index", 86);
	}, function() {
    	jQuery("#main_page_content").delay(5000).css("z-index", 86);
		jQuery("#news_small_submenu").delay(5000).css("z-index", 85);
    });
	jQuery("#archive_small_submenu").hover(function() {
	    jQuery("#main_page_content").css("z-index", 85);
		jQuery("#archive_small_submenu").css("z-index", 86);
	}, function() {
    	jQuery("#main_page_content").delay(5000).css("z-index", 86);
		jQuery("#archive_small_submenu").delay(5000).css("z-index", 85);
    });
	jQuery("#profile_small_submenu").hover(function() {
	    jQuery("#main_page_content").css("z-index", 85);
		jQuery("#profile_small_submenu").css("z-index", 86);
	}, function() {
    	jQuery("#main_page_content").css("z-index", 86);
		jQuery("#profile_small_submenu").css("z-index", 85);
    });
	jQuery("#team_small_submenu").hover(function() {
	    jQuery("#main_page_content").css("z-index", 85);
		jQuery("#team_small_submenu").css("z-index", 86);
	}, function() {
    	jQuery("#main_page_content").css("z-index", 86);
		jQuery("#team_small_submenu").css("z-index", 85);
    });
	jQuery("#partners_small_submenu").hover(function() {
	    jQuery("#main_page_content").css("z-index", 85);
		jQuery("#partners_small_submenu").css("z-index", 86);
	}, function() {
    	jQuery("#main_page_content").css("z-index", 86);
		jQuery("#partners_small_submenu").css("z-index", 85);
    });
	
	
	jQuery(".show_hide_btn").click( function() {
		if (jQuery("#ShowHide").is(":hidden")) {
			jQuery("#page_small_submenu").animate({ 
				marginBottom: "45px"
			}, 700 );
			jQuery(".show_hide_btn").html('<div class="hide-btn"><a href="javascript: void(0)" id="hide-btn-link">Hide</a></div>');
			jQuery("#ShowHide").show();
		} else {
			jQuery("#page_small_submenu").animate({ 
				marginBottom: "-106px"
			}, 700 );
			jQuery(".show_hide_btn").html('<div class="show-btn"><a href="javascript: void(0)" id="show-btn-link">Show</a></div>');
			jQuery("#ShowHide").hide();
		}
	}); 
	
	jQuery(".show_hide_btn_2").click( function() {
		if (jQuery("#ShowHide").is(":hidden")) {
			jQuery("#page_small_submenu_2").animate({ 
				marginBottom: "45px"
			}, 700 );
			jQuery(".show_hide_btn_2").html('<div class="hide-btn"><a href="javascript: void(0)" id="hide-btn-link">Hide</a></div>');
			jQuery("#ShowHide").show();
		} else {
			jQuery("#page_small_submenu_2").animate({ 
				marginBottom: "-106px"
			}, 700 );
			jQuery(".show_hide_btn_2").html('<div class="show-btn"><a href="javascript: void(0)" id="show-btn-link">Show</a></div>');
			jQuery("#ShowHide").hide();
		}
	}); 
	
	jQuery(".show_hide_arrows_top").click( function() {
		if (jQuery("#ShowHide").is(":hidden")) {
			ShowMenu();
		} else {
			HideMenu();
		}
	}); 
	
	jQuery("#archive_small_items").jCarouselLite({
		btnNext: ".arrow_small_rt",
        btnPrev: ".arrow_small_lt",
		visible: 3,
		speed: 1500,
		easing: "backinout",
		scroll: 3
	});
	
	//Load the news article selected
	jQuery(".thumbnail").click(function() {	
	   articleID = jQuery(this).attr('href').match(/#([0-9]+)/)[1]; //Get the Article ID
	   jQuery("#posterwall_wrapper").fadeOut("slow"); 	//Fade out the current background image
	   jQuery("#page_content_middle_skinny").load("/Application/loadarticle.php?article=" + articleID);	//Load the new article text
	   jQuery("#posterwall_wrapper").load("/Application/loadbkgnd.php?article=" + articleID);	//Load the new background image
	   pageContentHeight = jQuery("#page_content_middle_skinny").height();
	   divFooterPosition = pageContentHeight + 185;
	   jQuery("#footer-box").css("top", divFooterPosition);
	   jQuery("#posterwall_wrapper").fadeIn("slow");	//Fade in the new background image
	});
	
	//Load the partner selected
	jQuery(".partner_thumbnail").click(function() {	
	   partnerID = jQuery(this).attr('href').match(/#([0-9]+)/)[1]; //Get the Article ID
	   jQuery("#page_content_middle_skinny").load("/Application/loadpartner.php?partner=" + partnerID);	//Load the new article text
	});
	
	//Load the career highlight selected
	jQuery(".highlight_thumbnail").click(function() {	
	   highlightID = jQuery(this).attr('href').match(/#([0-9]+)/)[1]; //Get the Article ID
	   jQuery("#posterwall_wrapper").fadeOut("slow"); 	//Fade out the current background image
	   jQuery("#posterwall_wrapper").load("/Application/loadhighlight.php?highlight=" + highlightID);	//Load the new background image
	   jQuery("#posterwall_wrapper").fadeIn("slow");	//Fade in the new background image
	});
	
	
	//Declare variables for photo slideshow
	var photoURL = '';
	var photoID = '';
	var prevImg = '';
	var nextImg = '';
	var prevImgID = '';
	var nextImgID = '';
	
	//Load the selected photo into the background
	jQuery(".photo_thumbnail").click(function() {	
	   
	    photoURL = jQuery(this).attr('name'); //Get the photo url
		photoID = jQuery(this).attr('id'); //Get the photo ID
	    
		//Get the next image ID
		prevImg = jQuery('li#' + photoID).prev().children().attr("name");
		prevImgID = jQuery('li#' + photoID).prev().children().attr("id");
		nextImg = jQuery('li#' + photoID).next().children().attr("name");
		nextImgID = jQuery('li#' + photoID).prev().children().attr("id");
		jQuery(".photo-prev").html('<a href="javascript: void(0)" name="' + prevImg + '" id="photo-prev-link" class="' + prevImgID + '">Previous</a>');
		jQuery(".photo-next").html('<a href="javascript: void(0)" name="' + nextImg + '" id="photo-next-link" class="' + nextImgID + '">Next</a>');
		
		//Change the background image
		jQuery("#posterwall_wrapper").fadeTo('slow', 0);
		jQuery("#posterwall").attr("src", photoURL);
		jQuery("#posterwall_wrapper").fadeTo('slow', 100);
	
		//Hide the menus
		HideMenu();
		
	});
	
	jQuery(".photo-prev").click(function() {	
	   
		photoURL = jQuery(this).children().attr('name'); //Get the photo url
		photoID = jQuery(this).children().attr('class'); //Get the photo ID
				
		//Get the next image ID
		prevImg = jQuery('li#' + photoID).prev().children().attr("name");
		prevImgID = jQuery('li#' + photoID).prev().children().attr("id");
		if (typeof prevImg == 'undefined') {
			prevImg = jQuery('li').last().children().attr("name");
			prevImgID = jQuery('li').last().children().attr("id");
		}
		nextImg = jQuery('li#' + photoID).next().children().attr("name");
		nextImgID = jQuery('li#' + photoID).next().children().attr("id");
		jQuery(".photo-prev").html('<a href="javascript: void(0)" name="' + prevImg + '" id="photo-prev-link" class="' + prevImgID + '">Previous</a>');
		jQuery(".photo-next").html('<a href="javascript: void(0)" name="' + nextImg + '" id="photo-next-link" class="' + nextImgID + '">Next</a>');
		//alert(prevImg);
	
		//Change the background image
		jQuery("#posterwall_wrapper").fadeTo('slow', 0);
		jQuery("#posterwall").attr("src", photoURL);
		jQuery("#posterwall_wrapper").fadeTo('slow', 100);
	
		//Hide the menus
		//HideMenu();
		
	});
	
	jQuery(".photo-next").click(function() {	
	   
	    photoURL = jQuery(this).children().attr('name'); //Get the photo url
		photoID = jQuery(this).children().attr('class'); //Get the photo ID
	    
		//Get the next image ID
		prevImg = jQuery('li#' + photoID).prev().children().attr("name");
		prevImgID = jQuery('li#' + photoID).prev().children().attr("id");
		nextImg = jQuery('li#' + photoID).next().children().attr("name");
		nextImgID = jQuery('li#' + photoID).next().children().attr("id");
		jQuery(".photo-prev").html('<a href="javascript: void(0)" name="' + prevImg + '" id="photo-prev-link" class="' + prevImgID + '">Previous</a>');
		jQuery(".photo-next").html('<a href="javascript: void(0)" name="' + nextImg + '" id="photo-next-link" class="' + nextImgID + '">Next</a>');
		//alert(prevImg);
	
		//Change the background image
		jQuery("#posterwall_wrapper").fadeTo('slow', 0);
		jQuery("#posterwall").attr("src", photoURL);
		jQuery("#posterwall_wrapper").fadeTo('slow', 100);
	
		//Hide the menus
		//HideMenu();
		
	});
	
	//Schedule Toggle (Show/Hide extra content)
	jQuery(".schedule_extra").hide();

	jQuery("#item_more").toggle(function(){
		jQuery(this).text("[-]");
		}, function () {
		jQuery(this).text("[+]"); 
	});
	
	jQuery(".schedule_container").click(function(){
		jQuery(this).next(".schedule_extra").slideToggle("slow");
	});
	
	//Results Toggle (Show/Hide extra content)
	jQuery(".results_extra").hide();

	jQuery("#results_more").toggle(function(){
		jQuery(this).text("[-]"); 
		}, function () {
		jQuery(this).text("[+]"); 
	});
	
	jQuery(".results_container").click(function(){
		jQuery(this).next(".results_extra").slideToggle("slow");
	});
		
});

/**
* Home Page Video Player Embed Code
* Embeds latest video from Vimeo
* Background image fade out, then video appears
*/
function latestVideo(videos) {
	videoID = videos[0].id;
	videoThumbnail = videos[0].thumbnail_large;
	jQuery('#video_thumb').prepend('<img src="' + videoThumbnail + '" width="248" height="153" alt="" border="0" />');
}

//Show the Video Controls
function show_controls() {
	Swiff.remote(moogaloop, 'api_addEventListener', 'onFinish', 'video_on_stop');
	if(browser != 'Microsoft Internet Explorer') {
		jQuery("#controls-box").fadeTo('slow', 100);
		jQuery("#controls-box").css("z-index", 51);
		jQuery("#footer-box").fadeTo('slow', 0);
		jQuery("#footer-box").css("z-index", 50);
		jQuery("#sponsors-box").fadeTo('slow', 0);
		jQuery("#news-box").fadeTo('slow', 0);
		jQuery("#feature-box").fadeTo('slow', 0);
		jQuery("#video_submenu").fadeTo('slow', 0);
		jQuery(".gallery-back-btn").fadeTo('slow', 0);
		
		//Shift the header up and hide kk sig
		jQuery("#kk_header").animate({ 
			marginTop: "-84px"
		}, 'slow', 'linear' );
		jQuery("#kk_menu").animate({ 
			marginTop: "0px"
		}, 'slow', 'linear' );
		jQuery("#grey_bkgnd").animate({ 
			marginTop: "-84px"
		}, 'slow', 'linear' );
		jQuery("#subnav_bkgnd").animate({ 
			marginTop: "-84px"
		}, 'slow', 'linear' );
		jQuery(".kk-signature").fadeTo('slow', 0);
		jQuery("#kk_logo_bar").fadeTo('slow', 100);
		
		//Hide the videos playlist
		jQuery("#page_small_submenu_arrows").animate({ 
			marginBottom: "-106px"
		}, 700, 'linear' );
		jQuery(".show_hide_arrows_top").html('<div class="show-btn"><a href="#" id="show-btn-link">Show</a></div>');
		jQuery("#ShowHide").hide();
			
	} else {
		jQuery("#controls-box").css("display", 'block');
		jQuery("#footer-box").css("display", 'none');
		jQuery("#sponsors-box").css("display", 'none');
		jQuery("#news-box").css("display", 'none');
		jQuery("#feature-box").css("display", 'none');
		jQuery("#video_submenu").css("display", 'none');
		jQuery(".gallery-back-btn").css("display", 'none');
		jQuery("#kk_logo_bar").css("display", 'block');
		
		//Shift the header up and hide kk sig
		jQuery("#kk_header").animate({ 
			marginTop: "-84px"
		}, 'slow', 'linear' );
		jQuery("#kk_menu").animate({ 
			marginTop: "0px"
		}, 'slow', 'linear' );
		jQuery("#grey_bkgnd").animate({ 
			marginTop: "-84px"
		}, 'slow', 'linear' );
		jQuery("#subnav_bkgnd").animate({ 
			marginTop: "-84px"
		}, 'slow', 'linear' );
		jQuery(".kk-signature").css("display", 'none');
		
		//Hide the videos playlist
		jQuery("#page_small_submenu_arrows").animate({ 
			marginBottom: "-106px"
		}, 700, 'linear' );
		jQuery(".show_hide_arrows_top").html('<div class="show-btn"><a href="#" id="show-btn-link">Show</a></div>');
		jQuery("#ShowHide").hide();
		
		
	}
	
	//Show the tooltip with instructions on using the video controls
	jQuery("#video_control").tooltip().show();
	
}

function video_on_play() {
	Swiff.remote(moogaloop, 'api_play');
}

function video_on_pause() {
	Swiff.remote(moogaloop, 'api_pause');
}
function video_on_stop() {
	Swiff.remote(moogaloop, 'api_pause');
	Swiff.remote(moogaloop, 'api_seekTo', 0);
	if(browser != 'Microsoft Internet Explorer') {
		jQuery("#posterwall").fadeTo(2500, 100);
		jQuery("#controls-box").fadeTo('slow', 0);	
		jQuery("#controls-box").css("z-index", 50);
		jQuery("#footer-box").fadeTo('slow', 100);
		jQuery("#footer-box").css("z-index", 51);
		jQuery("#sponsors-box").fadeTo('slow', 100);
		jQuery("#news-box").fadeTo('slow', 100);
		jQuery("#feature-box").fadeTo('slow', 100);
		jQuery("#video_submenu").fadeTo('slow', 100);
		jQuery(".gallery-back-btn").fadeTo('slow', 100);
		
		//Shift the header up and hide kk sig
		jQuery("#kk_header").animate({ 
			marginTop: "0px"
		}, 'slow', 'linear' );
		jQuery("#kk_menu").animate({ 
			marginTop: "84px"
		}, 'slow', 'linear' );
		jQuery("#grey_bkgnd").animate({ 
			marginTop: "0px"
		}, 'slow', 'linear' );
		jQuery("#subnav_bkgnd").animate({ 
			marginTop: "0px"
		}, 'slow', 'linear' );
		jQuery(".kk-signature").fadeTo('slow', 100);
		jQuery("#kk_logo_bar").fadeTo('slow', 0);
		
		//Show the videos playlist
		jQuery("#page_small_submenu_arrows").animate({ 
			marginBottom: "45px"
		}, 700, 'linear' );
		jQuery(".show_hide_arrows_top").html('<div class="hide-btn"><a href="javascript: void(0)" id="hide-btn-link">Hide</a></div>');
		jQuery("#ShowHide").show();
			
	} else {
		jQuery("#posterwall").fadeTo(2500, 100);
		jQuery("#controls-box").css("display", 'none');
		jQuery("#footer-box").css("display", 'block');
		jQuery("#sponsors-box").css("display", 'block');
		jQuery("#news-box").css("display", 'block');
		jQuery("#feature-box").css("display", 'block');
		jQuery("#video_submenu").css("display", 'block');
		jQuery(".gallery-back-btn").css("display", 'block');
		
		//Shift the header up and hide kk sig
		jQuery("#kk_header").animate({ 
			marginTop: "0px"
		}, 'slow', 'linear' );
		jQuery("#kk_menu").animate({ 
			marginTop: "84px"
		}, 'slow', 'linear' );
		jQuery("#grey_bkgnd").animate({ 
			marginTop: "0px"
		}, 'slow', 'linear' );
		jQuery("#subnav_bkgnd").animate({ 
			marginTop: "0px"
		}, 'slow', 'linear' );
		jQuery(".kk-signature").css("display", 'block');
		jQuery("#kk_logo_bar").css("display", 'none');
		
		//Show the videos playlist
		jQuery("#page_small_submenu_arrows").animate({ 
			marginBottom: "45px"
		}, 700, 'linear' );
		jQuery(".show_hide_arrows_top").html('<div class="hide-btn"><a href="javascript: void(0)" id="hide-btn-link">Hide</a></div>');
		jQuery("#ShowHide").show();
	}
}

function embedVideo(video_id) {
	var swf_id = 'video';
	moogaloop = new Swiff('http://vimeo.com/moogaloop.swf', {
		id: swf_id,
		container: 'video',	
		width: 1280,
		height: 720,
		vars: {
			clip_id: video_id,
			show_portrait: 0,
			show_byline: 0,
			show_title: 0,
			autoplay: 1,
			js_api: 1, // required in order to use the Javascript API
			js_onLoad: 'show_controls', // moogaloop will call this JS function when it's done loading (optional)
			js_swf_id: 'video' // this will be passed into all event methods so you can keep track of multiple moogaloops (optional)
		},
		params: {
			allowscriptaccess: 'always',
			allowfullscreen: 'true',
			wmode: 'transparent'
		}
	}).toElement();
	
}

function showArchiveVideo(video_id) {

	jQuery("#posterwall").fadeTo(2500, 0, embedVideo(video_id));
	//jQuery("#posterwall").fadeTo(2500, 0);
	
}

function HideHeader() {	
	  //Shift the header up and hide kk sig
	  jQuery("#kk_header").animate({ 
		  marginTop: "-84px"
	  }, 'slow', 'linear' );
	  jQuery("#kk_menu").animate({ 
		  marginTop: "0px"
	  }, 'slow', 'linear' );
	  jQuery("#grey_bkgnd").animate({ 
		  marginTop: "-84px"
	  }, 'slow', 'linear' );
	  jQuery("#subnav_bkgnd").animate({ 
		  marginTop: "-84px"
	  }, 'slow', 'linear' );
	  jQuery(".kk-signature").fadeTo('slow', 0);
	  jQuery("#kk_logo_bar").fadeTo('slow', 100);
}
function ShowHeader() {	
	  //Shift the header up and hide kk sig
	  jQuery("#kk_header").animate({ 
		  marginTop: "0px"
	  }, 'slow', 'linear' );
	  jQuery("#kk_menu").animate({ 
		  marginTop: "84px"
	  }, 'slow', 'linear' );
	  jQuery("#grey_bkgnd").animate({ 
		  marginTop: "0px"
	  }, 'slow', 'linear' );
	  jQuery("#subnav_bkgnd").animate({ 
		  marginTop: "0px"
	  }, 'slow', 'linear' );
	  jQuery(".kk-signature").fadeTo('slow', 100);
	  jQuery("#kk_logo_bar").fadeTo('slow', 0);
}
function HideMenu() {
	jQuery("#page_small_submenu_arrows").animate({ 
		marginBottom: "-106px"
	}, 700, 'linear' );
	jQuery(".show_hide_arrows_top").html('<div class="show-btn"><a href="javascript: void(0)" id="show-btn-link">Show</a></div>');
	jQuery("#ShowHide").hide();
	HideHeader();
	
	if(browser != 'Microsoft Internet Explorer') {
		jQuery("#controls-box").fadeTo('slow', 100);
		jQuery("#controls-box").css("z-index", 51);
		jQuery("#footer-box").fadeTo('slow', 0);
		jQuery("#footer-box").css("z-index", 50);
	} else {
		jQuery("#controls-box").css("display", 'block');
		jQuery("#footer-box").css("display", 'none');
	}
}
function ShowMenu() {
	jQuery("#page_small_submenu_arrows").animate({ 
		marginBottom: "45px"
	}, 700, 'linear' );
	jQuery(".show_hide_arrows_top").html('<div class="hide-btn"><a href="javascript: void(0)" id="hide-btn-link">Hide</a></div>');
	jQuery("#ShowHide").show();
	ShowHeader();
	
	if(browser != 'Microsoft Internet Explorer') {
		jQuery("#controls-box").fadeTo('slow', 0);
		jQuery("#controls-box").css("z-index", 50);
		jQuery("#footer-box").fadeTo('slow', 100);
		jQuery("#footer-box").css("z-index", 51);
	} else {
		jQuery("#controls-box").css("display", 'none');
		jQuery("#footer-box").css("display", 'block');
	}
}
