$(document).ready(function(){
	$(document).pngFix();

	//localNavReadMore
	localNavReadMore();
	
	$("div.media").each(function(){
		renderFlash(this);
	});

	$('#qSearch input.single').css("color","#ccc").focus(function() {
		if($(this).val() == $(this).attr("defaultValue")) 
			$(this).val("").css("color","#454545");
	}).blur(function() {
		if($(this).val() == "") 
			$(this).val($(this).attr("defaultValue")).css("color","#ccc");
	});

	$("form#pageFilter select[name=pagesize], form#pageFilter select[name=orderby]").change(function() {
		$("form#pageFilter").submit();
	});

	$("form#filter select[name=color], form#filter select[name=size], form#filter select[name=brand]").change(function() {
		$("form#filter").submit();
	});

	$("form#filterCollection select[name=color], form#filterCollection select[name=size], form#filterCollection select[name=brand]").change(function() {
		$("form#filterCollection").submit();
	});
	
	
	
	
	$('#categoryFilterSelect').change(function () {
		$("form#filterCollection").submit();
	});

	
	$("a.addToFavorites").click(function(){	
		if (_signedin) {
			var options = { onreturn: function() { alert(LANG_FAVADDED); } };
			var nProductID = $(this).attr('rel');
			addToFavorites(nProductID, options);
		} else {
			alert(LANG_FAVLOGINREQ);
		}
	});

	$("a.deleteProduct").click(function() {		
		var o = $(this).parents("div.item")
		var nID = o.attr("rel");

		var options = { onreturn : function() { $(o).fadeOut("slow"); }	};
		deleteFromFavorites(nID, options);		
	});
	
	$('#gui-carousel-list, #shoponline-carousel-list, #lastViewedList, #home-carousel-list, #shop-carousel-list').cycle({ fx: 'fade' });
	
	//shopping cart animation
	(function() {
		var	$shoppingBag		= $('#shoppingBag'),
			$shoppingBagContent	= $('#shoppingBagContent');
		
		$shoppingBag
			.mouseenter(function() {
				if($shoppingBagContent.is(':hidden')) {
					getShoppingcart();
				}
			})
			.mouseleave(function() {
				$shoppingBagContent.hide();
			});
	})();

});
