$(document).ready(function(){
    
    function modelActive(model){
        //$(".carPopup").animate({top: "50px", height: "0px"},450);
        //$("#.carPromo>.img").css({width:"168px", height:"99px", top:"10px", left:"0px"});
        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
    $("#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);
    //$(".carPopup").animate({top: "0px", height: "310px"},1000);

    $(".carPromo").hover(function(){
        //if(!$("#"+$(this).attr('id')+":animated")){
            modelActive($(this));
        //}
    },function(){
        //$(".carPopup").stop(true, false);
        //$("#.carPromo a>.img").stop(true, false);
        //$(".carPopup").animate({top: "50px", height: "0px"},450);
        $(this).find(".carPopup").stop(true, false).animate({top: "50px", height: "0px"},450);
        //$("#.carPromo a>.img").animate({width:"168px", height:"99px", top:"10px", left:"0px"},450);
        $(this).find("a>.img").stop(true, false).animate({width:"168px", height:"99px", top:"10px", left:"0px"});
    });

    $("#envirologos>div").mouseover(function(){
        //window.alert("ping");
        $("#block"+$(this).attr("id").split("logo")[1]).fadeIn();
    }).mouseout(function(){
        //window.alert("pong");
        $("#block"+$(this).attr("id").split("logo")[1]).stop(true, true).fadeOut();
        //$("#block"+$(this).attr("id").split("logo")[1]).fadeOut();
    });

});