// JavaScript Document
function init(number, option) {
    var vCookie = getCookie("tbl" + number);
    oLayer = document.getElementById("tbl" + number);
    //oButton = document.getElementById("butMenu" + number);

    if (oLayer != null) {
        if (vCookie == null) {
            if (option == "0") {
                oLayer.style.display = "none";
                setCookie('tbl' + number, 'none');
                //oButton.src = "images/mais.gif";

            } else {
                setCookie('tbl' + number, 'block');
                oLayer.style.display = "block";
                //oButton.src = "images/menos.gif";
            }
        } else {
            if (vCookie == "none") {
                oLayer.style.display = "none";
                setCookie('tbl' + number, 'none');
                //oButton.src = "images/mais.gif";
            } else {
                setCookie('tbl' + number, 'block');
                oLayer.style.display = "block";
                //oButton.src = "images/menos.gif";
            }
        }
    }
}

function ShowMenuLateral(number) {
    oLayer = document.getElementById("tbl" + number);
    //oButton = document.getElementById("butMenu" + number);
    if (oLayer.style.display == "block") {
        setCookie('tbl' + number, 'none');
        //oButton.src="images/mais.gif";
        oLayer.style.display = "none";
    } else {
        setCookie('tbl' + number, 'block');
        //oButton.src="images/menos.gif";
        oLayer.style.display = "block";
    }
}

function setCookie(name, value) { document.cookie = name + "=" + escape(value); }

function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function StartShowHide(Name) {
    var vCookie = getCookie("ShowHide" + Name);
    oObject = document.getElementById(Name);

    /*if (vCookie != null) {
    if (vCookie == "block") {
    oObject.style.display = "block";
    } else {
    oObject.style.display = "none";
    }
    }
    else {
    oObject.style.display = "none";
    setCookie('ShowHide' + Name, 'none');
    }*/
    oObject.style.display = "none";
}

function ShowHide(Name) {
    var vCookie = getCookie("ShowHide" + Name);
    oObject = document.getElementById(Name);
    if (oObject.style.display == "block") {
        setCookie('ShowHide' + Name, 'none');
        oObject.style.display = "none";
    } else {
        setCookie('ShowHide' + Name, 'block');
        oObject.style.display = "block";
    }
}

function vestibular(n) {
    if (n != 0) {
        parent.frame1.location.href = 'ucFrame1.aspx?IDVestibular=' + n;
    }
}

function montaSWF(arquivo, largura, altura) {
    var now = new Date();
    var dia = now.getDay();
    var mes = now.getMonth();
    var ano = now.getFullYear();
    var hora = now.getHours();
    var mintuto = now.getMinutes();
    var segundo = now.getSeconds();
    var data = ano + "" + mes + "" + dia + "" + hora + "" + mintuto + "" + segundo;

    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">');
    document.write('<param name="movie" value="' + arquivo + '.swf?ieSux=' + data + '" />');
    document.write('<param name="quality" value="high" />');
    document.write('<param name="menu" value="false" />');
    document.write('<param name="wmode" value="transparent" />');
    document.write('<embed wmode="transparent" menu="false" src="' + arquivo + '.swf?ieSux=' + data + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + largura + '" height="' + altura + '"></embed>');
    document.write('</object>');
}

var ie =(((navigator.userAgent.indexOf("MSIE")>-1)||(navigator.userAgent.indexOf("Mozilla/5.0")>-1))&&navigator.userAgent.indexOf("Opera")==-1?true:false);
var ns =(navigator.userAgent.indexOf("Netscape")>-1&&navigator.userAgent.indexOf("Opera")==-1?true:false);
function ajustar_data(input, evento) {
    var tecla = (evento.keyCode ? evento.keyCode : evento.which ? evento.which : evento.charCode);
    if (tecla == 8 || tecla == 46 || tecla == 39 || tecla == 37 || tecla == 36 || tecla == 35 || tecla == 9) {
        return true;
    }
    if (tecla < 48 || tecla > 57) {
        evento.returnValue = false;
        return false;
    }
    else {
        if (input.value.length == 2 || input.value.length == 5) {
            input.value += "/";
        }
    }
    return true;
}

function ajustar_numero(input, evento) {
    var tecla = (evento.keyCode ? evento.keyCode : evento.which ? evento.which : evento.charCode);
    if (tecla == 8 || tecla == 46 || tecla == 39 || tecla == 37 || tecla == 36 || tecla == 35 || tecla == 9) {
        return true;
    }
    if (tecla < 48 || tecla > 57) {
        evento.returnValue = false;
        return false;
    }
    return true;
}

function ajustar_cnpj(input, evento) {
    var tecla = (evento.keyCode ? evento.keyCode : evento.which ? evento.which : evento.charCode);
    if (tecla == 8 || tecla == 46 || tecla == 39 || tecla == 37 || tecla == 36 || tecla == 35 || tecla == 9) {
        return true;
    }
    if (tecla < 48 || tecla > 57) {
        evento.returnValue = false;
        return false;
    }
    else {
        if (input.value.length == 2 || input.value.length == 6) {
            input.value += ".";
        }
        if (input.value.length == 10) {
            input.value += "/";
        }
        if (input.value.length == 15) {
            input.value += "-";
        }
    }
    return true;
}

