﻿<!--//--><![CDATA[//><!--

var selectedBucketType = '';

//RBSearch on header
function toggleHeaderSearch(id,button){
	var divArray = new Array("radiovariety","radioindustrynews","radioweb");

	var div = "radio" + id;
	var i;

	for(i=0;i<3;i++){

		if (divArray[i] != div){
			if (document.getElementById(divArray[i]).className == 'selected'){
				document.getElementById(divArray[i]).className = "unselected";
			}
		}
		else
		{
			if (document.getElementById(divArray[i]).className == 'unselected'){
				document.getElementById(divArray[i]).className = "selected";
			}
		}//end div

	}//end for
	document.SearchForm.searchtype[button].checked=true;
}
function doSearchStuff(){
	var i = 0;
	checkSearch();
	for(i=0;i<3;i++){
		if(document.SearchForm.searchtype[i].checked == true){
			window.location.href  = '/search/' + document.SearchForm.searchtype[i].value +'?q=' + escape(document.SearchForm.q.value) + '&s=' + escape(document.SearchForm.s.value);
		}
	}

	return false;
}


//departments tab thing
	function initRollTabs(rtImgClass, classname, rtArr, rtindex, rtNum, rtSelected) {
		var inc=0
		var alltags=document.all? document.all : document.getElementsByTagName("*")
		for (q=0; q<alltags.length; q++){
			if (alltags[q].className==classname){
				rtArr[inc++]=alltags[q]
			}
		}
		
		if (!document.getElementById) return

		var rtPreLoad = new Array();
		var rtTempSrc;
		var rtTabs = document.getElementsByTagName('li');

		for (var i = 0; i < rtTabs.length; i++) {
			for (var w = 1; w <= rtNum; w++) {
				tempnm = rtImgClass + w;
				if (rtTabs[i].id == tempnm) {
					rtindex.value = w;
					var src = rtTabs[i].className;
					var hsrc = 'lion';

					rtTabs[i].setAttribute('hsrc', hsrc);
					rtTabs[i].setAttribute('tbid', w);
					rtTabs[i].setAttribute('ibid', i);
					if (w == rtSelected) {
						rtTabs[i].className='lion';
						rtindex = i;
					}

					rtTabs[i].onmouseover = function() {
						rtTempSrc = this.getAttribute('className');
						this.className=this.getAttribute('hsrc');
						ShowContent(this.getAttribute('tbid'), rtNum, rtArr);
						if (rtindex != this.getAttribute('ibid')) {
							rtTabs[rtindex].className='lioff';
							rtindex = this.getAttribute('ibid');
						}
					}
					
				}
			}

		}
		ShowContent(rtSelected, rtNum, rtArr);
	}
	

	function ShowContent(divOn, numDivs, arrName){
		//get chosen message index (to show it):
		selindex = divOn - 1;
		for (p=0;p<numDivs;p++)
		{
			if (p == selindex) {
				arrName[p].style.display="block" //show current message
			} else {
				arrName[p].style.display="none" //hide previous message
			}
		}
	}

function getCookie1(Name) {
  var search = Name + "=";
	if (document.cookie.length > 0) { //if there are any cookies
    offset = document.cookie.indexOf(search);
    if (offset != -1) { // if cookie exists
      offset += search.length;    //set index of beginning of value
      end = document.cookie.indexOf(";", offset);  // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      return unescape(document.cookie.substring(offset,end))
    }
  }
}

function checkSearch()
{
	var searchField = document.getElementById('SearchText');

	switch (searchField.value)
	{
		case "":
		case "Enter Keywords":
			window.alert("Please enter a search term.");
			searchField.focus();
			return false;
	}
}

function bucketTypeTabOnClick(bucketType)
{
	var searchField = document.getElementById('SearchText');

	switch (searchField.value)
	{
		case "":
		case "Enter Keywords":
			window.alert("Please enter a search term.");
			searchField.focus();
			return false;
	}

	var form = document.getElementById('SearchForm');

	window.location.href = '/search/' + bucketType + '?q=' + escape(searchField.value);
}

function searchFieldSetFocus()
{
	var searchField = document.getElementById('SearchText');
	if (searchField != null)
	{
		searchField.focus();
	}
}

function ss(w, id)
{
	window.status = w;
	return true;
}

function cs()
{
	window.status = "";
}

function jump(url,linktype)
{
	if (document.images && url)
	{
		new Image().src = '/contents/images/_jump.gif?url=' + escape(url).replace(/\+/g, '%2B') + '&type=' + linktype;
	}
	
	return true;
}

function toggleLayer(sourceElement, elementId)
{
	var element;

	if (document.getElementById)
	{
		// this is the way the standards work
		element = document.getElementById(elementId);
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		element = document.all[elementId];
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		element = document.layers[elementId];
	}

	element.style.display = element.style.display ? '' : 'inline';
	
	sourceElement.innerHTML = element.style.display ? '&lt; <strong style="text-decoration:none;">less</strong>' : '<strong style="text-decoration:none;">more</strong> &gt;';
}


