﻿function overmodelos(obj) {
    obj.style.backgroundPosition = 'bottom';
    document.getElementById("DIV" + obj.id).style.display = 'inline';
}
function outmodelos(obj) {
    obj.style.backgroundPosition = 'top';
    document.getElementById("DIV" + obj.id).style.display = 'none';
}

function volta_info() {
    document.getElementById('volvo_informa').className = 'area-de-informacoes-veiculos-oculta';
}

function informacoes_volvo(obj) {
    if (obj.id == 's40') {
        document.getElementById('volvo_informa').className = 'area-de-informacoes-veiculos-info-s40';
    } else if (obj.id == 's60') {
        document.getElementById('volvo_informa').className = 'area-de-informacoes-veiculos-info-s60';
    } else if (obj.id == 's80') {
        document.getElementById('volvo_informa').className = 'area-de-informacoes-veiculos-info-s80';
    } else if (obj.id == 'v50') {
        document.getElementById('volvo_informa').className = 'area-de-informacoes-veiculos-info-v50';
    } else if (obj.id == 'xc60') {
        document.getElementById('volvo_informa').className = 'area-de-informacoes-veiculos-info-xc60';
    } else if (obj.id == 'xc70') {
        document.getElementById('volvo_informa').className = 'area-de-informacoes-veiculos-info-xc70';
    } else if (obj.id == 'xc90') {
        document.getElementById('volvo_informa').className = 'area-de-informacoes-veiculos-info-xc90';
    } else if (obj.id == 'c30') {
        document.getElementById('volvo_informa').className = 'area-de-informacoes-veiculos-info-c30';
    } else if (obj.id == 'c70') {
        document.getElementById('volvo_informa').className = 'area-de-informacoes-veiculos-info-c70';
    }
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}

startList = function () {
    if (document.all && document.getElementById) {
        navRoot = document.getElementById("nav");
        for (i = 0; i < navRoot.childNodes.length; i++) {
            node = navRoot.childNodes[i];
            if (node.nodeName == "LI") {
                node.onmouseover = function () {
                    this.className += " over";
                }
                node.onmouseout = function () {
                    this.className = this.className.replace(" over", "");
                }
            }
        }
    }
}
window.onload = startList;

function AbrirPopupSemiNovos(chassi, empresa, produto, modelo) {
    var link;
    link = "PopupSeminovos.aspx?ChassiResumido=" + chassi + "&Empresa=" + empresa + "&Produto=" + produto + "&Modelo=" + modelo;
    window.open(link, "", "height = 650, width = 540, scrollbars = yes", true);
}

/* Informacoes tecnicas */

function abreItens(obj) {
    $("#area_com_rolagem table").hide()
    
    if (obj.value == 'none') {
        $("#area_com_rolagem table").show()
    } else {
        $("#" + obj.value).show()
    }
}

$(function () {
    if ($(".galeria").length > 0) {
        $(".menu-novos").css("top", $(".img-principal").height())
    }

    $(".menu-novos ul li")
    .mouseover(function () {
        $(this).find("a").css("background-position", "0px 0px")
        $(this).find("a").animate({ backgroundPosition: "(0px -23px)" }, { duration: 100 })
    })
	.mouseout(function () {
	    $(this).find("a").animate({ backgroundPosition: "(0px 0px)" }, { duration: 80, complete: function () {
	        $(this).css({ backgroundPosition: "0px 0px" })
	    }
	    })
	})

    var bandeiras = $(".bandeiras-lang")
    $(".bandeiras-lang").remove()
    $(".area_direita").append(bandeiras)

    //modelos
    $(".envolta a img").each(function () {
        $(this)[0].src = "http://www.caltabiano.com.br/volvo/imgs/" + $(this)[0].src.split('/')[$(this)[0].src.split('/').length - 3] + "/" + $(this)[0].src.split('/')[$(this)[0].src.split('/').length - 1]
    })

    $('.detalhaImgs ul li a').mouseover(function () {
        $('.envolta a img').hide()
        $('#DIV' + this.id).show()
    })

    $('.envolta a img').hover(function () {
        $(this).fadeIn('normal')
    }, function () {
        $(this).fadeOut(400)
        $('.envolta a img').hide()
    })
})
