/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var lastZoom    = "";
var lastSection = "";
var idPratFocus = "";
var idSecFocus  = 0;
var idTemp      = "";
var icIgnora    = false;

var mostraZoom = function()
        {
			if (!icIgnora)
			{
	            if (idPratFocus != "")
	            {
		            if (lastZoom != this.id && idSecFocus == this.getAttribute( "idSection" ))
		            {
		                if (lastZoom != "")
						{
							idTemp    = lastZoom;
					        $("#"+idTemp).html("<img src='assets/images/product_corner-" + lastSection +  ".png' borde='0'>" );
		
						}
		                lastZoom    = this.id;
		                lastSection = this.getAttribute( "idSection" );
		                $("#"+lastZoom).html('<div id="zoom-' + lastZoom + '" class="zoom"><div class="zoom-produto"><a title="' + this.getAttribute("nmProduct") + '" href="http://www.ninui.com/prodInfo.php?pId=' + this.getAttribute("idProduct") + '"><img alt="' + this.getAttribute("nmProduct") + '" src="' + this.getAttribute("imgProduto") + '" width="160" height="140" border="0"></a></div><div class="zoom-tools"><div class="zoom-icons"><a href="http://www.ninui.com/basketAdd.php?pId=' + this.getAttribute("idProduct") + '"><img src="assets/images/ico-comprar.png" alt="Comprar" width="30" height="30" border="0"/></a><a href="http://www.ninui.com/favoritos.php?pId=' + this.getAttribute("idProduct") + '"><img src="assets/images/ico-favoritos.png" width="30" alt="Favoritar" height="30" border="0"/></a><a href="http://www.ninui.com/prodInfo.php?pId=' + this.getAttribute("idProduct") + '"><img src="assets/images/ico-detalhes.png" alt="Detalhes" width="30" height="30" border="0"/></a></div><div class="zoom-preco">R$ ' + this.getAttribute("vlPreco") + '</div></div></div>' );
		 				$('#zoom-' + lastZoom).fadeTo(10,1.0);
		            }
	            }
			}
			else
			{
				icIgnora = false;
			}
        }


var escondeZoom = function(state){
        if (lastZoom != "")
        {
	            $("#"+lastZoom).html("<img src='assets/images/product_corner-" + lastSection +  ".png' borde='0'>" );
	            lastZoom    = "";
	            lastSection = "";
        }
};

$(document).ready(function(){
        $("#demo2").slidingPanels({
                onEnterState: demoEnterState,
                onLeaveState: demoLeaveState
        });

	$('.prateleira-opcoes').mouseover(escondeZoom);
    $('.product').mouseover(mostraZoom);
    $('#demo2').click(escondeZoom);

});

var demoEnterState = function(state)
{
	if (state.toLowerCase() == "maximized")
	{
		icIgnora    = true;
		idPratFocus = this.id;
		idSecFocus  = idPratFocus.split("_")[1];
	}
};

var demoLeaveState = function(state)
{
    idPratFocus = "";
	idSecFocus  = 0;
    escondeZoom(0);
};

var demoClearPanels = function(){
        //$("#demo2 li").empty();
};
