var pics=new Array();
var stat=new Array();
var pic=new Array();

var categoryThumbElement = null;
var categoryThumbUrls = new Array();
var currentCategoryThumb = 0;
var categoryIntervalHandle = null;

function startCategoryRotation(thumbElement, newUrls) {
	categoryThumbElement = thumbElement;
	categoryThumbUrls = newUrls;
	currentCategoryThumb = 0;

	rotateCategoryThumbs();
	categoryIntervalHandle = setInterval('rotateCategoryThumbs()', 750);
}

function rotateCategoryThumbs() {
	if (categoryThumbElement) {
		if (currentCategoryThumb >= categoryThumbUrls.length)
			currentCategoryThumb = 0;

		categoryThumbElement.src = categoryThumbUrls[currentCategoryThumb];
		currentCategoryThumb++;
	}
}

function stopCategoryRotation() {
	if (categoryIntervalHandle) {
		clearInterval(categoryIntervalHandle);
	}
}

function changepic(i,code)
{ var loop=0;

	if (stat[code])
	{
		while ((pics[code][i]==0 || i>=5) && loop<100)
		{ if (i>=5) { i=0; }
			else
			{ i++;
			}		
			loop++;
		}
		
		if (pic[code][i].complete)
		{	document.getElementById(code).src=pic[code][i].src;
			setTimeout("changepic("+(i+1)+",'"+code+"')",750);
		}
		else
		{	setTimeout("changepic("+i+",'"+code+"')",20);
		}
	}
	
	
}

function loadpic(url,code,j)
{	if (stat[code]) { pic[code][j].src=url; }
}

function startm(code,ta,te)
{	stat[code]=1;
	var jj, jjj;
	var first=1;
	
	for(var j=0;j<6;j++)
	{ if (pics[code][j]==1)
		{ pic[code][j]=new Image();
			jj=j+1;
			jjj=jj;
			if (first) { first=0; loadpic(ta+jjj+te,code,j); }
			else { setTimeout("loadpic('"+ta+jjj+te+"','"+code+"',"+j+")",j*50); }
		}
	}
	changepic(0,code);
}

function endm(code)
{	stat[code]=0;
}


function validateStep() {
	var showContinue = true;
	if(document.forms.stepform.title.value == '') {
		var showContinue = false;
	}
	if(document.forms.stepform.description.value == '') {
		var showContinue = false;
	}	
	if(document.forms.stepform.keywords.value == '') {
		var showContinue = false;
	}	
	if(showContinue) {
		document.getElementById('submitb').disabled=false;
	}
	else {
		document.getElementById('submitb').disabled=true;
	}
}
