// Buy Link Randomizer 
function randombuylink() {
	buylinks = new Array('http://www.sonypictures.com/homevideo/faithlikepotatoes/buy/fcsamazon.html','http://www.sonypictures.com/homevideo/faithlikepotatoes/buy/cbdamazon.html','http://www.sonypictures.com/homevideo/faithlikepotatoes/buy/amazon.html','http://www.sonypictures.com/homevideo/faithlikepotatoes/buy/fcscbd.html');
	randlink = Math.floor(Math.random() * buylinks.length);
	document.getElementById('buypage').setAttribute('href', buylinks[randlink]);
}

// Buy Link for IE6
function buylink() {
	var buylink = document.getElementById('buypage');
	resources.onmouseover = function () {
		this.className += " current";
	}			
	resources.onmouseout = function () {
		this.className = this.className.replace(" current","");
	}
}

// Register Page Pop up
function regPop() {
	register = document.getElementById('navregister');
	register.onclick = function() {
		displayWindow(this.href,'registration',450,520,'scrollbars=0');
		return false;
	}
}

// Video Player
function videoplayer() {
	var links = document.getElementsByTagName('a');
	for (i=0;i<links.length;i++) {
		link = links[i];
		if (link.getAttribute('rel') == "clip") {
			link.onclick = function() {
				document.getElementById('videoplayer').playVideo(this.href,this.getAttribute('title'));
				return false;
			}
		}
	}
}

//ie 6 background image flicker fix
function ieFlicker() {
    try {
		document.execCommand('BackgroundImageCache', false, true);
    } catch(e) {}
}


// Initializing functions on page load
addLoadEvent(randombuylink);
addLoadEvent(regPop);
addLoadEvent(videoplayer);
addLoadEvent(ieFlicker);
