var perem=2;
var text='';
function showCarInfo(car_id) 
{
    var params=$H({id:car_id}).toQueryString(); 
    new Ajax.Request("/includes/ajax/carinfo.php",{method:"post",parameters: params, onSuccess:this.onCarInfoLoad.bind(this)});
}

function onCarInfoLoad(transport)
{
    if(perem==0)
    {
        perem=1;
        text=transport.responseText;
    }else
    {
        var el=document.getElementById('info');
        el.innerHTML=transport.responseText;
        new Effect.Opacity('info',{from:0.0,to:1.0,duration:0.5});
        perem=2;        
    }
}
function showinfo(car_id)
{
    if(perem==2)
    {
        perem=0;
        showCarInfo(car_id);
        showCarImage(car_id);
        new Effect.Opacity('info',{from:1.0,to:0.0,duration:0.5});
        setTimeout("opshow()", 1000);
    }
}
function opshow()
{
    if(perem==1)
    {
        var el=document.getElementById('info');
        el.innerHTML=text;
        new Effect.Opacity('info',{from:0.0,to:1.0,duration:0.5});
        perem=2;
    }else
    {
        perem=1;
    }
}

function showCarImage(car_id) 
{
    var params=$H({id:car_id}).toQueryString(); 
    new Ajax.Request("/includes/ajax/carimage.php",{method:"post",parameters: params, onSuccess:this.onCarImageLoad.bind(this)});
}
var path;
function onCarImageLoad(transport)
{
    //alert(transport.responseText);
        
        //var el1=document.getElementById('bigcartd');
        var reg=/'[^']*'/g;
        //alert(transport.responseText);
        var arr=transport.responseText.match(reg);
        path=arr[2];
        path=path.substring(1, path.length-1);
       
        //new Effect.Opacity('bigcardiv',{from:0.0,to:0.0});
        //el.style.display='none';
        
        //new Effect.Opacity('bigcardiv',{from:0.0,to:0.0});
        new Effect.Opacity('bigcardiv',{from:0.0,to:1.0,duration:1.0});
        //el.style.visible='visible';
        setTimeout("divImg()", 100);
        setTimeout("backgroundImg()", 1000); 
        
        //new Effect.Scale(  'bigcardiv',  0,  {    duration: 1,    from: 0,    to: 1,    scaleX: true,    scaleY: true,    scaleContent: true,    scaleFromCenter: true,    scaleMode: box  });

}
function backgroundImg()
{
     var el1=document.getElementById('bigcartd');
     el1.style.backgroundImage='url('+path+')';
     //alert(path);
}
function divImg()
{    var el=document.getElementById('bigcardivimg');
     //var el=document.getElementById('bigcardiv');
     el.src=path;
     //el.style.display='block';
     //alert(path);
}
