$(document).ready(function() {
	$("table.cart .item").bind("mouseenter",function(){
    $(this).addClass("cart-hover");
    $(".cart-hover .remove").show();
  }).bind("mouseleave",function(){
    $(".cart-hover .remove").hide();
    $(this).removeClass("cart-hover");
  });
  
  $("table.item-packages .package").bind("mouseenter",function(){
    $(this).addClass("package-hover");
    $(".package-hover .buy-now").attr("src","/img/buy-now-hover.gif");
  }).bind("mouseleave",function(){
    $(this).removeClass("package-hover");
    $(".item-packages .buy-now").attr("src","/img/buy-now.gif");
  });
  
  $("div.catalogue div.item").bind("mouseenter",function(){
  	var prodlist_desc_short=$("SPAN.prod_sd_omo", this);
	prodlist_desc_short.each(function(){
		prod_id=this.title;
		$.get("/response.php?type=get_product&prod_id="+prod_id+"&rand="+Math.random(), function(data){
			var desc=$("desc_short", data).text();
			var prod_id=$("rx_id", data).text();
			var prod_=$("SPAN.prod_sd_omo[title="+prod_id+"]");
   			prod_.replaceWith(desc);
			});
		})
		
    $(this).addClass("catalogue-hover");
    var itemHtml = $(this).html();
    div_over=$("div.catalogue-hover div.over");
	div_over.show().html(itemHtml);
    $("div.over", div_over).html('').hide();
    $("div.txt", div_over).show();
    $("div.catalogue-hover div.price a").addClass("hover");
    $("div.catalogue-hover div.price img").attr("src","/img/add-to-cart-hover.gif");
    
  }).bind("mouseleave",function(){
    $(this).removeClass("catalogue-hover");
    $("div.catalogue div.over").hide();
    $("div.catalogue div.price img").attr("src","/img/add-to-cart.gif");
    $("div.catalogue div.price a").removeClass("hover");
  });
  
  $("#show_all_categories").click(function(){  	$(this).replaceWith($(this).text()+":"); 
 	$("#all_categories").show(200);
 	return false;
  	})
});

function switchInfo(eThis) {
  if ($(".item-info").hasClass("info-closed")) {
    $(".item-info").removeClass("info-closed");
    $(eThis).attr("src", "/img/info-minus.gif");
  } else {
    $(".item-info").addClass("info-closed");
    $(eThis).attr("src", "/img/info-plus.gif");
  }
}

/* subload desc */

$(function(){
	var cat_desc=$("SPAN.cat_d");
	if (cat_desc.length) {
		cat_id=cat_desc[0].title;
		$.get("/response.php?type=get_category&cat_id="+cat_id+"&rand="+Math.random(), function(data){
			var desc=$("desc_full", data).text();
   			cat_desc.replaceWith(desc);
		 });
	}
	var prod_desc_short=$("SPAN.prod_sd");
	if (prod_desc_short.length) {
		prod_id=prod_desc_short[0].title;
		$.get("/response.php?type=get_product&prod_id="+prod_id+"&rand="+Math.random(), function(data){
			var desc=$("desc_short", data).text();
   			prod_desc_short.replaceWith(desc);
		 });
	}
	var prod_desc_full=$("SPAN.prod_fd");
	if (prod_desc_full.length) {
		prod_id=prod_desc_full[0].title;
		$.get("/response.php?type=get_product&prod_id="+prod_id+"&rand="+Math.random(), function(data){
			var desc=$("desc_full", data).text();
   			prod_desc_full.replaceWith(desc);
		 });
	}
})

function goto(url){	window.location=url;
	return false;
}