
det_vu.prototype.constructor = det_vu;

function det_vu(curcat,id_){
	this.nbmax=9;
	this.id_ = id_;
	this.id_curcat = (curcat=='auto'?1:(curcat=='moto'||curcat=='quad'||curcat=='scooter'?2:(curcat=='loisir'?3:(curcat=='utils'?4:5))));
	this.data_ = this.getCookie('det_vu');
	this.data_ = (this.data_==''?'|||||':this.data_);
	this.largeExpDate = new Date ();
	this.largeExpDate.setTime(this.largeExpDate.getTime() + (21 * 24 * 3600 * 1000));
	this.str=this.set();
	this.setCookie('det_vu',this.str,this.largeExpDate);
} 

det_vu.prototype.set = function(){
	var i;
	var str = this.id_curcat;
	var T = this.data_.split('|');
	var cpt=0;
	T[this.id_curcat] = T[this.id_curcat].replace(new RegExp(','+this.id_+','),',').replace(new RegExp('^'+this.id_+'(,|$)'),'').replace(new RegExp(','+this.id_+'$'),'');
	T[this.id_curcat] += (T[this.id_curcat]!=''?',':'')+this.id_;
	for(i=0;i<T[this.id_curcat].length;i++) if(T[this.id_curcat].substring(i,i+1)==',') cpt++;
	if(cpt>=this.nbmax)T[this.id_curcat] = T[this.id_curcat].replace(/^[^,]+,/,'');	
	for(var i=1;i<T.length;i++)str += '|' + T[i];
	return str;
}



det_vu.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)));	
}

det_vu.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' : ''); 
 }



