// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

Ajax.Responders.register({
    onCreate: function(){
        if($('ajax_busy') && (Ajax.activeRequestCount > 0)){
            Effect.Appear('ajax_busy',{duration: 0.5, queue: 'end'});
        }
        if((Ajax.activeRequestCount > 0)){
            document.body.style.cursor='wait';
        }
    },
    onComplete: function(){
        if($('ajax_busy') && (Ajax.activeRequestCount == 0)){
            Effect.Fade('ajax_busy',{duration: 0.5, queue: 'end'});
        }
        if((Ajax.activeRequestCount == 0)){
            document.body.style.cursor='default';
        }
    }
});

function blank()
{
}

function load_models(e)
{
    var f=document.getElementById(e).form;    
    new Ajax.Updater('model_selector','/cars/models',{method:'get',parameters:'make='+f.search_make.value});
}

function form_reset(e)
{
    var f=document.getElementById(e).form;
    new Ajax.Updater('model_selector','/cars/models',{method:'get'});
    f.search_make.value="";
    f.search_model.value="";
    f.search_sticker_price.value="0";
    load_models(e);
}

function form_submit(e)
{
    var f=document.getElementById(e).form;
    f.submit();
}

function change_photo(dsid,img,fname)
{
   image=document.getElementById(img);
   image.src='/images/'+dsid+'/'+fname;
}
