function starRanking(divId,targetId,imgStarYesPath,imgStarNoPath,imgStarWidth,imgStarHeight,lockRank,setRank,callBack,callArgt,nbMetMax,nbMetElId,metId)
{
	
	this.el 																	= document.getElementById(divId);
	this.targetId															= targetId;
	
	this.imgStarYesPath												= imgStarYesPath;
	this.imgStarNoPath												= imgStarNoPath;
	this.imgStarYesPath												= imgStarYesPath;
	this.imgStarWidth													= imgStarWidth;
	this.imgStarHeight												= imgStarHeight;
	this.setRank															= setRank;
	this.lockRank															= lockRank;
	this.callBack															= callBack;
	this.callArgt															= callArgt;

	this.nbMetMax															= nbMetMax;	
	this.metId																= metId;
	this.nbMetElId														= nbMetElId;
	this.nbMetEl															= document.getElementById(nbMetElId);

	
	baseBlock = window.document.createElement('DIV');
	baseBlock.style.position 						= 'absolute';
	baseBlock.style.overflow 						= 'visible';
	/*baseBlock.style.backgroundColor 			= 'transparent';*/
	baseBlock.style.border								= '0px dashed blue';
	baseBlock.style.top									= '0px';
	baseBlock.style.left									= '0px';
	baseBlock.style.width								= this.imgStarWidth + 'px';
	baseBlock.style.height								= this.imgStarHeight + 'px';
	baseBlock.rankValue									= 0;
	baseBlock.yesImage										= this.imgStarYesPath;
	baseBlock.noImage										= this.imgStarNoPath;
	baseBlock.targetId										= this.targetId;
	baseBlock.instanceSR								= this;
	baseBlock.callBack									= callBack;
	baseBlock.callArgt									= callArgt;
	baseBlock.style.backgroundImage 	= 'url(../img/starZero.gif)';
	baseBlock.style.backgroundRepeat		= 'no-repeat';
	
	
	if(this.lockRank != 1)
	{
		baseBlock.onclick									= this.changeRank;
		baseBlock.style.cursor							= 'pointer';
	}

	this.el.appendChild(baseBlock);
	
	for(x=0;x<5;x++)
	{
		starBlock 													= window.document.createElement('DIV');
		starBlock.id												= 'star' + x + 'Id';
		starBlock.style.position 						= 'absolute';
		starBlock.style.overflow 						= 'visible';

		if(this.setRank > x)
			starBlock.style.backgroundImage 	= 'url(' + this.imgStarYesPath + ')';
		else
			starBlock.style.backgroundImage 	= 'url(' + this.imgStarNoPath + ')';
			
		starBlock.style.border							= '0px dashed blue';
		starBlock.style.top									= '1px';
		starBlock.style.left								= this.imgStarWidth + (x*14) + 'px';
		starBlock.style.width								= imgStarWidth + 'px';
		starBlock.style.height							= imgStarHeight + 'px';
		starBlock.style.backgroundRepeat		= 'no-repeat';
		starBlock.rankValue									= x+1;
		starBlock.yesImage									= this.imgStarYesPath;
		starBlock.noImage										= this.imgStarNoPath;
		starBlock.targetId									= this.targetId;
		
		starBlock.instanceSR								= this;
		
		starBlock.callBack									= callBack;
		starBlock.callArgt									= callArgt;
		
		
		if(this.lockRank != 1)
		{
			starBlock.onclick								= this.changeRank;
			starBlock.style.cursor						= 'pointer';
		}
	
		this.el.appendChild(starBlock);
	}
	if(document.getElementById(this.targetId))
		document.getElementById(this.targetId).value = this.setRank;
}
	
