/*******************************************
**
**  TEMPLATES
**
**
********************************************/

/*#################################################
##  Templates #####################################
#################################################*/

/*############################
## Config Vars #############*/

var tdvTemplate ={
	/* Step 1 */
	step1:{printResult:function(sId,sProgName,sThumb,sVille,sRem1,sRem2,sRem3,nDispo,counter){
		var defaultZoom = 7;
				
		if(sThumb == "" || sThumb == "null") sThumb = "../../images/default_prog_thumb.jpg";
		
		// check consistency of data // rr404	
		if(sRem1 != "") sRem1 = '&bull; '+fitStr(sRem1,defaultVal.progResLength);
		if(sRem2 != "") sRem2 = '&bull; '+fitStr(sRem2,defaultVal.progResLength);
		if(sRem3 != "") sRem3 = '&bull; '+fitStr(sRem3,defaultVal.progResLength);
		
		var sDispo = "Aucun lot";//var sDispo = "Aucun lot disponible";
		var sDispoClass = "textRouge"; // change to textRouge si on veut le feature, mais faire le css avant // rr404
		if(nDispo == 1){
			sDispo = " 1 lot";	//sDispo = " 1 lot disponible";	
			sDispoClass = "textVert";
		}
		else{
			if(nDispo > 1){
				sDispo = ""+nDispo+" lots";//sDispo = ""+nDispo+" lots disponibles";
				sDispoClass = "textVert";
			}
		}
		
		
		
		
		////////////
		// PAGE 1 //
		////////////
		// formating result		
		//Eli********** Ajout de deux fonctions
		
		if(sProgName.length > 22) sProgName = sProgName.substring(0,22)+"...";
		if(sVille.length > 30) sVille = sVille.substring(0,30)+"...";
		
		if(currentCustomer == "cap2j") sDispo=""; // Pour ne pas afficher pour CAP2J le DIV
		
		/*Eli*****modif*/var res = '<div id="'+sId+'" nplace="'+counter+'" style="background:url(../../images/fiche.jpg); background-repeat:no-repeat; width:440px; height:95px; padding-top:3px; padding-bottom:3px;" onmouseover="mouseOverHl(\''+sId+'\')" setLotPDM(\''+sId+'\')"; onmouseover="unhlSelection_prog(\''+sId+'\')" >'
			+'<table cellpadding="0" cellspacing="0"><tr>'
			+'	<td width="10">&nbsp;</td>'
			+'  <td width="104"><div class="form" style="cursor:pointer" onclick="gotoSelection(\''+sId+'\',2); "><img src="'+sThumb+'" width="104" height="77" border="1"></div></td>'
			+'  <td width="210" valign="top">'
			+'	    <div class="title1" style="padding-left:5px; height:15px"><strong>'+sProgName+'</strong></div>'
			+'		<div class="title1" style="padding-left:5px; height:15px"><em>'+sVille+'</em></div>'
			+'		<div class="form" style="padding-left:20px; height:43px">'
			+'				'+sRem1+'<br>'
			+'				'+sRem2+'<br>'
			+'				'+sRem3+'</div>'
			+'	    <div class="'+sDispoClass+'" id="PRGM_idle" align="right">'+sDispo+'</div></td>'
			+'  <td width="99">'
			/*Eli*****modif*/+'	<div style="padding-left:10px"><div onclick="gotoSelection(\''+sId+'\',2); " class="textBleu" style="cursor:pointer">En savoir plus...</div></div>'
			+'	<div style="padding-left:10px; padding-top:10px"><div onclick="centerOnMarker(\''+sId+'\','+defaultZoom+')" class="textBleu" style="cursor:pointer">Positionner sur la carte</div></div>'
			+'  </td>'
			+'  <td width="13">&nbsp;</td>'
			+'</tr></table></div>';
		
		return res;
		} //end of printResult:function
	}, //end of step1
	

		//////////// ///
		// PAGE 2   //
		///////////////
	/**************************************************************************/
	// structure : {lots:[{lot_id:"132",nb_p:X, nom:"resumeL1", ot:0, ob:0, op:0, oc:0, oj:0 ,url_thumb:"./x.jpg",ref_pdm:"L.123",sup:"50", prix:"150000", dispo:0/1}],url_pdm:"./pdm.swf",url_vdo:"vdo.flv", date_dispo:""}	
	step2:{printResult:function(sId,nb_p,nom,ot,ob,op,oc,oj,url_thumb,ref_pdm,superf,prix,dispo,npl){

		if(url_thumb == "" || url_thumb == "null") url_thumb = '../../images/default_lot_thumb.jpg';
		
		var type = "T"+nb_p;
		
		var opts = "";
		if(ot == 1) opts += ' <img src="../../images/opt_terrasse.png" alt="terrasse" />';
		if(ob == 1) opts += ' <img src="../../images/opt_balcon.png" alt="balcon" />';
		if(op == 1) opts += ' <img src="../../images/opt_parking.png" alt="parking" />';
		if(oc == 1) opts += ' <img src="../../images/opt_celier.png" alt="celier" />';
		if(oj == 1) opts += ' <img src="../../images/opt_jardin.png" alt="jardin" />';
		
		if(ref_pdm == 'null') ref_pdm = 'noRef'+npl;
		
		var dispoTxt = '<div class="textVert" align="left">lot disponible</div>';
		if(dispo == 0) dispoTxt = '<div class="textRouge" align="left">lot indisponible</div>';
		if(dispo == 2) dispoTxt = '<div class="textOrange" align="left">lot réservé</div>';
		
		if(nom.length > 25) nom = nom.substring(0,23)+"...";
		
		var prixStr = "";
		if(prix <= 0) prixStr = "NC";
		else prixStr = prix+" &euro;"
		
		//Eli********** Ajout d'une fonction
		/*Eli*****modif*/var res = '<div id="'+ref_pdm+'" style="background:url(../../images/fiche_2.jpg); height:100px; width:430px; background-repeat:no-repeat; padding-left:10px" onmouseover="mouseOverHl_lot(\''+ref_pdm+'\')" onmouseover="unhlSelection_lot(\''+ref_pdm+'\')" nplace="'+npl+'" nprix="'+prix+'" nsurf="'+superf+'" sid="'+sId+'" >'
				 +'  <table width="425" height="92" cellpadding="0" cellspacing="0">'
                 +'     <tr><td width="112"><div class="form" style="cursor:pointer" onclick="gotoSelection(\''+sId+'\',3,\''+ref_pdm+'\');"><img src="'+url_thumb+'" width="104" height="77" border="1"></div></td>'
                 +'         <td width="153" align="center" class="DottedBorderTab">'
				 +'            <div style="height:50px"><div class="title1" style="text-align:left;"><strong>'+nom+'</strong></div><div style="text-align:left; font-size:15px; padding-top:10px"><strong>'+type+'</strong> : '+opts+'</div></div>'
                 +              dispoTxt
                 +'            <div align="left"><div style="cursor:pointer" onclick="gotoSelection(\''+sId+'\',3,\''+ref_pdm+'\'); " class="textBleu">En savoir plus...</div></div></td>'
                 +'         <td width="75" align="center" class="DottedBorderTab">'+superf+' m&sup2;</td>'
                 +'         <td width="83" align="center" class="title1">'+prixStr+' </td></tr></table></div>';
		
		return res;
		} // end ofprintResult:function
	} // end of step2
};
