function Trim(str)
{
	if(str != undefined)
	{
				   
	return str.replace(/^\s+|\s+$/g,"");
	
	}
}
var Produtos = {
	
	onmouseover: function(Codigo)
	{
		
		$("#QuickLook_" + Codigo).show();		
		
	},
	
	onmouseout: function(Codigo)
	{
		
		$("#QuickLook_" + Codigo).hide();
		
	},
	
	Abre: function(Codigo)
	{
		
		Utilitarios.AbrirModalAjax('ProdutosDetalhes.php?Codigo=' + Codigo, 800, 500);
		
	},
	
	ProdutoFotoMudar: function(Caminho, Foto)
	{	
	
		$("#Foto_Normal").attr("rel", Caminho + "/600_" + Foto);
		$("#Foto_Normal img").attr("src", Caminho + "/600_" + Foto);
		
	}
	
}
function AbreZoom(Foto)
{
	
	Shadowbox.open({
				content:    Foto,
				player:     "img",
				title:      ""
			});
			
}
function mktime() 
{
    
    var no=0, i = 0, ma=0, mb=0, d = new Date(), dn = new Date(), argv = arguments, argc = argv.length;

    var dateManip = {
        0: function (tt){ return d.setHours(tt); },
        1: function (tt){ return d.setMinutes(tt); },
        2: function (tt){ var set = d.setSeconds(tt); mb = d.getDate() - dn.getDate(); d.setDate(1); return set;},
        3: function (tt){ var set = d.setMonth(parseInt(tt, 10)-1); ma = d.getFullYear() - dn.getFullYear(); return set;},
        4: function (tt){ return d.setDate(tt+mb);},
        5: function (tt){
            if (tt >= 0 && tt <= 69) {
                tt += 2000;
            }
            else if (tt >= 70 && tt <= 100) {
                tt += 1900;
            }
            return d.setFullYear(tt+ma);
        }
        // 7th argument (for DST) is deprecated
    };

    for (i = 0; i < argc; i++){
        no = parseInt(argv[i]*1, 10);
        if (isNaN(no)) {
            return false;
        } else {
            // arg is number, let's manipulate date object
            if (!dateManip[i](no)){
                // failed
                return false;
            }
        }
    }
    for (i = argc; i < 6; i++) {
        switch (i) {
            case 0:
                no = dn.getHours();
                break;
            case 1:
                no = dn.getMinutes();
                break;
            case 2:
                no = dn.getSeconds();
                break;
            case 3:
                no = dn.getMonth()+1;
                break;
            case 4:
                no = dn.getDate();
                break;
            case 5:
                no = dn.getFullYear();
                break;
        }
        dateManip[i](no);
    }

    return Math.floor(d.getTime()/1000);
	
}

var Utilitarios = {
	
	DesativaBotao: function(Form)
	{
		
		$("#"+Form+"_A").show();
		$("#"+Form+"_B").hide();
		
	},
	
	AtivaBotao: function(Form)
	{
		
		$("#"+Form+"_A").hide();
		$("#"+Form+"_B").show();
		
	},
	
	CriarMascaras: function()
	{
	
		$(".CampoCep").mask("99999-999");
		$(".CampoCPF").mask("999.999.999-99");
		$(".CampoCNPJ").mask("99.999.999/9999-99");
		$(".CampoData").mask("99/99/9999");
		$(".CampoTelefone").mask("(99) 9999-9999");
		
	},
	
	FecharModal: function()
	{
		
		$.modal.close();
		
	}, 
	
	AbrirModalAjax: function(Link, Largura, Altura, AcaoPosCarregar)
	{
		
		$.ajax({
								
			type: "GET",
			url: Link,
			success: function(msg)
			{
				
				
				Txt				= 	''+
									'<table width="100%" border="0" cellspacing="0" cellpadding="5" class="ModalInline">'+
									'  <tr>'+
									'    <td align="right" class="ModalTopo" height="20" valign="middle">'+
									'    	<a href="javascript:;" onClick="Utilitarios.FecharModal();">'+
									'    		<img src="images/close.gif" border="0" />'+
									'        </a>'+
									'    </td>'+
									'  </tr>'+
									'  <tr>'+
									'    <td><div style="overflow:auto; height:'+Altura+'px; ">'+msg+'</span></td>'+
									'  </tr>'+
									'</table>';

				
				$.modal(Txt, 	{
								containerCss:	{
											height:		(Altura+40),
											width:		Largura
											},
								overlayClose:true
								});
				
				if(AcaoPosCarregar!="")
				{
					
					eval(AcaoPosCarregar);	
					
				}
				
			}
			
		});
		
													
	}
	
};
var Orcamento = {
	
	AlterarQuantidade: function(Acao, Quantidade, Codigo)
	{
		
		$("#Cesta_Box_Alterar_A_" + Codigo).show();
		$("#Cesta_Box_Alterar_B_" + Codigo).hide();
		
		$.ajax({
								
			type: 	"GET",
			url: 	"Ajax.php",
			data: 	"Acao=OrcamentoAlterarQtd&Codigo=" + Codigo + "&Quantidade=" + Quantidade + "&SAcao=" + Acao,
			success: function(msg)
			{
				
				$("#Quantidade_" + Codigo).html(msg);
				window.location = 'cesta.php';
				
			}
			
		});
		
	},
	
	RemoverItem: function(Codigo)
	{
		
		$("#Cesta_Box_Remover_A_" + Codigo).show();
		$("#Cesta_Box_Remover_B_" + Codigo).hide();
		
		$.ajax({
								
			type: 	"GET",
			url: 	"Ajax.php",
			data: 	"Acao=OrcamentoRemover&Codigo=" + Codigo,
			success: function(msg)
			{
				
				$("#Item_" + Codigo).remove();
				window.location = 'cesta.php';
				
			}
			
		});
		
	}	
	
}
$(document).ready(function() {
	
	Utilitarios.CriarMascaras();
	
	$(document).ready(function(){
		
		$(this).bind("contextmenu", function(e) {
			e.preventDefault();
		});
		
		
	});

});
