/*
ASM Core JavaScript
By: Junaid Bhura
www.junaidbhura.com
*/

$(document).ready(function(){
	/* DROP DOWN MENU START */
	$('#nav').jmenu({animation:'slide',duration:300});
	/* DROP DOWN MENU END */
	
	/* HOME PAGE SLIDER START */
	if($('#home-slider').length != 0) {
		$('#home-slider').nivoSlider({ effect:"slideInLeft", directionNavHide: false, animSpeed: 350, pauseTime: 6000 });
	}
	/* HOME PAGE SLIDER END */
	
	/* MAIN SEARCH START */
	if($('#search-container .search-field').attr('value') == '')
		$('#search-container .search-field').attr('value', 'Search');
	
	$('#search-container .search-field').click(function(){
		if($(this).attr('value') == 'Search')
			$(this).attr('value', '');
	});
	$('#search-container .search-field').blur(function(){
		if($(this).attr('value') == '')
			$(this).attr('value', 'Search');
	});
	/* MAIN SEARCH END */
	
	/* FOOTER SITEMAP START */
	$('.view-sitemap').click(function(){
		if($(this).is('.open')) {
			$('#footer .footer-content .sitemap-container').fadeOut();
			$(this).removeClass('open');
		}
		else {
			$('#footer .footer-content .sitemap-container').css('top', '-' + ($('#footer .footer-content .sitemap-container').height() + 60 + 3) + 'px'); // 60 (30 pixels padding top and bottom) + 3 (3 pixels orange border of the footer)
			$('#footer .footer-content .sitemap-container').fadeIn();
			$(this).addClass('open');
		}
		return false;
	});
	// If user clicks on the sitemap container it doesn't fade out
	$('#footer .footer-content .sitemap-container').click(function(){
		return false;
	});
	// If user clicks on the sitemap links, it should go through
	$('#footer .footer-content .sitemap-container a').click(function(e){
		e.stopPropagation();
		return true;
	});
	// If user clicks anywhere in the document, it fades out
	$(document).click(function(){
		$('#footer .footer-content .sitemap-container').fadeOut();
		$('.view-sitemap').removeClass('open');
	});
	/* FOOTER SITEMAP START */
});
