var RotatorCounter = 0;
var rotateId = Array();
var ImagesRotator = Array();
var Ids = Array();
var CurrNumber = Array();
var Is_run = Array();
var CurrentId = 0;

function deactivate(Counter, EidS){

	for (var i =0 ; i<Ids[Counter].length; i++) {
		if (Ids[Counter][i] != EidS )			
			document.getElementById('li' + Ids[Counter][i]).className = "";
		else
			document.getElementById('li' + Ids[Counter][i]).className = "active";
			
	}

//	document.getElementById('li' + Ids[Counter][0]).className = "active";

}

function fillIt(Counter, EidD, EidS) {
	deactivate(Counter, EidS);
	
	var Tmp = document.getElementById(EidS).innerHTML;
	document.getElementById("mainImage"+ EidS).id = document.getElementById("mainImage" + EidS).id + "tmp";
	document.getElementById(EidD).innerHTML = Tmp;
	document.getElementById("mainImage" + EidS).id = document.getElementById("mainImage"+ EidS).id + "Current";
	document.getElementById("mainImage"+ EidS+ "tmp").id = "mainImage" + EidS;
} 
function runRotate(Counter, EId){
	if (!Is_run[Counter]) {
		rotateId[Counter] = setInterval('rotate(' + Counter + ', ' + EId + ')', 500);
		Is_run[Counter] = true;
	}
			
}
function notRotate(Counter, EId){
	clearInterval (rotateId[Counter]);	
	Is_run[Counter] = false;	
}
function rotate(Counter, EId){
	if (CurrNumber[Counter] == ImagesRotator[Counter][EId].length) {
		CurrNumber[Counter] = 0;
	}
	var Fn = 'document.getElementById("mainImage' + EId + 'Current").innerHTML = ' + '\''+ImagesRotator[Counter][EId][CurrNumber[Counter]]+'\'';

	setTimeout (Fn,1);
	CurrNumber[Counter]++;
	
}
function refreshId(ID) {
	var ln = ID.length;
	CurrentId = ID.substring(ln - 1, ln);
}
