function createArrows()
{
	createArrow("arrow_1");
	createArrow("arrow_2");
	createArrow("arrow_3");
}


function createArrow(arrowID) 
{
// check if there is no image
	if(!document.getElementById(arrowID))
	{
	//create arrow and insert
		var newimg = document.createElement('img');
		newimg.src="/images/promos/p_arrow.gif";
		newimg.id=arrowID;
		o=document.getElementById("rel-images");
		o.appendChild(newimg);
	}
}

function __findimg()
{
	var imgs,i;
// Loop through all images, and check if their classes contain the class roll
	imgs=document.getElementsByTagName('img');
	for(i=0;i<imgs.length;i++)
	{
		if(/roll/.test(imgs[i].className))
		{
// add the function roll to the parent Element of the image
			imgs[i].parentNode.onmouseover=function(){roll(this);};
			imgs[i].parentNode.onmouseout=function(){roll(this);};
			imgs[i].parentNode.onfocus=function(){roll(this);};
			imgs[i].parentNode.onblur=function(){roll(this);};
		}
	}
}

function roll(o, IconId, QuoteImageSrc, IconSrc, CloseUpIconSrc, ArrowID, LargeGraphicSrc)
{
	// Change the Quote Image to the current one
	document.getElementById("promos").style.backgroundImage = 'url(' + QuoteImageSrc + ')' ;
	
	// Show all Arrow Images
	document.getElementById("arrow_1").style.visibility = 'visible' ;
	document.getElementById("arrow_2").style.visibility = 'visible' ;
	document.getElementById("arrow_3").style.visibility = 'visible' ;
	// Hide this Arrow Image
	document.getElementById(ArrowID).style.visibility = 'hidden' ;
	
	// TODO: Return the previous Close-Up to its normal state
	//
	
	// Change the current mouseover Icon to the Close-Up Icon
	document.getElementById(IconId).src = CloseUpIconSrc ;
	
	// Change the Large Graphic to the current
	document.getElementById("promoimage").style.backgroundImage = 'url(' + LargeGraphicSrc + ')' ;

}

function __roll(o, topBackgroundFile, QuoteFile, botBackgroundFile, botQuoteFile)
{
	var i,isnode,src,ftype,newsrc,nownode;
// loop through all childNodes
	for (i=0;i<o.childNodes.length;i++)
	{
		nownode=o.childNodes[i];
// if the node is an element and an IMG set the variable and exit the loop
		if(nownode.nodeType==1 && /img/i.test(nownode.nodeName))
		{
			isnode=i;
			break;
		}
	}
// check src and do the rollover
	src = o.childNodes[isnode].src;
	ftype = src.substring(src.lastIndexOf('.'), src.length);
	tempFile = src.substring(src.lastIndexOf('/') + 1, src.length);
	file = tempFile.substring(0, tempFile.lastIndexOf('.'));
	
	if(document.getElementById("promoimage").style.backgroundImage == 'url(' + topBackgroundFile + ')')
	{
		//newsrc = src.replace('_on','');
		document.getElementById("promoimage").style.backgroundImage = 'url(' + botBackgroundFile + ')' ;
		document.getElementById("promos").style.backgroundImage = QuoteFile ;
		//file = file.replace('_on','');
		//document.getElementById("arrow_"+file).style.visibility = 'visible';
	}else{
		//newsrc = src.replace(ftype, '_on'+ftype);
		document.getElementById("promoimage").style.backgroundImage = 'url(' + topBackgroundFile + ')' ;
		document.getElementById("promos").style.backgroundImage = 'url(' + QuoteFile + ')' ;
		//document.getElementById("arrow_"+file).style.visibility = 'hidden';
	}
	o.childNodes[isnode].src=newsrc;
}