function ajustar_cpf(input, evento) {
    var tecla = (evento.keyCode ? evento.keyCode : evento.which ? evento.which : evento.charCode);
    if (tecla == 8 || tecla == 46 || tecla == 39 || tecla == 37 || tecla == 36 || tecla == 35 || tecla == 9) {
        return true;
    }
    if (tecla < 48 || tecla > 57) {
        evento.returnValue = false;
        return false;
    }
    else {
        if (input.value.length == 3 || input.value.length == 7) {
            input.value += ".";
        }
        if (input.value.length == 11) {
            input.value += "-";
        }
    }
    return true;
}

function ajustar_cep(input, evento) {
    var tecla = (evento.keyCode ? evento.keyCode : evento.which ? evento.which : evento.charCode);
    if (tecla == 8 || tecla == 46 || tecla == 39 || tecla == 37 || tecla == 36 || tecla == 35 || tecla == 9) {
        return true;
    }
    if (tecla < 48 || tecla > 57) {
        evento.returnValue = false;
        return false;
    }
    else {
        if (input.value.length == 5) {
            input.value += "-";
        }
    }
    return true;
}

function sendIt(input, evento, target) {
    var tecla = (evento.keyCode ? evento.keyCode : evento.which ? evento.which : evento.charCode);
    if (tecla == 8 || tecla == 46 || tecla == 39 || tecla == 37 || tecla == 36 || tecla == 35 || tecla == 9) {
        return true;
    }
    if (tecla == 13) {
        evento.returnValue = false;
        __doPostBack(target, '');
    }
}

function filipeta(i) {
    document.getElementById("imgFilipeta").style.display = '';
    document.getElementById("imgFilipeta").src = 'Images/filipeta' + i + '.jpg';
}

function setActiveStyleSheet(title) {
    for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
        if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
            a.disabled = true;
            if (a.getAttribute("title") == title) {
                a.disabled = false;
            }
        }
    }
}

function impl(c) {
    if (c.checked) {
        document.getElementById('btnComando').disabled = '';
    }
    else {
        document.getElementById('btnComando').disabled = 'disabled';
    }
}

function openTrans() {
    if (document.getElementById("t8").checked)
        document.getElementById("indicacao").style.display = '';
    else
        document.getElementById("indicacao").style.display = 'none';
}

function setTrans(n) {
    var input = document.getElementsByName("chkTransportadora");
    
    for (var i = 0; i < input.length; i++) {
        if (n != input[i].value)
            input[i].checked = false;
    }

    if (n >= 1 && n <= 5)
        document.getElementById("t8").checked = true;

    switch (parseInt(n)) {
        case 1:
            document.forms[0].txtNomeTransporte.value = "Rodonaves";
            document.forms[0].txtTelefoneTransporte.value = "11 2192-3103";
            break;
        case 2:
            document.forms[0].txtNomeTransporte.value = "Jameff";
            document.forms[0].txtTelefoneTransporte.value = "11 2121-6161";
            break;
        case 3:
            document.forms[0].txtNomeTransporte.value = "Ramos";
            document.forms[0].txtTelefoneTransporte.value = "11 2955-1500";
            break;
        case 4:
            document.forms[0].txtNomeTransporte.value = "Braspress";
            document.forms[0].txtTelefoneTransporte.value = "11 2198-9000";
            break;
        case 5:
            document.forms[0].txtNomeTransporte.value = "DVA Express";
            document.forms[0].txtTelefoneTransporte.value = "11 2319-2001";
            break;
        case 6:
            document.forms[0].txtNomeTransporte.value = "Cliente retira";
            document.forms[0].txtTelefoneTransporte.value = "";
            break;
        case 7:
            document.forms[0].txtNomeTransporte.value = "Correio";
            document.forms[0].txtTelefoneTransporte.value = "3003-0100";
            break;
    }
}

function teclaFalse(n){
    return false;
}

function montaSWF(arquivo,largura,altura,action){

	var now = new Date();	
	var dia = now.getDay();
	var mes = now.getMonth();
	var ano = now.getFullYear();
	var hora = now.getHours();
	var mintuto = now.getMinutes();
	var segundo = now.getSeconds();
	var data = ano+""+mes+""+dia+""+hora;

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">');
	document.write('<param name="movie" value="swf/'+ arquivo +'.swf?ieSux='+ data +'" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="FlashVars" value="'+ action +'&clearCache='+ data +'" />');
	document.write('<embed FlashVars="'+ action +'&clearCache='+ data +'" wmode="transparent" menu="false" src="swf/'+ arquivo +'.swf?ieSux='+ data +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + largura + '" height="' + altura + '"></embed>');
	document.write('</object>');
}

function abreJanela(arquivo,nome,barra,largura,altura) {
	window.open(arquivo,nome,"resizable=no,toolbar=no,status=no,menubar=no,scrollbars="+barra+",width="+largura+",height="+altura);
}