$(function(){
	var selectedProduct;
	
	$(".products_content .more").click(function(event){
		id = $(this).attr("href").replace("/pages/index/", "");
		
		Cufon.replace($(".products_h2"),{color: '#724e4e', fontSize: '14px'});
		$(".products_h2").css({
			"background-color": "#ffffff"
		});
		
		Cufon.replace($(this).parents("h2"),{color: '#ffffff', fontSize: '14px'});
		$(this).parents("h2").css({
			"background-color": "#724e4e"
		});
		
		 selectedProduct = $(this);
		
		$(".products_content .content_box_right").fadeIn();
		$("#products_subcontent").load("/ajax/sub_products/" + id + "/");
		
		if("undefined" != typeof(event) )event.returnValue = false;
		return false;
	});
	
	$(".products_content .more").mouseover(function(){
		Cufon.replace($(this).parents("h2"),{color: '#ffffff', fontSize: '14px'});
		$(this).parents("h2").css({
			"background-color": "#724e4e"
		});
	});
	
	$(".products_content .more").mouseout(function(){
		path = window.location.pathname;
		path = path.split("/");
		href = $(this).attr("href");
		href = href.split("/")
		
		if ((href[href.length - 1] != path[path.length - 1]) || selectedProduct)
		{
			Cufon.replace($(this).parents("h2"),{color: '#724e4e', fontSize: '14px'});
			$(this).parents("h2").css({
				"background-color": "#ffffff"
			});
		}
		
		if (selectedProduct)
		{
			Cufon.replace(selectedProduct.parents("h2"),{color: '#ffffff', fontSize: '14px'});
			selectedProduct.parents("h2").css({
				"background-color": "#724e4e"
			});
		}
	});
	
	$(".overlay_div").live("click", function(){
		setVisible($("#product_share").val(), true);
		$(this).remove();
	});
	
//	$("body").click(function(){
//		if ($("#" + $("#product_share").val()).is(":visible"))
//			alert("sdfsdf");
//	});
});
