/* -------------------------------------------------------------------

	Boondoggle - Hans Dreesen
	Stichting Marketing
	
	This JavaScript file collects all general functions used
	throughout the site, as well as some smaller specific
	functions.

------------------------------------------------------------------- */



// when the document is ready to be traversed and manipulated...
$(document).ready(function(){
	
	
	// LINK HANDLER
	// when you click on a link with class externalLink
	$("a.externalLink, ul#sponsors a, ul.sponsorList a").click(function(){
		// open a new window with the link's location
		window.open($(this).attr("href"));
		// and do nothing after (to prevent the link from actually firing)
		return false;
	});
	
	// TWITTER FEED TABS
	$("#twitterFeed #showTab1").click(function() {
		$("#twitterFeed #tab1").css("display","block");
		$("#twitterFeed #showTab1").addClass("active");
		$("#twitterFeed #tab2").css("display","none");	
		$("#twitterFeed #showTab2").removeClass("active");
	})	
	$("#twitterFeed #showTab2").click(function() {
		$("#twitterFeed #tab2").css("display","block");
		$("#twitterFeed #showTab2").addClass("active");		
		$("#twitterFeed #tab1").css("display","none");	
		$("#twitterFeed #showTab1").removeClass("active");		
	})	
	
	// PROGRAMME
	/* layout */
	$("body#programme table tr td:first-child").addClass("time");
	/* sliding */
	var progCol01 = $(".progFancy #content #progCol01");
	var progCol02 = $(".progFancy #content #progCol02");
	
	function animateLeftTo(element, pxPosLeft){
		element.animate({left: pxPosLeft}, {queue:false,duration:200});
	};
	
	function initCols(active){
		var animation = false;
		activeCol = active;
		activeCol.removeClass("hidden").addClass("active");
		activeCol.find("img").css({opacity: 1});
		$(".mask").remove();
		hiddenCol = $(".progFancy #content .progCol").not(activeCol);
		hiddenCol.removeClass("active").addClass("hidden").prepend("<span class='mask'></span>");
		hiddenCol.find("img").css({opacity: 0.3});
		hiddenCol.hover(
			function(){
				if(!$(this).hasClass("active") && !animation){
					if($(this).is("#progCol01"))
						{animateLeftTo(activeCol, -340)}
					else
						{animateLeftTo($(this), -10)}
				}
			},
			function(){
				if(!$(this).hasClass("active") && !animation){
					if($(this).is("#progCol01"))
						{animateLeftTo(activeCol, -350)}
					else
						{animateLeftTo($(this), 0)}
				}
			}
		);
		hiddenCol.click(function(){
			if(!$(this).hasClass("active")){
				animation = true;
				if($(this).is("#progCol01")){
					activeCol.css({backgroundColor:"transparent"}).animate(
						{left:0},
						{queue:false, duration:500, complete:function(){initCols($("#progCol01"))} }
					)
				}else{
					$(this).css({backgroundColor:"#FFF"}).animate(
						{left:-350},
						{queue:false, duration:500, complete:function(){initCols($(this))} }
					)
				}
			}
		});
	}
	initCols($(".progFancy #content #progCol01"));
	
	
	// CONGRESS COMMISSION
	$("#ccPhotos").addClass("ccPhotosFancy");
	$("#ccMemberList").addClass("ccMemberListFancy");
	var classOrId;
	function highlight(attrName){
			$("#ccPhotos img").filter("#" + attrName).animate({marginTop:"-15px"}, 200, "linear");
			$("#ccMemberList tr").filter("." + attrName).addClass("hover");
	}
	function unhighlight(attrName){
			$("#ccPhotos img").filter("#" + attrName).animate({marginTop:"0px"}, 200, "linear");
			$("#ccMemberList tr").filter("." + attrName).removeClass("hover");
	}
	$("#ccPhotos img").hover(
		function(){
			classOrId = $(this).attr("id");
			highlight(classOrId);
		},
		function(){
			unhighlight(classOrId);
		}
	)
	$("#ccMemberList tr").hover(
		function(){
			classOrId = $(this).attr("class");
			highlight(classOrId);
		},
		function(){
			unhighlight(classOrId);
		}		
	)
	
});

