$(document).ready(function(){
	
	/* FAQ Accordian */
  	$('div.accordian> div').hide(); 
  	$('div.accordian> h4').click(function() {
  		$('div.accordian> h4').removeClass('on'); 
    	$(this).next('div').slideToggle('slow').siblings('div:visible').slideUp('slow').removeClass('on');
    	$(this).toggleClass("on");
  	});

	//language menu open on mouse over 
	$('#headNav ul.lang').hover(function () {
		clearTimeout($.data(this, 'timeout'));
		$.data(this, 'timeout', setTimeout($.proxy(function () {
			$('#mainNav li').css({ 'position': 'static' });
			$('.header-left').css({ 'position': 'static' });
			$(this).addClass('over');
			$("body").css("margin", "0 0 1px 0");
			$("#mainArea").css("zoom", "1");
		}, this), 200));
	}, function () {
		clearTimeout($.data(this, 'timeout'));
		$.data(this, 'timeout', setTimeout($.proxy(function () {
			$(this).removeClass('over');
			$('#mainNav li').css({ 'position': 'relative' });
			$('.header-left').css({ 'position': 'relative' });
			$("body").css("margin", "0");
			$("#mainArea").css("zoom", "1");
		}, this), 200));
	});

	$("#mainNav .menuCol ul li").hover(function () {
		$(this).addClass("active");
	}, function () {
		$(this).removeClass("active");
	});
	
	//main navigation open on mouse over 
	$('div#mainNav > ul:first > li').hover(function () {	
		clearTimeout($.data(this, 'timeout'));
		$.data(this, 'timeout', setTimeout($.proxy(function () {
			$('#mainNav > ul').addClass('show')
			$(this).addClass('over');
			$("body").css("margin", "0 0 1px 0");
			$("#mainArea").css("zoom", "1");
		}, this), 200));
	}, function () {
		clearTimeout($.data(this, 'timeout'));
		$.data(this, 'timeout', setTimeout($.proxy(function () {
			$(this).removeClass('over');
			$('#mainNav > ul').removeClass('show')
			$("body").css("margin", "0");
			$("#mainArea").css("zoom", "1");
		}, this), 200));
	});
	
	//footer scrollToTop link
	$(".scrollToTop").bind("click", function (e) {
		e.preventDefault();
		$('html, body').animate({ scrollTop: 0 }, 250);
	});
	
	// mainNavigation Width fix
	$(".shadow").each(function () {
		var shadowWidth = 0, colCount = 0, $wr = $("#wrapper"), $this = $(this);
		colCount = $(this).find(".menuCol").length;
		if (colCount > 3) {
			colCount = 3;
		} else {
			colCount--;
		}
		shadowWidth = 264 + (232 * colCount);
		$this.css("width", shadowWidth);

		menuleft = $this.offset().left - $wr.offset().left;
		leftDiff = ($this.width() + menuleft) - $wr.width();
		wright = $wr.offset().left + $wr.width();
		tright = $this.offset().left + $this.width();

		if (tright - wright > 0) {
			finalLeft = parseInt($this.css("left"), 10) - ((tright - wright) + 22);
			$this.css("left", finalLeft);
		};

		setTimeout(function () {
			$(".lang1 .shadowTop").width($(".lang1 .shadow").width() - $(".lang1").width() - 37);
		}, 50);
	});
});
