$(document).ready(function(){ 	
	
	/*centering subnav*/
	$("#nav li.hoverable").each( function(){
		var thiner = $(this).width();
		var largest = $('ul',this).width();
		var diff = (largest - thiner)/2;
		$('ul', this).css( 'margin-left', -(diff) );		
	});

	$('ul#homeNews').accordion({
		header: 'h3',
		autoheight: false 
	});
	
	$('ul#offers').accordion({
		header: 'h3',
		autoheight: false, 
		active: false,
		collapsible: true
	});
	$('#lastestOffers .oh').accordion({
		header: 'h4',
		autoheight: false, 
		alwaysOpen: false,
		active: false,
		collapsible: true
	});
	/*Simlulate clic*/
	$("a[rel^='accordionJobOffer']").click( function (){
		var data = $(this).attr('data');
		$( "#" + data ).click();
	}); 
	
	$('ul.accordionLikeStyle').accordion({
		header: '.title',
		autoheight: false 
	});

	$('.homeNews-image-first').show();
	$('.homeNews-image').hide();
	
	var higher = 0;
	if ( document.getElementById( 'colRight' ) && document.getElementById( 'colLeft') ){
		if ( document.getElementById( 'colRight' ).offsetHeight > higher ) higher = document.getElementById( 'colRight' ).offsetHeight;
		if ( document.getElementById( 'colLeft').offsetHeight > higher ) higher = document.getElementById( 'colLeft').offsetHeight;
	document.getElementById( 'colRight' ).style.minHeight = document.getElementById( 'colLeft' ).style.minHeight = higher + "px";
	}
	
	$('.mgList a').hover(function(){
		$('.mgScreen img').attr('src', this.href);
		return false;
	}).click(function(){
		$('.mgScreen img').attr('src', this.href);
		return false;
	});
	
	/*validate*/
	$('#contactus').validate();
	
	$('.selected .lvl2').each(function(){
		var width = $(this).width();
		var margin = (150 - width)/2;
		$(this).children().next().css('margin-left', - margin);
	});
	
	// main navigation
	$("#nav-main ul").superfish();													 
	
});

function getNewsID( id )
{
	if ( $('.homeNews-image').attr( "style", "display:none" ) )
	{
		$('.homeNews-image-first').hide();
		$('#image-'+id).slideToggle();
	}
}

