var basehref; // set with jQuery $('base').attr('href');

// on document load
$(function() {

	// set global site url var
	basehref = $('base').attr('href');

	// homepage panels animate
	initHomePanels();
	
	// hide other company menu's
	//companyHide();
	
});

function initHomePanels(){

	// homepage panels animate
	$('.home #header').css({'top':'-70px'});
	$('h3',
		$('.panel',
			$('.home #outer #panels')
			// on mouseleave
			.mouseleave(function(){
			
				$('#header')
				.animate({
					'top':'-70px'
				}, { queue:false, duration:200 }, function() {
					// Animation complete.
				})
			})
		)
		// css
		.css({
			'cursor':'pointer'
		})
		// onclick
		.click(function(){
					
			var lnk = $('a[href!="#"]:first',$(this));
			var target = $(lnk).attr('target');
			var url = $(lnk).attr('href');
			
			var panelclass = $(this).attr('class').replace('panel ',''); // tsja
		
			// redirect
			if(target == '_blank'){
				window.open(url);
				return false;
			} else {
				window.location = url;
				return false;
			}
		
		})
		// on mouseenter
		.mouseenter(function(){
			
			var panelclass = $(this).attr('class').replace('panel ',''); // tsja
			
			$("h3",this)
			.animate({
				'margin-top':'0px'
			}, { queue:false, duration:200 }, function() {
				// Animation complete.
			});
			
			$('.company',
				$('#header')
				.animate({
					'top':'0px'
				}, { queue:false, duration:200 }, function() {
					// Animation complete.
				})
			)
			.fadeOut(100)
			.filter('.'+panelclass)
			.fadeIn(300);
			
		})
		// on mouseleave
		.mouseleave(function(){
		
			$("h3",this)
			.animate({
				'margin-top':'132px'
			}, { queue:false, duration:500 }, function() {
				// Animation complete.
			});
			
		})
	)
	// css (hidden on load)
	.css({
		'margin-top':'132px'
	});
}
