Options.prototype.constructor = Options;

function Options(){
	this.mat_opt = document.getElementById('opt');
	if (this.mat_opt==null)
		return;
	this.aff_opt = document.getElementById('OptionsTitle');
	this.is_obj_ok = true;
	this.TabOptions = new Array();
	this.TabOptions = this.mat_opt.value.split('');
	
	var i=0;
	var str_opt = '';
	while (document.getElementById('opt_'+i) != null)
	{
		this.TabOptions[i] = (this.TabOptions[i]=='1'?'1':'0');
		if (this.TabOptions[i]=='1')
		{
			document.getElementById('opt_'+i).checked = true;
			document.getElementById('opt_lin_'+i).className='Selected';
			str_opt = str_opt + (str_opt==''?'':', ') + document.getElementById('opt_lbl_'+i).innerHTML;
		}
		i++;
	}
	if (this.aff_opt)
	{
		if (str_opt.length>20)
			str_opt = str_opt.substr(0,20)+'...';
		if (str_opt=='')
			str_opt = '&Eacute;quip. / Options';
		this.aff_opt.innerHTML = str_opt;
	}
	this.mat_opt.value=this.TabOptions.join('');
	if (this.mat_opt.value.indexOf('1')==-1)
		this.mat_opt.value='';
	this.nb_opt = i;
	this.keepOpen=false;
}

Options.prototype.CheckOpt = function(id_check){
	if (!this.is_obj_ok)
		return;
	var idx = id_check.replace('opt_','');
	this.TabOptions[idx] = (document.getElementById(id_check).checked?'1':'0');
	this.mat_opt.value=this.TabOptions.join('');
	if (this.mat_opt.value.indexOf('1')==-1)
		this.mat_opt.value='';
	var str_opt = '';
	if (this.aff_opt)
	{
		for (var i=0;i<this.nb_opt;i++)
		{
			if (document.getElementById('opt_'+i).checked)
			{
				str_opt = str_opt + (str_opt==''?'':', ') + document.getElementById('opt_lbl_'+i).innerHTML;
				document.getElementById('opt_lin_'+i).className='Selected';
			}
			else
				document.getElementById('opt_lin_'+i).className='';
		}
		if (str_opt.length>20)
			str_opt = str_opt.substr(0,20)+'...';
		if (str_opt=='')
			str_opt = '&Eacute;quip. / Options';
		this.aff_opt.innerHTML = str_opt;
		this.keepOpen=false;
	}
	//changement de style potentiel ici
}

Options.prototype.CloseDiv = function(){
	if (!this.keepOpen)
		document.getElementById('OptionsInnerCont').style.display='none';
}

