/*** top navigation dropdown ***/
function tabDropdown() {
var sfEls1 = document.getElementById("topnavlevel1").getElementsByTagName("LI");
for (var i=0; i<sfEls1.length; i++) {
	sfEls1[i].onmouseover=function() {
		this.className+="sfhover";
	}
	sfEls1[i].onmouseout=function() {
		this.className=this.className.replace(new RegExp("sfhover\\b"), "");
	}
}
var sfEls2 = document.getElementById("topnav2").getElementsByTagName("LI");
for (var i=0; i<sfEls2.length; i++) {
	sfEls2[i].onmouseover=function() {
		this.className+="sfhover";
	}
	sfEls2[i].onmouseout=function() {
		this.className=this.className.replace(new RegExp("sfhover\\b"), "");
	}
}
var sfEls3 = document.getElementById("globalnavMenu").getElementsByTagName("LI");
for (var i=0; i<sfEls3.length; i++) {
	sfEls3[i].onmouseover=function() {
		this.className+="sfhover";
	}
	sfEls3[i].onmouseout=function() {
		this.className=this.className.replace(new RegExp("sfhover\\b"), "");
	}
}
}
/*** end top navigation dropdown ***/
	 
/**** Date and Time stamp ******/
function DateTime() {
Stamp = new Date();
year = Stamp.getYear();
if (year < 2000) year = 1900 + year;
document.write((Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+ year + ' &nbsp; ');
var Hours;
var Mins;
var Time;
Hours = Stamp.getHours();
if (Hours >= 12) {
Time = " P.M.";
}
else {
Time = " A.M.";
}
if (Hours > 12) {
Hours -= 12;
}
if (Hours == 0) {
Hours = 12;
}
Mins = Stamp.getMinutes();
if (Mins < 10) {
Mins = "0" + Mins;
}	
document.write(Hours + ":" + Mins + Time);
}
/**** end Date and Time stamp ******/

/* CSS browser selector
CSS Browser Selector v0.3.2
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3')?g+' ff3':is('gecko/')?g:/opera(\s|\/)(\d+)/.test(ua)?'opera opera'+RegExp.$2:is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);
/*** end CSS browser selector ***/

/**** font resize ***/
// This Javascript is written by Peter Velichkov (http://blog.creonfx.com)
// and is distributed under the following license : http://creativecommons.org/licenses/by-sa/3.0/
// Use and modify all you want just keep this comment. Thanks
var incdec = 0;
var headID = document.getElementsByTagName("head")[0];
var cssNode = document.createElement("style");
cssNode.type = 'text/css';
cssNode.id="resizingText";

function createCookie(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 readCookie(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;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function loadCss(x){
	try{
		var cssStr = ' ';
		cssStr += '\
		div#newslayout h3.smaller {font-size:' + (15+x) +'px;}\ div.newsincategory .news h2 a, div#newslayout h2, div#topstories h2, div#vplusfeatures h2, div#columns h2, div#hottopics h2, div#channelreviews h2, div#columnistupsell h2, div#columnistcolumns h2, div#vplusreports h2 {font-size:' + (14+x) +'px;}\ #fbrssblogs h2, .entry-content .entry-body {font-size:' + (13+x) +'px;}\ div#sectionheadermenu ul, div#departmentcharts div#departmentchartstables, div.slanguage, div#vplusreports .deck, div.baselineentity2 {font-size:' + (12+x) +'px;}\ div.newsincategory div.deck, div.newsincategory div.byline, div.newsincategory div.subcategory, div.newsincategory div.subcategory a, div#newslayout div.deck, div#newslayout div.description, div#newslayout div.byline, div#newslayout div.next a, div.newsincategory div.newsitem, div#topstories div.description, div.more a, div.next a, div#vplusfeatures div.description a, div#columns div.byline, div#hottopics div.description, div#channelreviews .description, div#channelreviews .byline1, div#channelreviews .byline2, div#blogssmall .deck, .feedburnerFeedBlock .headline a, div#dailyd div.des, div#dailyd div.byline1, div#dailyd div.caption, div#DVD div.description, .feedburnerFeedBlock div, div#columnistcolumns div.previous, div#columnistcolumns div.next {font-size:' + (11+x) +'px;}\ .listing {font-size:' + (10+x) +'px;}\ .entry-header .title {font-size:' + (18+x) +'px;}\ div.newsincategory h3, div#newslayout h3, div#topstories h3, div#columns h3, div#hottopics h3, div#blogssmall h3, div#channelreviews h3, div#departmentcharts h3, div#dailyd h3, div#conacontainer h3 {font-size:' + (20+x) +'px;} \
		';
		cssStr += '\
		\
		';

if(cssNode.styleSheet){
			cssNode.styleSheet.cssText = cssStr; // for IE
		} else {
			var cssText = document.createTextNode(cssStr);
			cssNode.appendChild(cssText); // breaks ie
			//cssNode.innerHTML = cssStr; // breaks saffari
		}
		if(!document.getElementById("resizingText"))headID.appendChild(cssNode);
	}catch(err){ 
		// some debugging code
	}
}

function increaseFontSize() {
	if(incdec < 8){
		incdec++;
		loadCss(incdec);
		createCookie('textsize',incdec,1); 
	}
}

function decreaseFontSize() {
	if(incdec > 0){
		incdec--;
		loadCss(incdec);
		createCookie('textsize',incdec,1); 
	}		
}

var x = readCookie('textsize')
if (x && x!=0) {
	x = parseInt(x);
	incdec = x;
	loadCss(x);
}
/**** end font resize ***/

/**** images scrolling marquee ******/
/* The JavaScript Source!! http://javascript.internet.com
Created by: Mr J | http://www.huntingground.net/ */
scrollStep=1
timerLeft=""
timerRight=""
function toLeft(id){
  document.getElementById(id).scrollLeft=0
}

function scrollDivLeft(id){
  clearTimeout(timerRight) 
  document.getElementById(id).scrollLeft+=scrollStep
  timerRight=setTimeout("scrollDivLeft('"+id+"')",20)
}

function scrollDivRight(id){
  clearTimeout(timerLeft)
  document.getElementById(id).scrollLeft-=scrollStep
  timerLeft=setTimeout("scrollDivRight('"+id+"')",20)
}

function toRight(id){
  document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth
}

function stopMe(){
  clearTimeout(timerRight) 
  clearTimeout(timerLeft)
}
/**** end images scrolling marquee ******/


/**** below are the scripts from evMain.js ******/
<!--//--><![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;
}
function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}
