// display decision alert box
function decision(message, url){
	if(confirm(message)) location.href = url;
}

// open browser window
function openPopUp(url, windowName, w, h, scrollbar) {

           var winl = (screen.width - w) / 2;
           var wint = (screen.height - h) / 2;
           winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scrollbar ;
		   win = window.open(url, windowName, winprops);
           if (parseInt(navigator.appVersion) >= 4) { 
              	win.window.focus(); 
           } 
}

function jumpMenu(target,object,restore){ 
  eval(target+".location='"+object.options[object.selectedIndex].value+"'");
  if (restore) object.selectedIndex=0;
}

function findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function getImage(imageName)
{
		findObj('img').src = imageName;
}

function submitDoc(formName) { 
  var obj;
 
	if (obj=findObj(formName)!=null) 
	{
		findObj(formName).submit(); 
	}
	else 
	{
		alert('The form you are attempting to submit called \'' + formName + '\' couldn\'t be found. Please make sure the submitDoc function has the correct id and name.');
	}

}

var scrollSpeed = 3;
var intScrollSpeed;

function initiateScroll()
{
	var marqueeContainer = document.getElementById('marqueeContainer');
	var marqueeText = document.getElementById('marqueeText');

	if(marqueeContainer)
	{
		var checkMarqueeTextObj = document.createElement("div");
		checkMarqueeTextObj.style.display="inline";
		checkMarqueeTextObj.style.whiteSpace="nowrap";
		checkMarqueeTextObj.style.visibility="hidden";
		checkMarqueeTextObj.className = "marqueeText";
		checkMarqueeTextObj.innerHTML = marqueeText.innerHTML;
		document.getElementsByTagName("body")[0].appendChild(checkMarqueeTextObj);
		var textWidth = checkMarqueeTextObj.offsetWidth;
		document.getElementsByTagName("body")[0].removeChild(checkMarqueeTextObj);

		intScrollSpeed=scrollSpeed;
		setInterval("scrollText(" + textWidth + ")",50);

		marqueeContainer.onmouseover=function()
		{
			intScrollSpeed=0;
		};
		marqueeContainer.onmouseout=function()
		{
			intScrollSpeed=scrollSpeed;
		};
	}
}

function scrollText(textWidthStr)
{
	var marqueeObj = document.getElementById('marqueeText');
	if(! marqueeObj.style.marginLeft)
		marqueeObj.style.marginLeft = document.getElementById('marqueeContainer').offsetWidth + "px";

	//marqueeObj.style.marginLeft = (parseInt(marqueeObj.style.marginLeft) > (-10 - marqueeObj.offsetWidth)) ? parseInt(marqueeObj.style.marginLeft) - intScrollSpeed + "px" : "585px";
	//marqueeObj.style.marginLeft = (parseInt(marqueeObj.style.marginLeft) > ((parseInt(textWidthStr) + 10) * -1)) ? parseInt(marqueeObj.style.marginLeft) - intScrollSpeed + "px" : parseInt(marqueeObj.offsetWidth) + "px";
	marqueeObj.style.marginLeft = parseInt(marqueeObj.style.marginLeft) > (-1 * parseInt(textWidthStr) - 10) ? parseInt(marqueeObj.style.marginLeft) - intScrollSpeed + "px" : parseInt(document.getElementById('marqueeContainer').offsetWidth) + "px";
}

function initiateProdSwap()
{
	for(var i=0; i < arguments.length; i=i+3)
	{
		var ProdImgObj = document.getElementById(arguments[i]);
		if(ProdImgObj)
			prodSwap(ProdImgObj,arguments[i+1],arguments[i+2]);

	}
}

function prodSwap(ProdImgObj,ProdImgArr,ProdLinkArr)
{
	var ImgIndex = Math.floor(ProdImgArr.length*Math.random());
	ProdImgObj.src = ProdImgArr[ImgIndex].src;
	if(ProdLinkArr[ImgIndex] != '')
		ProdImgObj.parentNode.href=ProdLinkArr[ImgIndex];
}