  var cpath = "";
  var cid1 = "";
  var cid2 = "";
  var box3opened = false;
  var previd1 = "";
  
	$(document).ready(function() {

	});
	
	
  function buildBox2(data, textStatus, jqXHR)
  {
     $('#box2').replaceWith(data);
     $('#box2').animate({ left: '+=228'}, 500);
     getBox3();
  }

  function buildBox3(data, textStatus, jqXHR)
  {
     $('#box3').replaceWith(data);
     $('#box3').animate({ left: '+=424'}, 500, openBox3)
    
  }
  
  function closeBox2()
  {
	 $('#box2').animate({ left: '-=228'}, 500, getBox2());   
  }
  
  function getBox2()
  {
    var params = new Array();
    params.push("page=ajax_prodotti_box2_home");      
    params.push("path=" + cpath);
    if (cid1 != null) params.push("id2=" + cid1);
    if (cid2 != null) params.push("id3=" + cid2);      
    $.ajax({
        type: "GET",
        url: "/index.php",
        data: params.join("&"),
        dataType: "text",
        success: buildBox2
     });   
  }
  
  function getBox3()
  {
    var params = new Array();
    params.push("page=ajax_prodotti_box3_home"); 
    params.push("path=" + cpath);
    if (cid1 != null) params.push("id2=" + cid1);
    if (cid2 != null) params.push("id3=" + cid2);      
    $.ajax({
        type: "GET",
        url: "/index.php",
        data: params.join("&"),
        dataType: "text",
        success: buildBox3
     });   
  }
  
  function execRicerca(loc, path, id1, id2)
  {
    if (path != "portata" && path != "marca") return;
    apriRicerca();
    if (id2 != null && id2 != "")
    {
        var sc;
        $("#link_id2_" + id2).addClass("attivo");
        sc = "/index.php?page=prodotti_ricerca&path=" + path;
        if (id1 != null) sc += "&id2=" + id1;
        if (id2 != null) sc += "&id3=" + id2;
        window.open(sc, "_self");
        return;
    }
    if (previd1 != null && previd1 != "") $("#link_id1_" + previd1).removeClass("attivo"); 
   
    if (cpath == path)
    {
  		cid2 = id2;
  		cid1 = id1;    
	    $('#box3').animate({ left: '-=424'}, 500, getBox3());
    }
    else
    {
	    cpath = path;
	    cid1 = id1;
	    cid2 = id2;
		  $('#box3').animate({ left: '-=424'}, 500, closeBox2());
          
	  }
    if (id1 != null && id1 != "") 
    {
        previd1 = id1;
        $("#link_id1_" + id1).addClass("attivo");
    } 

 }
 
  function openBox3()
  {
    box3opened = true;
  } 

  function hideBox2()
  {
	  if (box3opened)
    {
      box3opened = false;
      $('#box3').animate({ left: '-=424'}, 500, hideBox2); 
    }
    else
    {
      $('#box2').animate({ left: '-=228'}, 500, chiudiRicerca);    
    }
    
  }
  
  function hideBox3()
  {
	 $('#box3').animate({ left: '-=424'}, 500, chiudiBox);   
  }   

	function apriRicerca(){
		$("#dimPlayerHp").css("width", "622px");
		$("#dimPlayerHp").css("z-index", "100");
		$(".home_footbox_01 .arrow").css("z-index", "20");
	}

 
	function chiudiRicerca(){
		$("#dimPlayerHp").css("width", "297px");
		$("#dimPlayerHp").css("z-index", "20");
		$("#homePlayer").css("z-index", "20");
		$(".home_footbox_01 .arrow").css("z-index", "100");
	} 
 
 function chiudiBox()
 {
    $(".arrow").css("z-index", "100");
 }
 
 
	function setPng24(obj) {
		obj.width=obj.height=1;
		obj.className=obj.className.replace(/\bpng24\b/i,'');
		obj.style.filter =
		"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
		obj.src=''; 
		return '';
	}