function stripQts2(name) {
	var newName = "";
	var test = name.split(unescape("%27%27")); //split the field on ascii code for double ''
	for (i=0;i<test.length;i++) {
	if (i != (test.length - 1) ) newName = newName + test[i] + "'";  // put it back together with an "'"
	else newName = newName + test[i]; // make sure end of string has no "'"
	}
	userQuery = newName;
}

//Review_Feedback
function ValidEmailFeedback(email) {
	invalidChars = " /:,;"
	if (email == "") {
		return false
	}
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) != -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) != -1) {
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return false
	}
	if (periodPos+3 > email.length) {
		return false
	}
		return true
}

function ValidateInputFeedback(form){
	if (form.email.value == "" ) {
		alert("Please enter your Email Address.");
		form.email.focus();
		return false;
	}

	if (form.email.value != "" ) {
		if (!ValidEmailFeedback(form.email.value)) {
			AlertMsg = "Please enter your full email address, including the @ sign and the domain.\r\n\r\nFor example:\r\n\r\nfsmith@xyz.com\r\nsally@aol.com\r\n";
			alert(AlertMsg);
			form.email.focus();
			form.email.select();
			return false;
		}
	}
return true;
}

function FeaturedStory(linkUrl, imageUrl, altAttribute, headline, nutgraph)
{
	this.LinkUrl = linkUrl;
	this.ImageUrl = imageUrl;
	this.AltAttribute = altAttribute;
	this.Headline = headline;
	this.Nutgraph = nutgraph;

	this.PreloadedImage = new Image();
	this.PreloadedImage.src = imageUrl;
}

function Switch(featuredStoryIndex)
{
	FeaturedClick = 1;
	RotateStop();
	FeaturedStoryCurrentIndex = featuredStoryIndex;
	UpdateFeaturedStoryDisplay(featuredStoryIndex);
}

function SwitchPrevious()
{
	FeaturedClick = 1;
	RotateStop();
	RotatePrevious();
}

function SwitchNext()
{
	FeaturedClick = 1;
	RotateStop();
	RotateNext();
}

function RotatePlay()
{
	if (FeaturedClick == 0) {
		FeaturedStoryTimerId = window.setInterval('RotateNext()', FEATURED_STORY_ROTATE_INTERVAL);
	}
}

function RotateStop()
{
	if (FeaturedStoryTimerId != null)
	{
		window.clearInterval(FeaturedStoryTimerId);

		FeaturedStoryTimerId = null;
	}
}

function RotatePrevious()
{
	FeaturedStoryCurrentIndex--;

	if (FeaturedStoryCurrentIndex < 0)
	{
		FeaturedStoryCurrentIndex = FEATURED_STORY_COUNT - 1;
	}

	UpdateFeaturedStoryDisplay(FeaturedStoryCurrentIndex);
}

function RotateNext()
{
	FeaturedStoryCurrentIndex++;

	if (FeaturedStoryCurrentIndex == FEATURED_STORY_COUNT)
	{
		FeaturedStoryCurrentIndex = 0;
	}

	UpdateFeaturedStoryDisplay(FeaturedStoryCurrentIndex);
}

function UpdateFeaturedStoryDisplay(featuredStoryIndex)
{
	var headlineAnchor1 = document.getElementById('featuredstorylinkurl1');
	var headlineAnchor2 = document.getElementById('featuredstorylinkurl2');
	var slideshow = document.getElementById('featuredstoriesslideshownav');
	var featuredImage = document.getElementById('featuredstoryimageurl');
	var nutgraph = document.getElementById('featuredstorynutgraph');
	var slideshowAnchors = slideshow.getElementsByTagName('a');
	var highlightIndex = 0;
	var featuredStory = FeaturedStories[featuredStoryIndex];

	headlineAnchor1.href = featuredStory.LinkUrl;
	headlineAnchor2.href = featuredStory.LinkUrl;
	headlineAnchor2.innerHTML = featuredStory.Headline;
	featuredImage.src = featuredStory.ImageUrl;
	featuredImage.alt = featuredStory.AltAttribute;
	nutgraph.innerHTML = featuredStory.Nutgraph;

	for (var anchorIndex = 0; anchorIndex < slideshowAnchors.length; anchorIndex++)
	{
		switch (slideshowAnchors[anchorIndex].className)
		{
			case 'sequenceoff':
			case 'sequenceon':
				if (highlightIndex == featuredStoryIndex)
				{
					slideshowAnchors[anchorIndex].className = 'sequenceon';
				}
				else
				{
					slideshowAnchors[anchorIndex].className = 'sequenceoff';
				}

				highlightIndex++;

				break;
		}
	}
}