starRanking.prototype.changeRank = function ()
{
	bloque = 1;
	
	if(this.instanceSR.nbMetEl)
	{
		if(!this.instanceSR.nbMetEl.metTab)
			this.instanceSR.nbMetEl.metTab = new Array() ;
			
		if(!this.instanceSR.nbMetEl.metTab[this.instanceSR.metId])
			this.instanceSR.nbMetEl.metTab[this.instanceSR.metId] = 0;
			
		if(	!this.instanceSR.nbMetMax
				|| this.rankValue == 0
				|| this.instanceSR.nbMetEl.metTab[this.instanceSR.metId] > 0
				|| (this.instanceSR.nbMetMax > 0 && nbMet(this.instanceSR.nbMetEl.metTab) < this.instanceSR.nbMetMax) 
			)
		{
			
			bloque = 0
			
			//Incrémentation NBMet
			if(document.getElementById(this.targetId).value == 0 && this.rankValue > 0)
			{
				this.instanceSR.nbMetEl.metTab[this.instanceSR.metId]++;
				//alert("++ " + this.instanceSR.nbMetEl.metTab[this.instanceSR.metId]);
			}
			else if(document.getElementById(this.targetId).value > 0 && this.rankValue == 0)
			{
				this.instanceSR.nbMetEl.metTab[this.instanceSR.metId]--;
				//alert("-- " + this.instanceSR.nbMetEl.metTab[this.instanceSR.metId]);
			}
			
		}
		
		//alert("nbMet : " + nbMet(this.instanceSR.nbMetEl.metTab)
		//	+ " | metid : " + this.instanceSR.metId 
		//	+ " | nbMetMax : " + this.instanceSR.nbMetMax 
		//	+ " | targetvalue : " + document.getElementById(this.targetId).value
		//	+ " | rankValue : " + this.rankValue
		//	+ " | nbMetElId : " + this.instanceSR.nbMetElId
		//	);
		
	}
	else
		bloque = 0;
	
	
	
	
	if(bloque != 1 )
	{
		for(x=1;x<6;x++)
		{
			if(this.rankValue < x)
				this.parentNode.childNodes[x].style.backgroundImage = 'url(' + this.noImage +')'
			else
				this.parentNode.childNodes[x].style.backgroundImage = 'url(' + this.yesImage +')'
		}
		
		document.getElementById(this.targetId).value = this.rankValue;
		
		if(document.getElementById('justif_' + this.targetId))
		{
			
			if(this.rankValue == 4 || this.rankValue == 5)
			{
				document.getElementById('justif_' + this.targetId).style.display = 'block';
				
				document.getElementById('justifArea_' + this.targetId).setAttribute('required','1',0);
				document.getElementById('justifArea_' + this.targetId).setAttribute('validFill','0',0);
				document.getElementById('justifArea_' + this.targetId).required = 1;
				document.getElementById('justifArea_' + this.targetId).validFill = 0;
			}
			else
			{
				document.getElementById('justif_' + this.targetId).style.display = 'none';
				document.getElementById('justifArea_' + this.targetId).setAttribute('required','',0);
				document.getElementById('justifArea_' + this.targetId).setAttribute('validFill','1',0);
				document.getElementById('justifArea_' + this.targetId).required = '';
				document.getElementById('justifArea_' + this.targetId).validFill = 1;
			}
			
		}
		
		if(this.callBack && this.callArgt)
		 	this.callBack(this.callArgt);
		else if(this.callBack)
			this.callBack();
			
	}
	else
		alert(this.instanceSR.nbMetEl.title);
	
}

function blibli(a)
{

}

function doNothing(a)
{
	//alert('do nothing');
}

function submitSearchForm()
{
	SRHformulaire.checkForSubmit()
}

function equalizeChild(childs)
{
	if(childs)
	{
		childs = childs.toString();
		var reg = new RegExp("[,]+", "g");
		var childrenArray = childs.split(reg);
		
		for(x=0;x<childrenArray.length;x++)
		{
			eval("var xxx = star_" + childrenArray[x]);
			
			for(y=1;y<6;y++)
			{
				if(this.rankValue < y)
					xxx.el.childNodes[y].style.backgroundImage = 'url(' + this.noImage +')';
				else
					xxx.el.childNodes[y].style.backgroundImage = 'url(' + xxx.el.childNodes[y].yesImage +')'
			}
			document.getElementById(xxx.el.childNodes[this.rankValue].targetId).value = this.rankValue;
		}
	}
	SRHformulaire.checkForSubmit();
}

function freezeParent(a)
{
	eval("var xxx = star_" + a);

	for(y=1;y<6;y++)
		xxx.el.childNodes[y].style.backgroundImage = 'url(../img/starDisabled.gif)';
	
	document.getElementById(xxx.el.childNodes[1].targetId).value = '0';
	
	SRHformulaire.checkForSubmit();
}

function nbMet(tab)
{
	
	nb = 0;
	for (var metid in tab)
	{
		if(tab[metid] > 0)
			nb++;
	}
	
	return nb;

}
