var IE4		= (document.all && !document.getElementById) ? true : false;
var IE5 	= (document.all && document.getElementById) ? true : false;
var MOZILLA	= (!document.all && document.getElementById) ? true : false;

var imagepath = "http://www.newinchess.com/shop/images/products/";
var productpath = "http://www.newinchess.com/Shop/ProductDetails.aspx?ID=cv&ProductID=";
var currentID = Math.floor(Math.random() * this.productids.length);
var delay = 4000 //( 4 seconds (denk ik))
//////////////////////////////////////////////////////////////////////////////
function GetElementByID(elementID)
{
	if (IE4) return document.all[elementID];
	if (IE5 || MOZILLA)	return document.getElementById(elementID);
}
// Init the rotator
function InitRotator()
{
	this.setReferenceAndImage();
	//if(!MOZILLA)
	//{
	  // set the delay if not MOZILLA
		setTimeout("this.movecube()",this.delay);
	//}
}
// Only for IE not others
function movecube()
{
   	var rotator = this.GetElementByID("cube");
 	  if (window.createPopup)		rotator.filters[0].apply();
 	  this.setReferenceAndImage();
 	  if (window.createPopup) rotator.filters[0].play();

 	  setTimeout("this.movecube()",this.delay);
}
// set ref and imag
function setReferenceAndImage()
{
    if(this.currentID >= this.productids.length) this.currentID = 0;
    if(this.productids[this.currentID] < 0)
    {	
	this.GetElementByID("Rotator").href = "http://www.newinchess.com/Magazine/MagazineDetails.aspx?&PageID=101&utm_campaign=Magazine&utm_medium=carrouselCV&utm_source=ChessVibes.com";	
    }
    else
    {		
    	this.GetElementByID("Rotator").href = productpath + this.productids[this.currentID] + "&utm_campaign=CVcarrousel&utm_source=ChessVibes.com&utm_medium=carrouselCV";
    }	
    this.GetElementByID("cube").src = imagepath + Math.abs(this.productids[this.currentID]) + ".jpg";
    if(this.GetElementByID("cube").height > 145)
    {
	//this.GetElementByID("cube").width = 90;
    }
    else
    {
	//this.GetElementByID("cube").width = 100;
    }	
    this.GetElementByID("cube").height = 145;
    this.currentID++;
}