//Article, Review Upsell
	if (document.images)
	{
		LOGINON=new Image(69,21)
		LOGINON.src="/graphics/upsell/upsell_login_buttonRO.gif";

		LOGINOFF=new Image(69,21)
		LOGINOFF.src="/graphics/upsell/upsell_login_button.gif";
	}

	function on(pic)
	{
		if (document.images)
		{
			document.images[pic].src=eval(pic + "ON.src");
		}
	}

	function off(pic)
	{
		if (document.images)
		{
			document.images[pic].src=eval(pic + "OFF.src");
		}
	}

	function submitForm()
	{
		document.frmLogin.submit();
	}


	function popVert(URL) {
		day = new Date();
		id = day.getTime();
		window.open(URL, null, "top=150,left=300,height=550,width=550,status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes,scrollbars=yes,titlebar=yes");
	}

function talkBackPopUp(articlePrefix, articleId){
	var url
	url = "/index.asp?layout=talkBackPostPopup&article_prefix=" + articlePrefix + "&article_id=" + articleId
	window.open(url, null, "top=150,left=300,height=590,width=520,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=no,titlebar=no");
}

//Featured Stories Slideshow on homepage
var FEATURED_STORY_ROTATE_INTERVAL = 10.0 * 1000; // milliseconds
var FEATURED_STORY_COUNT = 4;
var FeaturedStoryCurrentIndex = 0;
var FeaturedStoryTimerId = null;
var FeaturedClick = 0;
var FeaturedStories = new Array(FEATURED_STORY_COUNT);
var storyCount = 0;

//Film Search?
function ValidateInputSearch(search){
if (search.filmQuery.value == "" ) {
		alert("Please enter the name of the film you are searching for.");
		search.filmQuery.focus();
		return false;
	}
return true;
}

function bo_submit() {
var sel;
		sel = document.bo.boxyear;
		var yr = sel.options[sel.options.selectedIndex].value;
		sel = document.bo.boxmonth;
		var mo = sel.options[sel.options.selectedIndex].value;
		sel = document.bo.boxday;
		var da = sel.options[sel.options.selectedIndex].value;
		var dateStr = mo+'/'+da+'/'+yr;

if (document.bo.country.value == 'v1'){
	document.bo.layout.value = 'b_o_weekend';
}
else
{
document.bo.sort.value = 'BOTHISWEEK';
	document.bo.layout.value = 'b_o_foreign';
}

document.bo.date.value = dateStr;
document.bo.submit();
}

// On subscribe.asp, hovering over the topnav will make the select lists disappear.
function hideShowRegistrationSelect(tag)
{
	var element = document.getElementsByTagName(tag);
	var i;

//		if(element)
//		{
//			if (element[0].style.display == 'none' ) 
//			{
//				element[0].style.display = '';
//			} else 
//			{
//				element[0].style.display = 'none';	
//			}
//		}
}

function trim(value) {
	var agt=navigator.userAgent.toLowerCase();
	if(agt.indexOf("safari")!=-1)
		return safariTrim(value)
	else
		return standardTrim(value);
}

function safariTrim(str)
// simpler trim needed because Safari is buggy
{
	return RTrim(LTrim(str));
}

function LTrim(str)
// part of Safari trim
{
	var whitespace = new String(" \t\n\r");

	var s = new String(str);

	if (whitespace.indexOf(s.charAt(0)) != -1) {
	// We have a string with leading blank(s)...

	var j=0, i = s.length;

	// Iterate from the far left of string until we
	// don't have any more whitespace...
	while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
	 j++;

	// Get the substring from the first non-whitespace
	// character to the end of the string...
	s = s.substring(j, i);
	}
	return s;
}

function RTrim(str)
// part of Safari trim
{
	// We don't want to trip JUST spaces, but also tabs,
	// line feeds, etc.  Add anything else you want to
	// "trim" here in Whitespace
	var whitespace = new String(" \t\n\r");

	var s = new String(str);

	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
	  // We have a string with trailing blank(s)...

	  var i = s.length - 1;       // Get length of string

	  // Iterate from the far right of string until we
	  // don't have any more whitespace...
	  while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
		 i--;


	  // Get the substring from the front of the string to
	  // where the last non-whitespace character is...
	  s = s.substring(0, i+1);
	}

	return s;
}

function standardTrim(value) {
// original trim function, does not work on Safari
	var temp = value;
	var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
	if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
	var obj = /  /g;
	while (temp.match(obj)) { temp = temp.replace(obj, " "); }
	return temp;
}

//--><!]]>

/*
var myDate=new Date()
var today = new Date()
myDate.setFullYear(2008,1,1)

if ((!getCookie('VAR-PrivacyPolicy')) && (today < myDate)){

makeCookie('VAR-PrivacyPolicy','Y',60);
window.open('/index.asp?layout=module&module=popup&cache=FALSE', 'privacy_policy_popup', 'width=320, height=270, resizable=no, scrollbars=no' );

}
*/

function makeCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}