/************************************************\
» JQuery
\************************************************/

/* scroll panels on WORK ************************/

$(document).ready(function() {	

	//Get the height of the first item
	$('#mask').css({'height':$('#wws-intro').height()});	

	//Calculate the total width - sum of all sub-panels width
	//Width is generated according to the width of #mask * total of sub-panels
	$('#panel').width(parseInt($('#mask').width() * $('#panel div.panelid').length)); // Main tabs
	$('#subpanel').width(parseInt($('#submask').width() * $('#subpanel div').length)); // Sub tabs
	
	//Set the sub-panel width according to the #mask width (width of #mask and sub-panel must be same)
	$('#panel div.panelid').width($('#mask').width()); // Main tabs
	$('#subpanel div').width($('#submask').width()); // Sub tabs
	
	//Get all the links with rel as Main Panel
	$('a[rel=panel]').click(function () {

		//Get the height of the panel
		var panelheight = $($(this).attr('href')).height();

		//Set class for the selected item
		$('a[rel=panel]').removeClass('selected');
		$(this).addClass('selected');	
		
		//Resize the height
		$('#mask').animate({'height':panelheight},{queue:false, duration:500});	
		
		//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor
		$('#mask').scrollTo($(this).attr('href'), 800);		
		
		//Discard the link default behavior
		return false;
	});

	//specification for selections and overs for mainpanel
	$('#map_diag').click(function () { $("#diag a").addClass('selected'); });
	$('#map_work').click(function () { $("#work a").addClass('selected'); });
	$('#map_results').click(function () { $("#results a").addClass('selected'); });
	$('#map_diag, #diag a').hover( 
		function () { 
	    	$('#diag a').addClass("hover"); 
	    	$('#wws-intro .banner_diag').addClass("show"); 
		},
		function () { 
			$('#diag a').removeClass("hover");
	    	$('#wws-intro .banner_diag').removeClass("show"); 
	  	}
	);
	$('#map_work, #work a').hover( 
		function () { 
			$('#work a').addClass("hover"); 
	    	$('#wws-intro .banner_work').addClass("show"); 
		},
		function () { 
			$('#work a').removeClass("hover");
	    	$('#wws-intro .banner_work').removeClass("show"); 
		}
	);
	$('#map_results, #results a').hover(
		function () { 
			$('#results a').addClass("hover"); 
	    	$('#wws-intro .banner_results').addClass("show"); 
		},
		function () {
			$('#results a').removeClass("hover");
	    	$('#wws-intro .banner_results').removeClass("show"); 
		}
	);

	//Get all the links with rel as Sub Panel
	$('a[rel=subpanel]').click(function () {
		
		//Set class for the selected item
		$('a[rel=subpanel]').removeClass('selected');
		$(this).addClass('selected');	
		
		//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor
		$('#submask').scrollTo($(this).attr('href'), 800);		
		
		//Discard the link default behavior
		return false;
	});

	//sidebar image rotation for submenu
	$('#subcoaching').click(function () {
		$('#imgwork').fadeOut(300, function() {
			$('#imgwork').attr('src','temas/gfx/layout/wws_ workCoaching.jpg').fadeIn(300);
		});
	});
	$('#submentoring').click(function () {
		$('#imgwork').fadeOut(300, function() {
			$('#imgwork').attr('src','temas/gfx/layout/wws_ workMentoring.jpg').fadeIn(300);
		});
	});
	$('#subtraining').click(function () {
		$('#imgwork').fadeOut(300, function() {
			$('#imgwork').attr('src','temas/gfx/layout/wws_ workTraining.jpg').fadeIn(300);
		});
	});

});

/* diverse functions ****************************/


