﻿var varHoraInicial = new Date()
var HoraInicial = varHoraInicial.getTime()

var sequencia=0;
var o = document.getElementById("div");


//function click() {
//if (event.button==2||event.button==3) {
//oncontextmenu="alert('Função bloqueada');return false;";
//}
//}
//document.onmousedown=click
//document.oncontextmenu = new Function("alert('Função bloqueada');return false;")



function salvarProduto(Codigo){
    window.location="produto.aspx?ProCodigo=" + Codigo + "&Quantidade=" + document.getElementById('ctl00_Conteudo_edtQuantidadeModificada').value
    return true
   }


function ValidarVersaoNavegador(){
    var nVer = navigator.appVersion;
    var nAgt = navigator.userAgent;
    // No IE a versão real vem depois da palavra "MSIE" do useragent
    if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
    browserName  = "IE";
    fullVersion  = parseFloat(nAgt.substring(verOffset+5));
    majorVersion = parseInt(''+fullVersion);
    }
    
    // no opera, vem depois do opera
    else if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
    browserName  = "Opera";
    fullVersion  = parseFloat(nAgt.substring(verOffset+6));
    majorVersion = parseInt(''+fullVersion);
    larguraScroll = 18;
    }
    
    // no firefox, depois de firefox
    else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
    browserName  = "Firefox";
    fullVersion  = parseFloat(nAgt.substring(verOffset+8));
    majorVersion = parseInt(''+fullVersion);
    larguraScroll = 18;
    }
    
    // na maioria dos browser, "name/version" esta no fim do useragent
    else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) ) 
    {
    browserName  = nAgt.substring(nameOffset,verOffset);
    fullVersion  = parseFloat(nAgt.substring(verOffset+1));
    if (!isNaN(fullVersion)) majorVersion = parseInt(''+fullVersion);
    else {fullVersion  = 0; majorVersion = 0;}
    }
    
    // e se nao detectar nem nome nem useragent
    if ( 
        browserName.toLowerCase() == browserName.toUpperCase()
    || fullVersion==0 || majorVersion == 0 
    )
    {
    browserName  = navigator.appName;
    fullVersion  = parseFloat(nVer);
    majorVersion = parseInt(nVer);
    }
    
    if ( browserName == 'IE' && majorVersion < 6) {
      window.location = 'navegadornaosuportado.aspx'
    }
}   
function clearForm(formIdent) 
{ 
  var form, elements, i, elm; 
  form = document.getElementById 
    ? document.getElementById(formIdent) 
    : document.forms[formIdent]; 

	if (document.getElementsByTagName)
	{
		elements = form.getElementsByTagName('input');
		for( i=0, elm; elm=elements.item(i++); )
		{
			if (elm.getAttribute('type') == "text")
			{
				elm.value = '';
			}
		}
	}

	// Actually looking through more elements here
	// but the result is the same.
	else
	{
		elements = form.elements;
		for( i=0, elm; elm=elements[i++]; )
		{
			if (elm.type == "text")
			{
				elm.value ='';
			}
		}
	}
}


var contadorInicial = 1

function liberarPagina(){
  var o = document.getElementById('loading');
  o.style.display = "none";
}
function atualizarTempoCarga(){
  var horaFinal = new Date()
  if (document.getElementById("ctl00_Rodape1_lblTempoCarga")) {
    document.getElementById("ctl00_Rodape1_lblTempoCarga").innerHTML = document.getElementById("ctl00_Rodape1_lblTempoCarga").innerHTML + ' e descarregada em ' + ((horaFinal.getTime() - HoraInicial)/1000) + ' segundos'; 
    }
}

function carregarFade(contador,div){
var o = document.getElementById(div);
if (contador >= 5) {
  definirOpacidade('loading',contador);
  contador -=  10;
  window.setTimeout("carregarFade(" + contador + ",'" + div + "')",50) ;
  }
else
  {
  o.style.display = "none";
  }
}

