/* Author: 

*/
var thisisopen	= '';
var talentshowing	= '';
var randomImagesDir	= (window.location.href.indexOf("/fr") > -1) ? "../images/" : "images/";

$(document).ready(function(){
	//RANDOM IMAGE
	var rand = Math.floor(Math.random() * 7);
	$('#leftCol').css('background-image','url(' + randomImagesDir + rand + '.jpg)');
	
	//NAV
	$('.internallink').click(function(e){
		e.preventDefault();
		
		var showthis = $(this).attr('href');
		//console.log('showthis : ' + showthis + ' ; docshowing : ' + docshowing);
		//if( showthis == docshowing ) { return; }
		
		switch( showthis.substr(1) )
		{
			default:
				$('#alt').hide();
				$('.talent-container').hide();
				$('#main').show();
				$('.info-col').hide();
				$(showthis).show();
			break;
			
			case "portfolio":
				$('.info-col').hide();
				$("#main").hide();
				$("#alt").load("portfolio/portfolio.php?proj=all", function(){
					// PORTFOLIO
					// NOTE:
					// this has to be inside this func because otherwise the "ajaxLoadedDeepBtn" class
					// links won't be loaded.
					$(".ajaxLoadedDeepBtn").click(function(e){
						e.preventDefault();
						
						var page = $(this).attr("id").substr($(this).attr("id").lastIndexOf("=")+1);
						$.colorbox({href:"portfolio/portDetail.php?proj="+page});
					});
				}).show();				
			break;
		}
	});
	
	//TALENT
	$('#info-talent').find('li').find('a').click(function(e){
		e.preventDefault();
		
		var showthis = $(this).attr('href');
		
		if (talentshowing == '') {
			$(showthis).show();
		}
		else {
			$(talentshowing).hide();
			$(showthis).show();
		}
		talentshowing =  showthis;		
	});
	
	$('#leftCol').find('.close-talent').click(function(e){
		e.preventDefault();
		$(this).parent().hide();
	});

	//FOOTER DROPDOWN
	$('footer .showdown').click(function(e){
	e.preventDefault();
	
		$('footer a').removeClass('addunderline');
		$(this).addClass('addunderline');
					
		var showthis = $(this).attr('href');
		
		if (thisisopen == '') {
			$(showthis).slideDown('fast');
			thisisopen = showthis;
		}
		else if (thisisopen == showthis) {
			$(showthis).slideUp('fast');
			thisisopen = '';
			$(this).removeClass('addunderline');
		}		
		else if (thisisopen != '') {
			$(thisisopen).slideUp('fast',
				function(){
					$(showthis).slideDown('fast');
					thisisopen = showthis;
				}
			)
		}
	});
	
	//var kent = (statement)? true : false
});
