﻿///////////////////////////////////////////////////////////////////////////////////////////////////////////
//Tamanho by navegador
function tamanhoScroll() {
    if (isCurrentBrowser("Firefox")) {
        this.document.getElementById('hfTelaW').value = document.body.offsetWidth.toString();
        this.document.getElementById('hfTelaH').value = document.documentElement.clientHeight;
    }
    if (isCurrentBrowser("MSIE")) {
        this.document.getElementById('hfTelaW').value = document.body.offsetWidth.toString();
        this.document.getElementById('hfTelaH').value = document.body.offsetHeight.toString();
    }
    if (isCurrentBrowser("Safari")) {
        this.document.getElementById('hfTelaW').value = document.body.offsetWidth.toString();
        this.document.getElementById('hfTelaH').value = document.documentElement.clientHeight;
    }
}

function isCurrentBrowser(browserName) {
    if (navigator.userAgent.search(browserName) != -1)
        return true;
    else
        return false;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//Tamanho
function tamanho(obj) {
    alert('Área do navedagor:' + document.body.offsetWidth + ' x ' + document.body.offsetHeight);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//TitleRefresh
function TitleRefresh() 
{   var tas;
    tas = setTimeout("this.document.title = 'Ford Models Brasil';", 10);

}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//AlterBackgroundColor
function AlterBackgroundColor(objeto,color1,color2) {
    if (document.getElementById(objeto).style.backgroundColor == color2) {
        document.getElementById(objeto).style.backgroundColor = color1;
    }
    else {
        document.getElementById(objeto).style.backgroundColor = color2;
    }
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//AlterBackgroundMenuHome
function AlterBackgroundColorMenuHome(objeto1,objeto2, color1, color2) {
    if (document.getElementById(objeto2).style.backgroundColor == color2) {
        document.getElementById(objeto1).style.backgroundColor = color1;
        document.getElementById(objeto2).style.backgroundColor = color1;
    }
    else {
        document.getElementById(objeto1).style.backgroundColor = color2;
        document.getElementById(objeto2).style.backgroundColor = color2;
    }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//AlterBackgroundImage
function AlterBackgroundImage(objeto, image1, image2) {
    if (document.getElementById(objeto).style.backgroundImage == image2) {
        document.getElementById(objeto).style.backgroundImage = image1;
        
    }
    else {
        document.getElementById(objeto).style.backgroundImage = image2;
    }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//AlterColor
function AlterColor(objeto, color1, color2) {
    if (document.getElementById(objeto).style.color == color2) {
        document.getElementById(objeto).style.color = color1;
    }
    else {
        document.getElementById(objeto).style.color = color2;
    }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNÇÃO PARA MASCARAS
function Mascaras(e, src, mask) {
    if (window.event)
    { _TXT = e.keyCode; }
    else if (e.which)
    { _TXT = e.which; }

    if (_TXT > 47 && _TXT < 58) {
        var i = src.value.length;
        var saida = mask.substring(0, 1);
        var texto = mask.substring(i)
        if (texto.substring(0, 1) != saida)
        { src.value += texto.substring(0, 1); }
        return true;
    }
    else {
        if (_TXT != 8)
        { return false; }
        else { return true; }
    }
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//Campos de busca (Limpa no OnFocus() e Reescreve no LostFocus())
function TextOnFocus(txt) {
    txt.value = "";
}
function TextLostFocus(txt, texto) {
    if (txt.value == "") {
        txt.value = texto;
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//Mostra o Loading antes do processamento, o hidden deverá ser passado após na página mesmo.
function ShowObjeto(objeto) {

    document.getElementById(objeto).style.visibility = "visible";
}
//MENU Click /////////////////////////////////////////////////////////////////////////////////////////////
function MenuClick(objeto) {

    var obj = document.getElementById(objeto);

    if (obj.style.display == "none") 
    {
        obj.style.display = "block";
    }
    else 
    {
        obj.style.display = "none";
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////