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_ContentPlaceHolder1_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)
    {
    }
}    

//function ativarJanela(){
//var edtjanela = document.getElementById('ctl00_edtLightBox');
//eval(edtjanela.value);
//}


		
//contador++;
//if (contador == 10) 
// { 
//   alert('rafa');
// }
//else 
// { 
//   alert('contador' + contador );
//   window.setTimeout("this.carregaFade(contador)",50) ;
// }

// //Função Fade Pre-load HTML

//var opacity = 96; // Avoid starting at 100% due to Mozilla bug
//var slowly = {
//	fade : function (id) {
//		this.fadeLoop(id, opacity);
//	},
//	fadeLoop : function (id, opacity) {
//		var o = document.getElementById(id);
//		if (opacity >= 5) {
//			slowly.setOpacity(o, opacity);
//			opacity -= 4;
//			window.setTimeout("slowly.fadeLoop('" + id + "', " + opacity + ")", 50);
//		} else {
//			o.style.display = "none";
//		}
//	},
//	setOpacity : function (o, opacity) {
//		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)
//	}
//}
    


