var currentItem = 0;

function timedPicChange(){
	 //alert('timedPicChange');
	showRandomItem('+');
	var timedPic = setTimeout("timedPicChange()",8000);
}

function resetTime(){
	clearTimeout(timedPic);
}

function fadeIn() {
	anim2.animate();
}

function fadeOut() {
	anim.animate();
}

function setImage() {
    var children = document.getElementById("rotating1").childNodes;
    for (i=0;i<cnt;i=i+1){
        if(i != currentItem)
		    children[i].style.display="none";
		else {
		    children[i].style.display="";
		}
    }
    fadeIn();
}

function showRandomItem( num ){
    //alert(currentItem);
 	if ( num == '+' ) {
	 	currentItem++;
 	} else if ( num == '-' ){
   		currentItem--;
	}

	if ( currentItem < 0 ){
		currentItem = ( cnt - 1 );
	} else if ( currentItem > ( cnt - 1 ) ) {
		currentItem = 0;
	}

	if ( ( num != '+' ) && ( num != '-' ) ) {
		currentItem = num;
		setImage();
	} else {
		anim.onComplete.subscribe(setImage);
	 	fadeOut();
	}
}	

function clickItem() {
	document.location = itemUrl;
}





