
function rendererDate(value, p, record){
	return value.dateFormat('d M Y');
}

function rendererKm(value, p, record){
	if(value != "" && value > 0){
		return value;
	} else {
		//prix = 'A d&eacute;b.';
		return 'Nc.';
	}
}
function rendererAnnee(value, p, record){
	if(value <= 1950){
		return "NC";
	}
	return value;
}

function rendererPrix(value, p, record){
	var prix = "<b>A d&eacute;b.</b>"
	var devise = record.get("devise");
	if(value != "" && value > 0){
		//prix = value+' &euro;';
		value = Math.round(value);
		prix = value+' '+devise;
	} else {
		//prix = 'A d&eacute;b.';
		prix = 'Nc.';
	}
	//return '<span class="moteur_prix">'+prix+'</span>';
	
	var str = "";
	var prixpromo = record.get("prixpromo");
	if(prixpromo != null && prixpromo > 0){
		/*str = "<span class='moteur_prix'>"+record.get("prixpromo")+"<span><br/>";
		str += "<strike>"+prix+"</strike>";*/
		
		str = "<span class='moteur_prix'>"+prix+"<span><br/>";
		str += "<strike>"+record.get("prixpromo")+"</strike>";
	}else{
		str =  prix;	
	}
	
	return str;
}

function rendererPhoto(value, p, record){
	var photo = record.get("tt");
	var urlphoto;
	var visible = record.get("visible");
	
	
	/*if(photo && photo != 0 && photo != -1){
		urlphoto = "/portail/Commons/images/"+record.get("photo")+"/thumb/"+record.get("photo")+"_1."+record.get("extension");
	}else if(photo == 0 || photo == -1){
		urlphoto = "/portail/gaaservices/design/img/production/thumbs/NO-Photo.jpg"
	}*/
	
	if(photo && visible && visible && visible > 1 && photo != 0 && photo != -1 && record.get("hasthumb") == 1){
		urlphoto = "/portail/Commons/images/"+record.get("photo")+"/thumb/"+record.get("photo")+"_1."+record.get("extension");
	}else if(photo == null || photo == 0 || photo == -1 || visible == 1 || visible == 0 || record.get("hasthumb") == 0){
		urlphoto = "/portail/gaaservices/design/img/production/thumbs/NO-Photo.jpg"
	}
	return String.format('<b><i>{0}</i></b>', '<img src="'+urlphoto+'"/>');
} 

/*
function rendererAnnonce(value, p, record){
	tabAnnonce = record.data['annonce'];
	clim = "";
	if(tabAnnonce[5] && tabAnnonce[5] == "1" ){
		clim = ",climatis&eacute;";
	}
	if (tabAnnonce[3]) {
		cv = tabAnnonce[3] + 'CV';
	} else {
		cv = "";
	}
	
	var km;
	if(tabAnnonce[4] == 0){
		km = ""
	}else{
		km = tabAnnonce[4]+" KM";
	}
	return String.format('<b><a href="/Particulier/Detailsannonce/index/transaction/vente/idannonce/{6}" onclick="return false;">{0}&nbsp;{1}</a></b>' 
				+ ' <a href="#addPAnier" onclick="addPanier({6}); return false;" class="panier" title="Ajouter au panier !"><img src="/plateforme/Commons/images/Caddie4.gif" class="panier" alt="Ajouter au panier"/></a>' 
				+ '<br/>{2}&nbsp;{3}<br/>{4}{5}'
			,tabAnnonce[0],tabAnnonce[1],tabAnnonce[2],cv,km,clim,record.get("idannonce"));
}       
*/


function rendererAnnonce(value, p, record){
	tabAnnonce = record.data['annonce'];
	clim = "";
	if(tabAnnonce[5] && tabAnnonce[5] == "1" ){
		clim = ",climatis&eacute;";
	}
	if (tabAnnonce[3]) {
		cv = tabAnnonce[3] + 'CV';
	} else {
		cv = "";
	}
	
	var km;
	if(tabAnnonce[4] == 0){
		km = ""
	}else{
		km = tabAnnonce[4]+" KM";
	}
	
	return String.format('<a href="/Particulier/detailsAnnonce/index/idannonce/{6}" onclick="return false;"><b>{0}&nbsp;{1}</b> - Voir les d&eacute;tails</a>' 
			+ '<br/>{2}&nbsp;{3}<br/>{4}{5}<br/>' 
			+ '<a class="panier" href="#removePanier" onclick="panierRemove({6})" title="Enlever du panier"><img class="panier" alt="Enlever du panier" src="/plateforme/Commons/images/site/rem_co.gif" /> </a>'
//			+ '<br/><a href="/Particulier/Detailsannonce/index/transaction/vente/idannonce/{6}" onclick="return false;">Voir les d&eacute;tails</a>'
//			'<p><a href="#removePanier" onclick="panierRemove({6})"><img src="/plateforme/Commons/images/site/rem_co.gif" alt="enlever du panier" /></a></p>'
			,tabAnnonce[0],tabAnnonce[1],tabAnnonce[2],cv,km,clim,record.get("idannonce"));
} 


var renderRow = function (record, rowIndex, p, store){
    if(this.showPreview){
    p.body = '' +
    		'<div id="bandeau_details_'+rowIndex+'"></div>';
    
    	return 'x-grid3-row-expanded';
    }
        return 'x-grid3-row-collapsed';
    }    
