var isN4  	= (document.layers) ? true : false;
var isIE  	= (document.all) ? true : false;
var isDOM 	= (document.getElementById && !document.all) ? true : false;

function ClearText(e)
{
    if (e.value == "Digite o seu e-mail"){
        e.value = "";
    }
    return this;
}

function CheckText(e)
{
    if( e.value == "" ){
        return e.value = "Digite o seu e-mail";
    }
    return this;
}
function PrintPage()
{
	if (isIE) window.print();
	else alert('Por favor selecione a opcao "Arquivo -> Imprimir" do menu superior para imprimir.');
}
function GoToNext(size,cep1,cep2)
{
   if(document.getElementById(cep1.id).value.length >=size)
      document.getElementById(cep2.id).focus();
}
function OpenPopup(idPopup, url, popupW, popupH){
	window.open(url, idPopup, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=' + popupW + ',height=' + popupH + ',top=55,left=55');
}
function OpenProductRememberPopup(idProduct){
    OpenPopup('productremember', 'productremember.aspx?idproduct=' + idProduct, 330, 300);
}
function OpenGiftCardPopup(idPopup, url, popupW, popupH){
	window.open(url, idPopup, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + popupW + ',height=' + popupH + ',top=55,left=55');
}

function callcenterunavailable(){
    welcomeWindow = window.open("chat_unavailable.htm", "callcenter", "width=430,height=600");
}
function callcenter(parentPage){
    if (parentPage == null || parentPage == "")
        welcomeWindow = window.open('http://www12.directtalk.com.br/server/directtalk_chatr.dll/user?S=I&id_s=AC5300749749F0139066', 'callcenter', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=430,height=400');
    else
        welcomeWindow = window.open('http://www12.directtalk.com.br/server/directtalk_chatr.dll/user?S=I&id_s=AC5300749749F0139066&origem=' + parentPage, 'callcenter', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=430,height=400');
}
function oPenPopupShipCost(zipCode, zipCodeComplement)
{
    var zipfull = zipCode + zipCodeComplement;
    window.open('popupshipcost.aspx?zip='+zipfull,null ,'width=500,height=340');
    return false;
}
function ValidateNumberOfChars(textBox, limit, divResponse){

	var validKey = true;
	var obj = document.getElementById(textBox);
	var divResponse = document.getElementById(divResponse);
	var diff = limit - obj.value.length;
	
	if(diff < 0 && 
		window.event.keyCode != 8 &&
		window.event.keyCode != 17 &&
		!(window.event.keyCode >= 33 && window.event.keyCode <= 40) &&
		window.event.keyCode != 46
		)
	{
		obj.value = obj.value.substr(0, limit);
		validKey = false;
	}
	
	divResponse.innerHTML = "Total de <font color=\"red\"><strong>" + obj.value.length + "</strong></font> caracteres digitados de no máximo <strong>" + limit + "</strong>.";
	
	return validKey;
}
//function ValidateKeyPress(buttonPost)
//{
//    var impressKeyCode = true;
//    var obj = document.getElementById(buttonPost);
//    if(window.event && window.event.keyCode == 13){
//        impressKeyCode = false;
//        obj.click();
//    }
//    return impressKeyCode;
//}
function ValidateKeyPress(buttonPost,e)
{
   var impressKeyCode = true;
    if(isIE)
    {
        if(e.keyCode == 13){
            impressKeyCode = false;
            document.getElementById(buttonPost).click();
        } 
    }
  else
    {
        if(e.which == 13)
        {
            impressKeyCode = false;
            document.getElementById(buttonPost).click();
        }
    }
          
    return impressKeyCode;
}
function BlockEnter(e)
{
    if (!e)
    {       
        e = window.event;
     }
    if (e.keyCode == 13)
    {
        return false;
    }
}
function AutoPostEmail(e, url){
    if (!e)
        e = window.event;
    if (e != null && e.keyCode == 13)
    {
        window.location.replace(url + 'newsletter.aspx?email=' + document.forms[0].txtEmail.value);
        return false;
    }
}
function OpenProductPopup(idProduct){
	OpenPopup("productpopup","productpopup.aspx" + "?idproduct=" + idProduct , 500, 325);
}
function OpenProductPopup(idProduct){
	OpenPopupProd("productpopup","productpopup.aspx" + "?idproduct=" + idProduct , 520, 270);
}
function OpenPopupProd(idPopup, url, popupW, popupH){
	window.open(url, idPopup, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + popupW + ',height=' + popupH + ',top=55,left=55');
}
function OpenPopup(idPopup, url, popupW, popupH){
    window.open(url, idPopup, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + popupW + ',height=' + popupH + ',top=55,left=55');
}
function OpenPopCenter(e, w, h)
{
    u = document.forms[0].txtZip.value;
    u += document.forms[0].txtZipComplement.value;    
    window.open(e.href + u, 'CEP', 'width=' + w + ',height=' + h + ',left=' + ((screen.width - w) / 2) + ',top=' + ((screen.height - h) / 2));
    return false;
}
function GoToNext(size,cep1,cep2)
{
   if(document.getElementById(cep1.id).value.length >=size)
      document.getElementById(cep2.id).focus();
}
function OpenPopupImageProduct(idPopup, url, popupW, popupH){
    window.open(url, idPopup, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + popupW + ',height=' + popupH + ',top=55,left=55');
}
function CloseWindow()
{
    window.close();
}
function setVisibility(layerName, on) {
    if(document.getElementById(layerName) == null)
        return;

    if (on){
		    document.getElementById(layerName).className = "visiblediv";
	}
    else{
		    document.getElementById(layerName).className = "invisiblediv";
    }
}      
//Comandos usados para a exibição do PopUp de ajuda
var timeOut;
function divflutuante()
{
	timeOut = setTimeout("showDiv()",420000);
	
}
function showDiv()
{   
    document.getElementById('pop').style.top = ""+(eval(getScrollHeight())+ eval(document.documentElement.clientHeight)/2)+"px"; 
    setDivMaxScreenSize("trans");
    document.getElementById('pop').className='visiblediv';
	document.getElementById('trans').className='visiblediv';
	document.getElementById('trans').className='translucent';
    
       
}
function start()
{
	divflutuante();
}
function hideDiv()
{
	clearTimeout(timeOut);
	document.getElementById('pop').className='invisiblediv';
	document.getElementById('trans').className='invisiblediv';
	document.getElementById('ifrHelp').src='functions.aspx?help=1';
	
	
}
function hideDivBannerFly()
{
    document.getElementById('DivBannerFly').className='invisiblediv';
}
function hideDivSecuritySite()
{
    document.getElementById('divSecuritySite').className='divSecurityI';
}
function showDivSecuritySite()
{
    document.getElementById('divSecuritySite').className='divSecurityV';
}
function setDivMaxScreenSize(div)
{
    
    document.getElementById(div).style.height=getMaxScrollHeight()+"px";
    document.getElementById(div).style.width=getMaxScrollWidth()+"px";
	
}
function getMaxScrollWidth()
{
	return document.body.offsetWidth;
}
function getMaxScrollHeight()
{
	return document.body.offsetHeight;
}
function getScrollHeight()
{
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
           
   return h ? h : 0;
}

// Função do Totalizador flutuante


var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
var px = document.layers ? "" : "px";
function JSFX_FloatDiv(id, sx, sy)
{
   
    var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
    window[id + "_obj"] = el;
    if(d.layers)el.style=el;    
    el.cx = el.sx = sx;
    el.cy = el.sy = sy;
    el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};
    el.flt=function()
    {
        var pX, pY;
        pX = (this.sx >= 0) ? 0 : ns ? innerWidth :
        document.documentElement && document.documentElement.clientWidth ?
        document.documentElement.clientWidth : document.body.clientWidth;
        pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ?
        document.documentElement.scrollTop : document.body.scrollTop;
        if(this.sy<0)
        pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ?
        document.documentElement.clientHeight : document.body.clientHeight;
        this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;
        this.sP(this.cx, this.cy);
        setTimeout(this.id + "_obj.flt()", 20);
//        DivValue();
    }
    return el;
}


