$(document).ready(function(){
	
	/* -------------- Activate Nivo-Slider -------------- */
  	if($.browser.msie && $.browser.version=="7.0" || $.browser.msie && $.browser.version=="8.0"){
		$('#home_splash').nivoSlider({
			effect: 'fade',
			animSpeed: 500,
			pauseTime: 5500,
			startSlide: 0,
			directionNav: true,
			directionNavHide: false,
			controlNav: true,
			afterLoad: function(){
				$('.nivo-controlNav').css('left',(958 - $('.nivo-controlNav').width()) / 2);
			}
		});
	}
	else{
		$('#home_splash').nivoSlider({
			effect: 'fade',
			animSpeed: 500,
			pauseTime: 5500,
			startSlide: 0,
			directionNav: true,
			directionNavHide: false,
			controlNav: true,
			keyboardNav: false,
			pauseOnHover: true,
			manualAdvance: false,
			captionOpacity: 1,
			afterLoad: function(){
				$('.nivo-controlNav').css('left',(958 - $('.nivo-controlNav').width()) / 2);
			}
		});
 	}
	
	/* -------------- For hide/show search value -------------- */
	$('#search input').focus(function(){
		$(this).parent().addClass('focus');
		if(this.value == 'Search website...' ) this.value='';
	}).focusout(function(){
		$(this).parent().removeClass('focus');
		if(this.value == '') this.value='Search website...';
	});
	
	/* -------------- For last elements -------------- */
	$('.bottom_menu_nav li:last').addClass('last');
	$('.footer_content > ul > li:last').css('margin','0 0 10px 30px');
	$('.coust_location_widget ul:first-child > li:last').css('margin-right','0');
	$('.location_menu ul:first-child > li:last').css('padding-bottom','10px');

	/* -------------- Main Navigation menu -------------- */
	
	/* Open sub menu */
	$('#mainnav ul:first-child > li').hover(function(){
		$(this).addClass('active');
	},function(){
		$(this).removeClass('active');
	});
	
	/* Inner arrow if have sub-menu */
	$('#mainnav ul > li').each(function(){
		if($(this).find('ul').hasClass('sub-menu'))
		{
			$(this).children('a').html($(this).children('a').text()+''+$('.hidden_arrow').html());	
		}
	});
		
	/* -------------- Location menu -------------- */
	$('.toggle_location_menu').click(function(){
		$(this).parents('.header_location_top').toggleClass('open');
		$('.location_menu').toggle('fast');
		return false;
	});
		
	$('body').click(function(){
		if($('.location_menu').css('display') == "block")
		{
			$('.location_menu').toggle('fast');
			$('.header_location_top').toggleClass('open');
		}
	});	
	
	/* Hack for IE 7 */
    $('.sub-menu li a').each(function(){
		$(this).width($(this).parents('.sub-menu').width() - 40);
	});	
	 $('.latest-promo').each(function() {
            PIE.attach(this);
    });
});