function definirOpacidade(div,opacity){
  var o = document.getElementById(div)  
  o.style.filter = "alpha(style=0,opacity:" + opacity + ")";	// IE
  o.style.KHTMLOpacity = opacity / 100;				// Konqueror
  o.style.MozOpacity = opacity / 100;					// Mozilla (old)
  o.style.opacity = opacity / 100;					// Mozilla (new)
}


 function SelecionaTodosChecks(spanChk){
   var oItem = spanChk.children;
   var theBox= (spanChk.type=="checkbox") ? 
   spanChk : spanChk.children.item[0];
   xState=theBox.checked;
   elm=theBox.form.elements;
  
   for(i=0;i<elm.length;i++)
     if(elm[i].type=="checkbox" && 
              elm[i].id!=theBox.id)
     {
       if(elm[i].checked!=xState)
         elm[i].click();
     }
 }


function confirmaSaida(){
if(confirm('Caso deseje sair do sistema, será necessário informar seu usuário e senha na próxima vez que tentar se conectar. Confirma a saida do painel ?'))
{ window.location="login.aspx?logout=1"}
}

function ativarCarrinho(){
  try
  {
     var flagAtivaCarrinho = document.getElementById('ctl00_flagAtivaCarrinho');
     if (flagAtivaCarrinho.value == 1 ) {
        abrirJanela('carrinho.aspx','Carrinho de compras','Verifique acima os itens adicionado em seu carrinho de compras',750,400)
      }
   }
   catch(err)
    {
    }
}    

qs=new Array()
variaveis=location.search.replace(/\x3F/,"").replace(/\x2B/g," ").split("&")
if(variaveis!=""){
for(i=0;i<variaveis.length;i++){
nvar=variaveis[i].split("=")
qs[nvar[0]]=unescape(nvar[1])
}
}
function QueryString(variavel){
return qs[variavel]
}



function carregarEditor(editor,Codigo){
   window.showModalDialog(editor +  'aspx?id=' + Codigo  ,'CustomPopUp','dialogHeight:600px;dialogWidth: 800px; dialogTop: 286px; dialogleft:400px; edge: Raised; center: Yes; resizable: Yes; status: No;');
  
 //  var link 
   

//   if (QueryString('Modo') != 'undefined') 
//	{ 
//		link == QueryString('Modo') ; 
//		alert('Modo1');
//		alert(QueryString('Modo'));
//	}
//   if (QueryString('modo') != 'undefined') 
//	{ 
//		link = QueryString('modo')  ; 
//		alert('Modo2')
//	}
   var randomnumber=Math.floor(Math.random()*1001)
   location.href='index.aspx?Modo=Edicao&hora=' + randomnumber
}
function CarregarjanelaIndicacao(){
window.open("indique.aspx","Indique","height=270,width=180,status=no,toolbar=no,menubar=no,location=no");
}

function CarregarjanelaRastreamento(){
window.open("rastreamentoCodigo.aspx","Indique","height=270,width=480,status=no,toolbar=no,menubar=no,location=no");
}

function carregarEditorEstrutura(){
   window.showModalDialog('controles/estrutura/Estrutura_editor.aspx','CustomPopUp','dialogHeight:600px;dialogWidth: 800px; dialogTop: 286px; dialogleft:400px; edge: Raised; center: Yes; resizable: Yes; status: No;');
   location.href='EditorDeLayout_areas.aspx?modo=edicao'
}

function AdicionarControle(){
   window.showModalDialog('EditorAdicionarControle.aspx','CustomPopUp','dialogHeight:600px;dialogWidth: 800px; dialogTop: 286px; dialogleft:400px; edge: Raised; center: Yes; resizable: Yes; status: No;');
   location.href='EditorDeLayout_areas.aspx?modo=edicao'
}


function carregarEditorImagens(){
   window.showModalDialog('controles/BotoesPadrao/BotoesPadrao_editor.aspx','CustomPopUp','dialogHeight:600px;dialogWidth: 800px; dialogTop: 286px; dialogleft:400px; edge: Raised; center: Yes; resizable: Yes; status: No;');
   location.href='EditorDeLayout_areas.aspx?modo=edicao'
}

