//Ajout panier
function ART_panier(vehicule_id, vehicule_prixn) {
	document.getElementById('divAJAX').style.visibility="visible";
	ART_ajax('page.php?module=panier&action=panier&vehicule_id='+vehicule_id+'&vehicule_prixn='+vehicule_prixn ,'divAJAX',0);
	ART_ajax('page.php?module=panier&action=panier_message' ,'select_haut',0);
	ART_ajax('page.php?module=panier&action=panier_message' ,'select_bas',0);
	//ART_ajax('page.php?module=panier&action=ajout&vehicule_id='+vehicule_id+'&vehicule_prixn='+vehicule_prixn ,'divAJAX',0);
	setTimeout('ART_ajaxHide();', 2000);
}

//Ajout panier (page détail)
function ART_detail(vehicule_id, vehicule_prixn) {
    document.getElementById('divAJAX').style.visibility="visible";
    ART_ajax('page.php?module=panier&action=panier&vehicule_id='+vehicule_id+'&vehicule_prixn='+vehicule_prixn ,'divAJAX',0);
    ART_ajax('page.php?module=panier&action=panier_message' ,'select',0);
    document.getElementById('ajout').innerHTML= "Véhicule ajouté à la sélection.";
    setTimeout('ART_ajaxHide();', 2000);
}

//PHOTO ajax
function ART_ajaxShow(id, table){
	document.getElementById('divAJAX').style.visibility="visible";
	ART_ajax('page.php?module=defaut&action=photo&id='+id+'&table='+table ,'divAJAX',0);
}
function ART_ajaxHide(){
	document.getElementById('divAJAX').style.visibility="hidden";
	document.getElementById('divAJAX').innerHTML= "";
}
function ART_ajaxSwap(photo){
	 var imgCibleSrc = document.getElementById('photo_grande').src;
	 var imgSourceSrc = photo.src;
	 
	 CibleSrc = imgCibleSrc.replace('grande', 'petite');
	 SourceSrc = imgSourceSrc.replace('petite', 'grande');
	 
	 document.getElementById('photo_grande').src = SourceSrc;
	 photo.src = CibleSrc;
}


function ART_print() {
    if(document.getElementById("no_print").innerHTML) {
       var envoi_texte = document.getElementById("envoi_texte").value;
       var no_print = document.getElementById("no_print").innerHTML;
       document.getElementById("no_print").innerHTML = "";
    } 
    var contenu = document.getElementById("print").innerHTML;
    Print = window.open();
    Print.document.open();
    Print.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>FRANCE CARS OCCASION</title></head><link href=\"./theme/defaut/css/defaut.css\" rel=\"stylesheet\" type=\"text/css\" /><body style=\"background-color:#FFF\" onload='window.print();'>"+contenu+"</body></html>");
    Print.document.close();
    if(no_print){
        document.getElementById("no_print").innerHTML = no_print;
        document.getElementById("envoi_texte").value = envoi_texte;   
    } 
}


//CDC
function ART_launch_cdc(){
    var test=eval("pic"+id_cdc);
    if(test.complete){
       ART_cdc(); 
       setTimeout('ART_div();', 6000); 
    }else{
       setTimeout('ART_launch_cdc();', 10);
    }
}

var cdc_height=75; // hauteur du div
var cdc_i=cdc_height; 
var cdc_j=0;
var mouvement="";
var vitesse=7;
 
function ART_div() {
	if(cdc_i<0 && cdc_j==0) { 
		cdc_j=1; 
		cdc_i=0; 
		ART_cdc();
	}
	if(cdc_i>cdc_height && cdc_j==1) {
        document.getElementById("cdc_transition").style.height = cdc_height+'px';
        return ART_repeat();
    } 

	document.getElementById("cdc_transition").style.height = cdc_i+'px';
	if(cdc_j==1) cdc_i= cdc_i+vitesse; else cdc_i=cdc_i-vitesse;
	clearTimeout(mouvement);
	mouvement = setTimeout("ART_div();", 40);
}
function ART_repeat() {
    cdc_i=cdc_height;
    cdc_j=0;
    clearTimeout(mouvement);
    mouvement = setTimeout("ART_div();", 6000);
}
function ART_redirection() {
    window.location.href = "index.php?module="+cdc[id_cdc][4]+"&action=detail&vehicule_id="+cdc[id_cdc][0];
}
function ART_cdc() {
    if(id_cdc==nb_cdc) id_cdc=0; else id_cdc++; 
    document.getElementById("cdc_lien").onclick= ART_redirection;
    document.getElementById("cdc_transition").style.width = (eval('pic'+id_cdc+'.width')+6)+'px';
    document.getElementById("cdc_transition").style.height = (eval('pic'+id_cdc+'.height')+6)+'px';
    document.getElementById("cdc_transition").style.backgroundImage = "url('"+eval('pic'+id_cdc+'.src')+"')";
    document.getElementById("cdc_prix").innerHTML = cdc[id_cdc][3];
	document.getElementById("cdc_txt").innerHTML = cdc[id_cdc][1]+"<br />"+cdc[id_cdc][2];
	//alert(eval('pic'+id_cdc+'.height')+' '+document.getElementById("cdc_transition").style.height);
    cdc_height = eval('pic'+id_cdc+'.height')+6;
    if(cdc_i==0) ART_div();
}
