$(document).ready(function() {
	$("img").lazyload({
	    effect:"fadeIn",
	    placeholder: conf['www_root']+"/images/grey.gif"
	});
	
	// Watermark search and newsletter inputs
	$("#header input").Watermark("Find The Best Deals Now");
	$("#footer input").Watermark("Your Email Address", {color: '#f0840b'});

	// Header category menu fade in/out effect
	$("#header div.menu").mouseenter(function() {
		$("#category_menu").stop().fadeTo(500, 0.95).css('opacity', '0.95');
	});
	$("#header div.menu").mouseleave(function() {
		$("#category_menu").stop().fadeOut().css('opacity', '0');
	});

	// Slideshow animation
	$('.box_slideshow .slides').cycle({
		fx: 'fade',
		pager: '.pager',
		speed: 300
	});

	enable_grid_list_buttons();
	enable_header_selects();

});

function enable_header_selects() {
    // Header select boxes
    $("div.header div.options select").selectbox({ effect: "fade" });
}

function enable_grid_list_buttons() {
    	// Click on grid/list
	$(".grid").parent().click(function() {
		$(".products").removeClass('product-list');
		$(".products").addClass('product-grid');
		$(".grid").parent().addClass('active');
		$(".list").parent().removeClass('active');
	});
	$(".list").parent().click(function() {
		$(".products").removeClass('product-grid');
		$(".products").addClass('product-list');
		$(".list").parent().addClass('active');
		$(".grid").parent().removeClass('active');
	});
}

function search() {
    var keyword = $("div.search input").val();

    document.location = conf['www_root']+"/"+keyword;
}
