/*implements Select object by D.PECCHIOLI*/

	var xPos,yPos,lgimg,opac;
	var wid;var d;
	var display=true;/*display or not fade*/
	var interval=null;
	var xPosInit,yPosInit;

Basket.prototype.constructor = Basket;

	function Basket(cat,ss_cat,listing_type){
		this.Tcat=new Array('ann','ft');
		this.Tss_cat=this.Tcat;
		this.Tss_cat['ann']=new Array('auto','moto','od');
		this.Tss_cat['ft']=new Array('auto');
		this.lgimgInit=(listing_type=='listing'?52:110);
		this.X_end_ani = 650;/*end X basket ani*/
		this.Y_end_ani = 700;/*end Y basket ani*/
		this.listing_type = listing_type;
		this.PreferedDelay = 45;
		this.delay = this.PreferedDelay;
		this.StepNumber = 20;
		this.cat=cat;
		this.ss_cat = ss_cat;
		this.maxbs = 20;
		this.data_= null;
		this.xmlhttp = null;
		this.xmlhttp_details = null;
		this.split_ = "-------\n";
		this.picto_bs_id = null;
		this.inter = null;
		this.inter_show = null;
		this.IE = document.all?true:false;
		this.off_top = (document.getElementById('top_px')?parseInt(document.getElementById('top_px').offsetTop)+6:null);
		this.Details = null;/*tableau des objets compars*/
		this.sessid = this.get_Sessid();/*get php_sessid*/
		this.step=0;
		this.initData();
		this.mode='basket';
		this.nb_el_checked = 0;
		this.isDev = false;
		this.isRec = false;
		this.isProd = false;
		if (window.location.href.match(new RegExp('\.lacentrale\.dev')))
		{
			this.isDev = true;
			this.pathStatic = window.location.href.replace(new RegExp('^[^.]*\.([^.]*\.lacentrale\.dev/).*$'),'http://dev-lc-static.$1');
		}
		else if (window.location.href.match(new RegExp('srvwrec')) || window.location.href.match(new RegExp('192\.168\.1\.4')))
		{
			this.isRec = true;
			this.pathStatic = 'http://srvwrec:81/';
		}
		else
		{
			this.isProd = true;
			this.pathStatic = 'http://static.lacentrale.fr/';
		}
		if(this.isBasket()){
			this.request('/ze_basket.php?sessid='+this.sessid);/*load bs object from database*/
		}
	}
	
	Basket.prototype.request = function(dest) {
		try { // Moz supports XMLHttpRequest. IE uses ActiveX.
			// browser detection is bad. object detection works for any browser
			this.xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e) { alert('Votre navigateur ne supporte pas ajax !');
			// browser doesn't support ajax. handle however you want
		} // the xmlhttp object triggers an event everytime the status changes
		if(this.xmlhttp!=null){
			this.xmlhttp.onreadystatechange = triggered;// triggered() function handles the events
			// open takes in the HTTP method and url.
			this.xmlhttp.open("GET", dest+'&uncache='+Math.random());
			// Moz is fine with just send(); but
			// IE expects a value here, hence we do send(null);
			this.xmlhttp.send(null);
		}
	}
	
	Basket.prototype.initData = function(){
		var i,j;
		this.data_ = new Array;
		for(i=0;i<this.Tcat.length;i++){
			this.data_[this.Tcat[i]] = new Array;
			for(j=0;j<this.Tss_cat[this.Tcat[i]].length;j++){
				this.data_[this.Tcat[i]][this.Tss_cat[this.Tcat[i]][j]] = new Array;
			}
		}
	}
	
	Basket.prototype.unserialize = function(ser_data){
		var tmp,line_,i,j;
		this.data_ = new(Array);
		var Tret = ser_data.split(this.split_);
			for(i=0;i<Tret.length;i++){
				tmp = Tret[i].split("\n");
				for(j=0;j<tmp.length;j++){
					if(tmp[j].length>0){
						line_ = tmp[j].split(";");
						if(this.data_[line_[0]]==null)this.data_[line_[0]] = new Array;
						if(this.data_[line_[0]][line_[1]]==null)this.data_[line_[0]][line_[1]] = new Array;
						if(line_[2]!='')this.data_[line_[0]][line_[1]]=line_[2].split(',');
					}
				}
			}
		this.setIsBasket();
	}	
	
	Basket.prototype.modifiePanier = function(inAnnonce,ss_cat)
	{
		if(inAnnonce=='')return false;
		if(this.sessid.length>1){
			var pos = this.isInBasket(ss_cat,inAnnonce);
			var action_ = (pos>-1?'del':'add');
			if(pos==-1 && this.data_['ann'][ss_cat].length>=this.maxbs){
				alert('Vous ne pouvez pas sélectionner plus de '+this.maxbs+' éléments dans votre sélection '+this.ss_cat_to_string(ss_cat)+'.');
				return false;
			}
	 		this.request('/ze_basket.php?sessid='+this.sessid+'&id='+inAnnonce+'&cat=ann&ss_cat='+ss_cat+'&action='+action_);
	 	}
	}
	
	Basket.prototype.modifiePanierTech = function(inAnnonce,ss_cat)
	{
		if(inAnnonce=='')return false;
		if(this.sessid.length>1){
			var pos = this.isInBasketTech(ss_cat,inAnnonce);
			var action_ = (pos>-1?'del':'add');
			if(pos==-1 && this.data_['ft'][ss_cat].length>=this.maxbs){
				alert('Vous ne pouvez pas sélectionner plus de '+this.maxbs+' éléments dans votre sélection Fiches Techniques '+this.ss_cat_to_string(ss_cat)+'.');
				return false;
			}
	 		this.request('/ze_basket.php?sessid='+this.sessid+'&id='+inAnnonce+'&cat=ft&ss_cat='+ss_cat+'&action='+action_);
	 	}
	}
	
	Basket.prototype.delete_from_Cat = function(inAnnonce)
	{
		if(this.sessid.length>1){
	 		this.request('/ze_basket.php?sessid='+this.sessid+'&id='+inAnnonce+'&cat='+this.cat+'&ss_cat='+this.ss_cat+'&action=del');
	 	}
	}
	
	Basket.prototype.setIsBasket = function(){
		var i,j,found;
		found = false;
		i=0;
		while(i<this.Tcat.length && !found){
			j=0;
			while(j<this.Tss_cat[this.Tcat[i]].length && !found){
				found = (this.data_[this.Tcat[i]][this.Tss_cat[this.Tcat[i]][j]].length>0);
				j++;
			}
			i++;
		}
		var largeExpDate = new Date ();
    largeExpDate.setTime(largeExpDate.getTime() + (86400 * 1000));
		this.setCookie('isBasket',(found?'true':''),largeExpDate);
	}
	
	Basket.prototype.isBasket = function(){
		return this.getCookie('isBasket')=='true';
	}
	
	Basket.prototype.get_Sessid = function(){
		return this.getCookie('php_sessid');
	}
	
	Basket.prototype.getCookie = function(key_id)
	{
		var i,j;
		var cookie = document.cookie;
		i = cookie.indexOf(key_id+'=');
		if(i==-1)return false;
		j = cookie.indexOf(";",i);		
		if(j==-1)j=cookie.length;
		return (unescape(cookie.substring(i+key_id.length+1,j)));
	}
	
	Basket.prototype.isIn = function(cat,ss_cat,id_){
		var i=0;
		var pos=-1;
		while(pos==-1 && i<this.data_[cat][ss_cat].length){
			if(this.data_[cat][ss_cat][i]==id_)pos=i;
			i++;
		}
		return pos;
	}
	
	Basket.prototype.isInBasket = function(ss_cat,id_){
		var i=0;
		var pos=-1;
		while(pos==-1 && i<this.data_['ann'][ss_cat].length){
			if(this.data_['ann'][ss_cat][i]==id_)pos=i;
			i++;
		}
		return pos;
	}
	
	Basket.prototype.isInBasketTech = function(ss_cat,id_){
		var i=0;
		var pos=-1;
		while(pos==-1 && i<this.data_['ft'][ss_cat].length){
			if(this.data_['ft'][ss_cat][i]==id_)pos=i;
			i++;
		}
		return pos;
	}
	
	Basket.prototype.refresh_listing = function(cat,ss_cat,id_s,site){
		if(cat==null)return;
		if(ss_cat==null)return;
		if(id_s==null)return;
		if(site==null)return;
		var Tid = id_s.split(',');
		var i,pic_id;
		
		for(i=0;i<Tid.length;i++)
		{
			if((pic_id = document.getElementById(cat+'_'+ss_cat+'_'+Tid[i]))!= null && pic_id.src!=null)
			{
				if(bs.isIn(cat,ss_cat,Tid[i])>-1)
				{
					pic_id.src=this.pathStatic+'images/'+site+'_fr/moins.gif';
					pic_id.title='Retirer de ma sélection';
					pic_id.alt='Retirer de ma sélection';
					pic_id.style.cursor='pointer';
					if(this.IE)
						pic_id.style.filter = '';
					else
						pic_id.style.opacity='';
				}
				else
				{
					pic_id.src=this.pathStatic+'images/'+site+'_fr/plus.gif';
					pic_id.title='Ajouter à ma sélection';
					pic_id.alt='Ajouter à ma sélection';
					pic_id.style.cursor='pointer';
					if(this.IE)
						pic_id.style.filter = '';
					else
						pic_id.style.opacity='';
				}
			}
			else if((link_id = document.getElementById(cat+'_'+ss_cat+'_'+Tid[i]))!= null)
			{
				if(bs.isIn(cat,ss_cat,Tid[i])>-1)
				{
					link_id.innerHTML='Retirer de ma s&eacute;lection';
					link_id.title='Retirer de ma sélection';
					link_id.style.cursor='pointer';
					link_id.className = 'BasketOff'
				}
				else
				{
					link_id.innerHTML='Ajouter &agrave; ma s&eacute;lection';
					link_id.title='Ajouter à ma sélection';
					link_id.style.cursor='pointer';
					link_id.className = 'BasketOn'
				}
			}
		}
	}
	
	Basket.prototype.req_details = function(cat,ss_cat) {
		try {
			this.xmlhttp_details = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
			}
		catch (e) { alert('Votre navigateur ne supporte pas ajax !');
		} 
		if(this.xmlhttp_details!=null){
			this.cat = cat;
			this.ss_cat = ss_cat;
			this.xmlhttp_details.onreadystatechange = triggered_details;
			this.xmlhttp_details.open("GET", '/ze_proxy.php?ws='+(this.cat=='ann'?'get_mini_detail_lc':'get_mini_fichtech_lc')+'&user=js&password=none&out=js&categorie='+ss_cat+(this.cat=='ft' && this.listing_type==null?'&photo=1':'')+'&id='+bs.data_[cat][ss_cat]);
			this.xmlhttp_details.send(null);
		}
	}
	
	Basket.prototype.delete_from = function(cat,ss_cat){
		var i;
		if(cat==null || ss_cat==null)return;
		var To_delete=new Array();
		for(i=0;i<bs.data_[cat][ss_cat].length;i++){
			if(document.getElementById('sel_'+cat+'_'+ss_cat+'_'+bs.data_[cat][ss_cat][i]).checked)
				To_delete[To_delete.length]=bs.data_[cat][ss_cat][i];
		}
		if(To_delete.length==0){
			alert('Vous devez sélectionner au moins un élément à retirer.');
			return false;
		}
		this.cat = cat;
		this.ss_cat = ss_cat;
		this.delete_from_Cat(To_delete);
		return true;
	}
	
	Basket.prototype.Action = function(id_){
		if (this.mode=='basket')
		{
			window.location='detail_'+this.ss_cat+'_flat.php?annonce='+id_+'&from=basket';
		}
		else if (this.mode=='compare')
		{
			document.getElementById('sel_'+this.cat+'_'+this.ss_cat+'_'+id_).checked = ! document.getElementById('sel_'+this.cat+'_'+this.ss_cat+'_'+id_).checked;
			if (document.getElementById('sel_'+this.cat+'_'+this.ss_cat+'_'+id_).checked)
			{
				this.nb_el_checked++;
				if (this.nb_el_checked>4)
				{
					alert('Vous ne devez pas sélectionner plus de 4 éléments à comparer.');
					document.getElementById('sel_'+this.cat+'_'+this.ss_cat+'_'+id_).checked=false;
					this.nb_el_checked--;
				}
				else
					document.getElementById('picto_check_'+id_).className='SelectCheckShow';
				if (this.nb_el_checked==4)
					bs.Compare(bs.cat,bs.ss_cat);
			}
			else
			{
				this.nb_el_checked--;
				document.getElementById('picto_check_'+id_).className='SelectCheck';
			}
		}
	}
	
	Basket.prototype.ChangeMode = function(mode){
		if (mode!='basket' && mode!='compare') return;
		
		this.mode = mode;
		if (mode=='basket')
		{
			for(i=0;i<bs.data_[this.cat][this.ss_cat].length;i++)
			{
				document.getElementById('picto_suppr_'+bs.data_[this.cat][this.ss_cat][i]).className='SelectSupprShow';
				document.getElementById('picto_check_'+bs.data_[this.cat][this.ss_cat][i]).className='SelectCheck';
				document.getElementById('AnnComparer2').style.display='block';
				document.getElementById('AnnComparer').style.display='none';
			}
		}
		else if (mode=='compare')
		{
			if (bs.data_[this.cat][this.ss_cat].length<=4)
			{
				for(i=0;i<bs.data_[this.cat][this.ss_cat].length;i++)
				{
					document.getElementById('sel_'+this.cat+'_'+this.ss_cat+'_'+bs.data_[this.cat][this.ss_cat][i]).checked = true;
					document.getElementById('picto_check_'+bs.data_[this.cat][this.ss_cat][i]).className='SelectCheckShow';
				}
				bs.Compare(bs.cat,bs.ss_cat);
			}
			else
			{
				for(i=0;i<bs.data_[this.cat][this.ss_cat].length;i++)
				{
					document.getElementById('picto_suppr_'+bs.data_[this.cat][this.ss_cat][i]).className='SelectSuppr';
					if (document.getElementById('sel_'+this.cat+'_'+this.ss_cat+'_'+bs.data_[this.cat][this.ss_cat][i]).checked)
						document.getElementById('picto_check_'+bs.data_[this.cat][this.ss_cat][i]).className='SelectCheckShow';
					else
						document.getElementById('picto_check_'+bs.data_[this.cat][this.ss_cat][i]).className='SelectCheck';
					document.getElementById('AnnComparer2').style.display='none';
					document.getElementById('AnnComparer').style.display='block';
				}
			}
		}
	}
	Basket.prototype.Compare = function(cat,ss_cat){
		if(cat==null || ss_cat==null)return;
		var i;
		var To_compare=new Array();
		for(i=0;i<bs.data_[cat][ss_cat].length;i++){
			if(document.getElementById('sel_'+cat+'_'+ss_cat+'_'+bs.data_[cat][ss_cat][i]).checked)
				To_compare[To_compare.length]=bs.data_[cat][ss_cat][i];
		}
		if(To_compare.length<2){
			alert('Vous devez sélectionner au moins 2 éléments à comparer.');
			return;
		}else if(To_compare.length>4){
			alert('Vous ne devez pas sélectionner plus de 4 éléments à comparer.');
			return;
		}
		this.setCookie('compare',cat+'|'+ss_cat+'|'+To_compare);
		window.location.href = '/prepare_and_compare.php';
	}
	
	Basket.prototype.getCompare = function(){
		var Tcompare = this.getCookie('compare').split('|');
		this.cat=Tcompare[0];
		this.ss_cat=Tcompare[1];
		return Tcompare[2].split(',');
	}
	
	Basket.prototype.changePos=function(ob,in_){
		xPos += (xPosInit>this.X_end_ani?-1:1)*(parseInt(Math.abs(xPos - this.X_end_ani)/12) - (this.step<8?(yPos - this.Y_end_ani)/10:0));
		yPos += (yPosInit>this.Y_end_ani?-1:1)*(parseInt(Math.abs(yPos - this.Y_end_ani)/12));
		if(in_){lgimg*=0.96;opac*=0.92;}else lgimg*=1.02;
		if(!in_){
			ob.style.left = xPos+'px';
			ob.style.top = yPos+'px';
			ob.style.width = lgimg+'px';
		}
		if(in_){			
			if(display){
				if(this.IE){
					ob.style.filter = 'alpha(opacity='+opac+');';
					this.picto_bs_id.style.filter = 'alpha(opacity='+opac+');';
				}
				else {
					ob.style.opacity=opac;
					this.picto_bs_id.style.opacity=opac;
				}
			}
		}
		if(this.step>30 || this.delay<10){
			window.clearInterval(interval);
			interval=null;
			if(this.cat=='ann')this.modifiePanier(wid,this.ss_cat);
			else if(this.cat=='ft')this.modifiePanierTech(wid,this.ss_cat);
			this.picto_bs_id = null;
			ob.style.width=0+'px';
			ob.style.left = xPosInit+'px';
			ob.style.top = (yPosInit-(this.listing_type=='listing'?3:0))+'px';
		}else if(new Date().getTime() - d > (1.1*this.PreferedDelay)){
			window.clearInterval(interval);			
			this.delay*=0.8;
			interval = setInterval('bs.changePos(ob,'+in_+')', this.delay);
		}
		this.step++;
		d = new Date().getTime();
	}
	
	Basket.prototype.start_listing_ani = function(id_,cat,s_cat,myHeight,ob_){
		if(interval!=null)return;
		var target_ref;
		if((target_ref = document.getElementById('SelectCont')) != null)target_ref.style.display='block';
		var pic_ref;
 		if (cat=='ann' && bs.mode == 'compare')
 		{
			bs.ChangeMode('basket');
	 		this.nb_el_checked=0;
		}
		if( (pic_ref = document.getElementById('pic_pos_select')) != null ){
			this.X_end_ani = pic_ref.offsetLeft-10;
			this.Y_end_ani = pic_ref.offsetTop-30;
		}
		var is_in_bs = (cat=='ann'?this.isInBasket(s_cat,id_)>-1:this.isInBasketTech(s_cat,id_)>-1);		
		if(cat=='ann'){
			ob_.innerHTML = (is_in_bs?'Retrait en cours':'Ajout en cours');			
			ob_.className = 'PanierEnCours';
		}
		else{
			if(this.IE)ob_.style.filter = 'alpha(opacity=30);';
			else ob_.style.opacity=0.30;
		}
		
		if(!is_in_bs && this.data_[cat][s_cat].length>=this.maxbs){
			alert('Vous ne pouvez pas sélectionner plus de '+this.maxbs+' éléments dans votre sélection '+this.ss_cat_to_string(s_cat)+'.');
			return;
		}
		ob = document.getElementById('img_'+id_);
		this.cat = cat;
		this.ss_cat = s_cat;
		var ele = document.getElementById(this.cat+'_detail_'+this.ss_cat);
		if(ele.style.display=='none'){
			this.hide_and_show(this.cat,this.ss_cat,myHeight);
		}
		yPos = ob.offsetTop;
		xPos = ob.offsetLeft;
		if(this.IE){
			ob.style.filter = 'alpha(opacity=70);';
			opac = 70;
		}
		else {
			ob.style.opacity=0.70;
			opac = 0.70;
		}
		this.picto_bs_id = document.getElementById('picto_bs_'+id_+'_'+this.ss_cat);
		lgimg = this.lgimgInit;
		if(!is_in_bs)ob.style.width = lgimg+'px';
		xPosInit=xPos;yPosInit=yPos;this.step=0;
		wid = id_;
		this.delay = this.PreferedDelay;
		interval = setInterval('bs.changePos(ob,'+is_in_bs+')', this.delay);
	  d = new Date().getTime();
	}
	
	Basket.prototype.encode_to_lc_url = function(chaine){
		return chaine.replace(new RegExp('/','g'),'*').replace(new RegExp('\\+','g'),'~').replace(new RegExp('\'','g'),'`').replace(new RegExp('-','g'),'_').replace(new RegExp('&','g'),'^').replace(new RegExp(' ','g'),'+');
	}
	
	Basket.prototype.decode_from_lc_url = function(chaine){
		return chaine.replace(new RegExp('\\*','g'),'/').replace(new RegExp('~','g'),'+').replace(new RegExp('`','g'),'\'').replace(new RegExp('_','g'),'-').replace(new RegExp('\\^','g'),'&');
	}
	
	Basket.prototype.encode_od_to_lc_url = function(chaine){
		return chaine.replace(new RegExp('"','g'),'`').replace(new RegExp(';','g'),'.').replace(new RegExp(',','g'),'.').replace(new RegExp(' ','g'),'+').replace(new RegExp(':','g'),'_').replace(new RegExp('\\\\','g'),'|').replace(new RegExp('/','g'),'|');
	}
	
	Basket.prototype.hide_and_show = function(cat,ss_cat,myHeight){
		var i,j;
		this.cat = cat;
		this.ss_cat = ss_cat;
		var ele = document.getElementById(cat+'_detail_'+ss_cat);
		if(ele.style.display==''){
			ele.style.display='none';
			this.define_title(cat,ss_cat);
			/*myHeight.hide();
			myHeight.toggle();*/
		}
		else{
			ele.style.display='';
			for(i=0;i<this.Tcat.length;i++){
				for(j=0;j<this.Tss_cat[this.Tcat[i]].length;j++){
					if((this.cat!=this.Tcat[i]) || (this.ss_cat!=this.Tss_cat[this.Tcat[i]][j]))
						document.getElementById(this.Tcat[i]+'_detail_'+this.Tss_cat[this.Tcat[i]][j]).style.display='none';
					this.define_title(this.Tcat[i],this.Tss_cat[this.Tcat[i]][j]);
				}
			}
			if(!/[a-zA-Z]/.test(ele.innerHTML))bs.req_details(this.cat,this.ss_cat);
			else {
				/*myHeight.hide();
				myHeight.toggle();*/
			}
		}
	}
	
	Basket.prototype.cat_to_string = function(chaine){
		if(chaine=='ann')return 'Annonces';
		if(chaine=='ft')return 'Fiches techniques';
	}
	
	Basket.prototype.ss_cat_to_string = function(chaine){
		if(chaine=='auto')return 'Voitures';
		if(chaine=='moto')return 'Motos';
		if(chaine=='od')return 'Accessoires';
	}
	
	Basket.prototype.define_title = function(cat,ss_cat){
		/*if(cat=='ann'){			
			document.getElementById('main_'+cat+'_'+ss_cat).innerHTML = '<table width="100%"><tr><td width="200px">Ma s&eacute;lection d'+(ss_cat=='od'?'\'':'e ')+'<b>'+this.ss_cat_to_string(ss_cat)+
			'</b> ('+this.data_[cat][ss_cat].length+') </td><td>'+
			(bs.data_[cat][ss_cat].length>0?'<a href="#" onClick="bs.hide_and_show(\''+cat+'\',\''+ss_cat+'\',myHeight);return false;">'+(document.getElementById(cat+'_detail_'+ss_cat).style.display=='none'?'Afficher</a>':'Masquer</a>'):'&nbsp;')
			+'</td></tr></table>';
		}else if(cat=='ft'){
			document.getElementById('main_'+cat+'_'+ss_cat).innerHTML = '<table width="100%"><tr><td width="200px">Ma s&eacute;lection de <b>Fiches tech.</b> ('+this.data_[cat][ss_cat].length+') </td><td>'+
			(bs.data_[cat][ss_cat].length>0?'<a href="#" onClick="bs.hide_and_show(\''+cat+'\',\''+ss_cat+'\',myHeight);return false;">'+(document.getElementById(cat+'_detail_'+ss_cat).style.display=='none'?'Afficher</a>':'Masquer</a>'):'&nbsp;')
			+'</td></tr></table>';
		}*/
	}
	
	Basket.prototype.build_detail = function(cat,ss_cat,T){
		
		if(cat == 'ann'){
			var Txt;
			if(ss_cat=='od')Txt = (T['OB_TEXT'].length>12?T['OB_TEXT'].substr(0,12)+' ...':T['OB_TEXT']);
			else Txt = (T['MODEL'].length>10?T['MODEL'].substr(0,10)+' ...':T['MODEL']);
			return '<li class="SelectTable"><div title="Supprimer cette annonce de la sélection" class="SelectSupprShow" id="picto_suppr_'+T['ID']+'" onClick="bs.delete_from_Cat('+T['ID']+')"></div><div class="SelectCheck" id="picto_check_'+T['ID']+'"><img src="'+this.pathStatic+'images/lc_fr/picto_select_compare.png" class="SelectCheckImg" /></div><input type="checkbox" class="SelectCheckInput" id="sel_'+cat+'_'+ss_cat+'_'
						+T['ID']+'">'
						+(T['M']==1?'<div class="imgSelectM">':'<div class="imgSelect">')
						+'<a href="javascript:;" onClick="bs.Action('+T['ID']+')" class="AnnSelectLink">'
						+'<img style="width: 77px; height: 58px;" id="picto_bs_'+T['ID']
						+'_'+ss_cat+'" border="0" src="'
						+(T['IS_PHO']>0?T['photo'][0]:this.pathStatic+'images/lc_fr/vignette_type_'+ss_cat+'.png')+'" /></a>'
						+(T['M']==1?'</div>':'</div>')
						+'<a href="javascript:;" onClick="bs.Action('+T['ID']+')" class="SelectAnnLink">'
						+Txt+(ss_cat!='od'?'<br>'+this.FormatNumber(T['PRICE'],' ',3)+'&nbsp;&euro;':'')
						+'</a></li>';
						
		}else if(cat == 'ft'){
			return '<table style="height:50px" border="0" cellpadding="0" cellspacing="0"><tr><td><input type="checkbox" id="sel_'+cat+'_'+ss_cat+'_'
						+T['ID']+'" onClick="document.getElementById(\'picto_bs_\'+'
						+T['ID']+'+\'_'+ss_cat+'\').style'+(this.IE?'.filter = \'alpha(opacity=\'+(this.checked?40:100)+\');\';':'.opacity=(this.checked?0.4:1);')+'" value="'
						+T['ID']+'"></td><td width="52px"><a href="fiche-technique-'+(ss_cat=='auto'?'voiture':'')+'-'+this.encode_to_lc_url(T['BRAND'].toLowerCase())+'-'
						+this.encode_to_lc_url(T['MODEL'].toLowerCase())+'-'+this.encode_to_lc_url(T['VERSION'].toLowerCase())+'-'+T['MILLESIME']+'.html'
						+'">'
						+((typeof(T['photos'])=='object' && T['photos'].length>1)?'<div class="lcmultibrdr">':'')
						+'<img style="width: 52px; height: 39px;" id="picto_bs_'+T['ID']
						+'_'+ss_cat+'" border="0" src="'
						+(typeof(T['photos'])=='object'?T['photos'][0]:this.pathStatic+'images/lc_fr/vignette_type_'+ss_cat+'.png')+'"></img>'
						+((typeof(T['photos'])=='object' && T['photos'].length>1)?'<img style="margin: -12px 0px 0px 0px;" src="'+this.pathStatic+'images/lc_fr/multi-photo.gif" alt="Multi-photos" border="0">':'')
						+'</a>'
						+((typeof(T['photos'])=='object' && T['photos'].length>1)?'</div>':'')
						+'</td><td style="width:5px">&nbsp;</td><td style="width: 180px;"><a href="fiche-technique-'+(ss_cat=='auto'?'voiture':'')+'-'+this.encode_to_lc_url(T['BRAND'].toLowerCase())+'-'
						+this.encode_to_lc_url(T['MODEL'].toLowerCase())+'-'+this.encode_to_lc_url(T['VERSION'].toLowerCase())+'-'+T['MILLESIME']+'.html'
						+'">'+T['BRAND']+' '+T['MODEL'] + ' '+T['VERSION']
						+(ss_cat=='moto'?'&nbsp;cc':'')
						+'</a></td></tr></table>';
						
						TailleUl();
		}
	}
	
	Basket.prototype.build_list = function(cat,ss_cat,T){
		if(cat == 'ann'){
			return '<tr style="height:43px;" onClick="bs.reload_one_Compar('+T['ID']+');" onMouseOver="bs.maintain_list();this.style.backgroundColor=\'#80BFFF\';" onMouseOut="this.style.backgroundColor=\'#FFFFFF\';">'
						+'<td style="width:2px"></td><td width="52px"><img style="width: 52px; height: 39px;" id="picto_bs_'+T['ID']
						+'_'+ss_cat+'" border="0" src="'
						+(T['IS_PHO']>0?T['photo'][0]:this.pathStatic+'images/lc_fr/vignette_type_'+ss_cat+'.png')+'" />'
						+(T['M']==1?'<img src="'+this.pathStatic+'images/lc_fr/multi-photo.gif" alt="Multi-photos" border="0" style="margin:-12px 0px 0px 0px;">':'')
						+'</td><td style="width:5px">&nbsp;</td><td style="font-family:Arial;font-size:10px;">'
						+(ss_cat=='od'?T['OB_TEXT']:T['BRAND']+' '+T['MODEL'] + ' '+T['VERSION']+'&nbsp')
						+'</td></tr>';
		}else if(cat == 'ft'){
			return '<tr style="height:43px;" onClick="bs.reload_one_Compar('+T['ID']+');" onMouseOver="bs.maintain_list();this.style.backgroundColor=\'#80BFFF\';" onMouseOut="this.style.backgroundColor=\'#FFFFFF\';">'
						+'<td style="width:2px"></td><td width="52px"><img style="width: 52px; height: 39px;" id="picto_bs_'+T['ID']
						+'_'+ss_cat+'" border="0" src="'
						+(typeof(T['photos'])=='object'?T['photos'][0]:this.pathStatic+'images/lc_fr/vignette_type_'+ss_cat+'.png')+'"></img>'
						+((typeof(T['photos'])=='object' && T['photos'].length>1)?'<img src="'+this.pathStatic+'images/lc_fr/multi-photo.gif" alt="Multi-photos" border="0" style="margin:-12px 0px 0px 0px;">':'')
						+'</td><td style="width:5px">&nbsp;</td><td style="font-family:Arial;font-size:10px;">'+T['BRAND']+' '+T['MODEL'] + ' '+T['VERSION']
						+'</td></tr>';
		}
	}
	
	Basket.prototype.setDetails = function(Tdetail){
		this.Details = Tdetail;
	}
	
	Basket.prototype.startCompare = function(Tid,compare_label){
		var i;
		for(i=0;i<Tid.length;i++){
			detail[i] = new Detail(this.cat,this.ss_cat,Tid[i],i,detail,this,compare_label,Tid.length);
		}
		compare_label.setDetails(detail);
		this.setDetails(detail);
		for(i=0;i<Tid.length;i++){
			detail[i].request(detail[i].seeFT);
		}
		return detail;
	}
	
	Basket.prototype.maintain_list = function(){
		if(typeof(this.inter)!='undefined')window.clearInterval(this.inter);
		this.inter = setInterval('document.getElementById(\'select_another_item_shadow\').style.display=\'none\';document.getElementById(\'select_another_item\').style.display=\'none\';', 2000);
	}
	
	Basket.prototype.reload_one_Compar = function(id_){
		var i;
		if(typeof(this.inter)!='undefined')window.clearInterval(this.inter);
		document.getElementById('select_another_item_shadow').style.display='none';
		document.getElementById('select_another_item').style.display='none';
			
		for(i=0;i<this.Details.length;i++){
			this.Details[i].ready=false;
			if(this.cat=='ann')this.Details[i].seeFT=false;
			this.Details[i].compare = false;
		}			
				
		if(compare_label.reload_item==true){
			/*reload an item in comparator*/
			if(this.cat=='ann'){
				for(i=0;i<actif;i++)this.Details[i].Build(null);
				for(i=actif+1;i<this.Details.length;i++)this.Details[i].Build(null);
			}else{
				for(i=0;i<actif;i++)this.Details[i].Build_FT(null);
				for(i=actif+1;i<this.Details.length;i++)this.Details[i].Build_FT(null);
			}
			this.Details[actif].reloadMe(this.Details[actif].cat,this.Details[actif].ss_cat,id_,actif,this.Details,this);			
		}else{
			/*add an item in comparator*/
			for(i=0;i<this.Details.length;i++){
				detail[i].setWidthByNbEl(detail.length+1);
				detail[i].leftX=null;
				detail[i].div.style.left='-170px';
				detail[i].comptMV = 0;
			}
			this.Details[this.Details.length]=new Detail(this.cat,this.ss_cat,id_,this.Details.length,this.Details,this,compare_label,this.Details.length+1);
			this.Details[this.Details.length-1].request(this.Details[this.Details.length-1].seeFT);
			this.Details[this.Details.length-1].div.style.left='-170px';
			if(this.cat=='ann'){
				for(i=0;i<this.Details.length-1;i++)this.Details[i].Build(null);
			}
			else {
				for(i=0;i<this.Details.length-1;i++)this.Details[i].Build_FT(null);
			}
		}
		this.req_details(this.cat,this.ss_cat);
	}
	
	Basket.prototype.add_element = function(){
		var i;
		i=0;
		while(i<this.Details.length && this.Details[i].placed)i++;
		if(i<this.Details.length)return;
		compare_label.reload_item=false;
		if(typeof(this.inter)!='undefined')window.clearInterval(this.inter);
		if(typeof(this.inter_show)!='undefined')window.clearInterval(this.inter_show);
		this.inter = setInterval('document.getElementById(\'select_another_item_shadow\').style.display=\'none\';document.getElementById(\'select_another_item\').style.display=\'none\';', 2000);
		var el=document.getElementById('select_another_item');
		var el_shadow=document.getElementById('select_another_item_shadow');
		var top_ref = (document.getElementById('add_element').offsetTop+this.off_top);
		el.style.top = top_ref+'px';
		el_shadow.style.top = (top_ref-6)+'px';
		var left_ref = (document.getElementById('add_element').offsetLeft+5);
		el.style.left = left_ref+'px';
		el_shadow.style.left = (left_ref-6)+'px';
		el.style.display = '';
		if(this.IE){
			opac = 10;
			el.style.filter = 'alpha(opacity='+opac+');';
			el_shadow.style.filter = 'alpha(opacity='+(opac/3)+');';
			this.inter_show = setInterval('opac+=15;if(opac>100)window.clearInterval(bs.inter_show);document.getElementById(\'select_another_item_shadow\').style.filter = \'alpha(opacity=\'+(opac/3)+\');\';document.getElementById(\'select_another_item\').style.filter = \'alpha(opacity=\'+opac+\');\';',25);
		}
		else {
			opac = 0.1;
			el.style.opacity=opac;
			el_shadow.style.opacity=(opac/3);
			this.inter_show = setInterval('opac+=0.15;if(opac>1)window.clearInterval(bs.inter_show);document.getElementById(\'select_another_item_shadow\').style.opacity = (opac/3);document.getElementById(\'select_another_item\').style.opacity = opac ;',25);
		}
		var height_ref = document.getElementById('select_another_item_bas').offsetTop;
		if(!this.IE){
			document.getElementById('shadow_top_menu').src=this.pathStatic+'images/lc_fr/shadows/bg_top_shadow_267.png';
			document.getElementById('shadow_center_menu').src=this.pathStatic+'images/lc_fr/shadows/bg_middle_shadow_267.png';
			document.getElementById('shadow_bas_menu').src=this.pathStatic+'images/lc_fr/shadows/bg_bas_shadow_267.png';
		}
		document.getElementById('shadow_center_menu').style.height = (height_ref-5)+'px';
		el_shadow.style.display = '';
	}
	
	Basket.prototype.select_another_item = function(){
		var i;
		i=0;
		while(i<this.Details.length && this.Details[i].ready)i++;
		if(i<this.Details.length){
			alert('Veuillez attendre la fin du chargement.');
			return;
		}
		compare_label.reload_item=true;
		if(typeof(this.inter)!='undefined')window.clearInterval(this.inter);
		if(typeof(this.inter_show)!='undefined')window.clearInterval(this.inter_show);
		this.inter = setInterval('document.getElementById(\'select_another_item_shadow\').style.display=\'none\';document.getElementById(\'select_another_item\').style.display=\'none\';', 2000);
		var el=document.getElementById('select_another_item');
		var el_shadow=document.getElementById('select_another_item_shadow');
		var top_ref = (document.getElementById('select_'+actif).offsetTop+this.off_top);
		el.style.top = top_ref+'px';
		el_shadow.style.top = (top_ref-6)+'px';
		if(this.Details!=null){
			var left_ref = (parseInt(this.Details[actif].div.style.left.substring(0,this.Details[actif].div.style.left.length-2))+((this.Details[actif].width_-140)/2));
			el.style.left = left_ref+'px';
			el_shadow.style.left = (left_ref-6)+'px';
			if(this.IE){
				opac = 10;
				el.style.filter = 'alpha(opacity='+opac+');';
				el_shadow.style.filter = 'alpha(opacity='+(opac/3)+');';
				this.inter_show = setInterval('opac+=15;if(opac>100)window.clearInterval(bs.inter_show);document.getElementById(\'select_another_item_shadow\').style.filter = \'alpha(opacity=\'+(opac/3)+\');\';document.getElementById(\'select_another_item\').style.filter = \'alpha(opacity=\'+opac+\');\';',25);
			}
			else {
				opac = 0.1;
				el.style.opacity=opac;
				el_shadow.style.opacity=(opac/3);
				this.inter_show = setInterval('opac+=0.15;if(opac>1)window.clearInterval(bs.inter_show);document.getElementById(\'select_another_item_shadow\').style.opacity = (opac/3);document.getElementById(\'select_another_item\').style.opacity = opac ;',25);
			}
			el.style.display = '';
			var height_ref = document.getElementById('select_another_item_bas').offsetTop;
			if(!this.IE){
				document.getElementById('shadow_top_menu').src=this.pathStatic+'images/lc_fr/shadows/bg_top_shadow_267.png';
				document.getElementById('shadow_center_menu').src=this.pathStatic+'images/lc_fr/shadows/bg_middle_shadow_267.png';
				document.getElementById('shadow_bas_menu').src=this.pathStatic+'images/lc_fr/shadows/bg_bas_shadow_267.png';
			}
			document.getElementById('shadow_center_menu').style.height = (height_ref-5)+'px';
			el_shadow.style.display = '';
		}
	}
	
	Basket.prototype.ShowTip = function(){
		var i,j,count,ob;
		if((ob = document.getElementById('bulle_compar')) && !this.getCookie('compare')){
			count = 0;
			for(i=0;i<this.Tcat.length;i++){
				for(j=0;j<this.Tss_cat[this.Tcat[i]].length;j++){
					count += this.data_[this.Tcat[i]][this.Tss_cat[this.Tcat[i]][j]].length;
				}
			}
			if(count){
				if(typeof(tip_inter)=='undefined'){
					if(this.IE){
						opac_tip = 5;
						ob.style.filter = 'alpha(opacity='+opac_tip+');';
						setTimeout('document.getElementById(\'bulle_compar\').style.display=\'\';tip_inter=setInterval(\'document.getElementById(\\\'bulle_compar\\\').style.filter=\\\'alpha(opacity=\\\'+opac_tip+\\\');\\\';if(opac_tip>=95)clearInterval(tip_inter);else opac_tip+=5;\',25);',1000);
						setTimeout('tip_inter=setInterval(\'if(opac_tip<5){clearInterval(tip_inter);document.getElementById(\\\'bulle_compar\\\').style.display="none";}else{document.getElementById(\\\'bulle_compar\\\').style.filter=\\\'alpha(opacity=\\\'+opac_tip+\\\');\\\';opac_tip-=5;}\',25)',15000);
					}		
					else {
						opac_tip = 0.05;
						ob.style.opacity=opac_tip;
						setTimeout('document.getElementById(\'bulle_compar\').style.display=\'\';tip_inter=setInterval(\'document.getElementById(\\\'bulle_compar\\\').style.opacity=opac_tip;if(opac_tip>=0.95)clearInterval(tip_inter);else opac_tip+=0.05;\',25)',1000);
						setTimeout('tip_inter=setInterval(\'if(opac_tip<0.05){clearInterval(tip_inter);document.getElementById(\\\'bulle_compar\\\').style.display="none";}else{document.getElementById(\\\'bulle_compar\\\').style.opacity=opac_tip;opac_tip-=0.05;}\',25)',15000);
					}
				}
			}
		}
	}
	
	Basket.prototype.purge = function(T_id,cat,ss_cat){
		var i,j;
		var To_delete = new Array();
		for(i=0;i<this.data_[cat][ss_cat].length;i++){
			found = false;
			j=0;
			while(!found && j<T_id.length){
				found = (T_id[j]['ID'] == this.data_[cat][ss_cat][i]);
				if(!found)j++;
			}
			if(!found)To_delete[To_delete.length]=this.data_[cat][ss_cat][i];
		}
		if(To_delete.length>0){
			this.delete_from_Cat(To_delete);
			alert(To_delete.length+' élément'+(To_delete.length>1?'s':'')+' de votre sélection '+this.ss_cat_to_string(ss_cat)+' '+(To_delete.length>1?'ont été supprimés car il n\'existent plus.':'a été supprimé car il n\'existe plus.'));
			return true;
		}
		return false;
	}
	
	Basket.prototype.setCookie = function (name, value, expires, path, secure) {
		var domain;
		var myReg = new RegExp('\.lacentrale\.fr');
		domain = (myReg.test(window.location)?'.lacentrale.fr':'');
		document.cookie= name + '=' + escape(value) +
		((expires) ? '; expires=' + expires.toGMTString() : '') +
		((path) ? '; path=' + path : '; path=/') +
		((domain.length) ? '; domain=' + domain : '') +
		((secure) ? '; secure' : '');
	}

	Basket.prototype.FormatNumber = function (val,sep,count){
		var num = (parseInt(val)).toString();
		var str = '';
		var i=(num.length-1);
		while(num.length){
			if(num.length>=count){
				str = num.substr(num.length-count) + (str!=''?sep:'') + str;
				num = num.substr(0,num.length-count);
			}
			else {
				str = num +(str!=''?sep:'') + str;
				num = '';
			}
		}
		return str;
	}


