﻿$(document).ready(function(){
    
    function modelActive(model){
        model.find(".carPopup").animate({top: "-270px", height: "320px"},1000);
        model.find("a>.img").animate({width:"208px", height:"123px", top:"0px", left:"-17px"});
        model.find(".carPopup").css("cursor","pointer");
    }

    // page setup
    //var $introText = $("#introText").css({"top":"300px", "height":"0px"});
    $(".carPopup").css({"top":"50px", "height":"0px", "overflow":"hidden", "display": "block"});
    $("#.carPromo a>.img").css({width:"168px", height:"99px", top:"10px", left:"0px"});

    // starting animation
    //$introText.animate({top: "70px", height: "230px"},1000);

    $(".carPromo").hover(function(){
        modelActive($(this));
    },function(){
        var a = $(this);
        a.find(".carPopup").stop(true, false).animate({top: "50px", height: "0px"},450);
        a.find("a>.img").stop(true, false).animate({width:"168px", height:"99px", top:"10px", left:"0px"});
    });

    $("#envirologos>div").mouseover(function(){
        $("#enviroblocks").fadeIn();
        $("#block"+$(this).attr("id").split("logo")[1]).fadeIn();
    }).mouseout(function(){
        $("#enviroblocks").fadeOut();
        $("#block"+$(this).attr("id").split("logo")[1]).stop(true, true).fadeOut();
    });

});

$(document).ready(function(){

    var button = "btn";
    var panel = "info";
    var rangetimer;

    function showModel(model){
        if(rangetimer){ clearTimeout(rangetimer); rangetimer = null; }
        $("#features>div").each(function(){
            var a = $(this);
            if(a.attr("id") != (panel+model)){
                //window.alert(a.attr("id") + " " + (panel+model) + " " + a.css("display"));
                a.fadeOut(500);
                //a.css({ "display" : "none" });
            }
        });
        rangetimer = setTimeout(function(){$("#" + panel + model).fadeIn(500)},500);
    }

    //$("#infoFinance").hide();
    //$("#buttons>ul").hide();

    $("#featureNav a").mouseover(function(){
        //window.alert(this.id);
        //var a = $(this);
        //var model = a.attr("id").split(button)[1];
        var model = this.id.split(button)[1];
        showModel(model);
        //$("#" + panel + model).fadeIn(500);
    }).mouseout(function(){
        //var a = $(this);
        //var model = a.attr("id").split(button)[1];
        //$("#" +panel + model).fadeOut(250);
    }).click(function(){
        return false;
    });
    $("#features>div:first").fadeIn(750);
    //$("#buttons>ul").fadeIn(750);
        
    // lancer changer
    var active = "Scrap";
    function toggleLancer(){
        active = (active == "Scrap") ? "" : "Scrap";
        var time = (IE) ? 0 : 500;
        if(IE6)
            $("#carPrices>span").fadeOut(time);
        $("#carPrices>img").fadeOut(time);
        $("#priceCar"+active).fadeIn(time);
        $("#financeTables>table").fadeOut(time);
        $("#lancerPrice" + active + "Table").fadeIn(time);
    }
    
    $("#toggleLancer").click(function(){
        toggleLancer();
        return false;
    });
    
    //$(".moreLancer #priceCar").fadeOut(0);
    //$("#lancerPriceTable").fadeOut(0);
    
});