function carregarUploadDeArquivos(){
   window.showModalDialog('controles/Upload/upload_editor.aspx','CustomPopUp','dialogHeight:600px;dialogWidth: 800px; dialogTop: 286px; dialogleft:400px; edge: Raised; center: Yes; resizable: Yes; status: No;');
   location.href='EditorDeLayout_areas.aspx?modo=edicao'
}


function CarregarSimuladorDeSedex(){
   window.showModalDialog('simuladorSedex.aspx','CustomPopUp','dialogHeight:600px;dialogWidth: 800px; dialogTop: 286px; dialogleft:400px; edge: Raised; center: Yes; resizable: Yes; status: No;');
}


function CarregarjanelaIndicacaoProduto(){
window.open("indiqueProduto.aspx?Link=" + document.getElementById('ctl00_Conteudo_edtURLProduto').value,"Indique","height=270,width=180,status=no,toolbar=no,menubar=no,location=no");
}
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0].toUpperCase() == variable.toUpperCase()) {
      return pair[1];
    }
  } 
  alert('Query Variable ' + variable + ' not found');
}
function AmpliarFoto(foto) {
  window.open('AmpliarFoto.aspx?ProCodigo=' + getQueryVariable('ProCodigo'),'Foto','height=480,width=640,status=yes,toolbar=no,menubar=no,location=no')
}

function MudarAba(div){
  var o = document.getElementById(div)  
  
  document.getElementById('ProdutoDescricao').style.display = "none"  
  document.getElementById('ProdutoDadosTecnicos').style.display = "none"  
  document.getElementById('ProdutoGarantia').style.display = "none"  
  document.getElementById('ProdutoAvaliacao').style.display = "none"  
  
  
  o.style.display = "inline"
}


   
    var setOfLinksOnclickAction = new Array();
   
    function DisableLinks(someDivId)
    {
    
         
        //Getting Target Div to disable all the links inside it.
        var targetDiv = document.getElementById(someDivId)
       
        //Getting all the archorList in the div
        var anchorList = targetDiv.getElementsByTagName('a');
        for (var i=0; i < anchorList.length;i++)
        {
            //Making sure that end-user identifies(sees) that the link is disabled
             anchorList[i].disabled=true;
             //Storing the link-onclick action in global variable which will be used in EnableLinks(...) function
             setOfLinksOnclickAction[i] = anchorList[i].onclick
             //Real-Disabling
             anchorList[i].onclick = '';
            
        }
    }
    
    
function SelecionarDIV(id) {
document.getElementById(id).style.backgroundImage  = 'url(imagem/editor/FundoTransparenteAmarelo.png)'
//document.getElementById(id).style.border = '2px';
//document.getElementById(id).style.borderStyle  = 'dotted';
//document.getElementById(id).style.borderColor  = 'red';

}


function DesmarcarDIV(id) {
document.getElementById(id).style.backgroundImage  = 'url(imagem/editor/FundoTransparente.png)'
//document.getElementById(id).style.border = '0px';
//document.getElementById(id).style.borderStyle  = 'dotted';
//document.getElementById(id).style.borderColor  = 'red';
}

function RecarregarEditor(){
      location.href='EditorDeLayout_areas.aspx?modo=edicao'
}

/*function showToolTip(e){
      document.getElementById('ToolTip').innerHTML="<table><tr><td class=ToolTipTD>teste</td></tr></table>";
      document.getElementById('ToolTip').style.pixelLeft=(e.x+15+document.body.scrollLeft);
      document.getElementById('ToolTip').style.pixelTop=(e.y+document.body.scrollTop);
      document.getElementById('ToolTip').style.visibility="visible";
            
}
function hideToolTip(){
      document.getElementById('ToolTip').style.visibility="hidden";
}

*/