/*** top navigation dropdown ***/
function tabDropdown() {
var sfEls1 = document.getElementById("topnavlevel2").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"), "");
	}
}
}
/*** end top navigation dropdown ***/
	 
/**** Date and Time stamp ******/
function DateTime() {
var strDate = '';

Stamp = new Date();
year = Stamp.getYear();
if (year < 2000) {
	year = 1900 + year;
}
strDate = (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;
}	
strDate += Hours + ":" + Mins + Time;

return strDate;
}
/**** end Date and Time stamp ******/

/*
CSS Browser Selector v0.4.0 (Nov 02, 2010)
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',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):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";


/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
/*** end Bookmark ***/

/**** scrolling breaking news marquee
The JavaScript Source :: http://javascript.internet.com
Created by: Mike Hudson :: http://www.afrozeus.com
You can also play with these variables to control fade speed, fade color, and how fast the colors jump.*/

var m_FadeOut = 255;
var m_FadeIn=0;
var m_Fade = 0;
var m_FadeStep = 3;
var m_FadeWait = 1600;
var m_bFadeOut = true;
var m_iFadeInterval;
var arrFadeLinks;
var arrFadeTitles;
var arrFadeCursor = 0;
var arrFadeMax;

function Fadewl() {
  m_iFadeInterval = setInterval(fade_ontimer, 10);
  arrFadeLinks = new Array();
  arrFadeTitles = new Array();
  setupFadeLinks();
  arrFadeMax = arrFadeLinks.length-1;
  setFadeLink();
}

function setFadeLink() {
  var ilink = document.getElementById("fade_link");
  ilink.innerHTML = arrFadeTitles[arrFadeCursor];
  ilink.href = arrFadeLinks[arrFadeCursor];
}

function fade_ontimer() {
  if (m_bFadeOut) {
    m_Fade+=m_FadeStep;
    if (m_Fade>m_FadeOut) {
      arrFadeCursor++;
      if (arrFadeCursor>arrFadeMax)
        arrFadeCursor=0;
      setFadeLink();
      m_bFadeOut = false;
    }
  } else {
    m_Fade-=m_FadeStep;
    if (m_Fade<m_FadeIn) {
      clearInterval(m_iFadeInterval);
      setTimeout(Faderesume, m_FadeWait);
      m_bFadeOut=true;
    }
  }
  var ilink = document.getElementById("fade_link");
  if ((m_Fade<m_FadeOut)&&(m_Fade>m_FadeIn))
    ilink.style.color = "#" + ToHex(m_Fade);
}

function Faderesume() {
  m_iFadeInterval = setInterval(fade_ontimer, 10);
}

function ToHex(strValue) {
  try {
    var result= (parseInt(strValue).toString(16));

    while (result.length !=2)
            result= ("0" +result);
    result = result + result + result;
    return result.toUpperCase();
  }
  catch(e)
  {
  }
}
/**** end of scrolling breaking news marquee ******/

/*** photo gallery ***/
/***********************************************
* CMotion Image Gallery- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for source code
* Last updated Mar 15th, 04'. Added "End of Gallery" message.
* This copyright notice must stay intact for legal use
***********************************************/

var restarea=6 //1) width of the "neutral" area in the center of the gallery in px
var maxspeed=2 //2) top scroll speed in pixels. Script auto creates a range from 0 to top speed.
var endofgallerymsg="" //3) message to show at end of gallery. Enter "" to disable message.
var endofgallerymsg1="" //3) message to show at end of gallery. Enter "" to disable message.

function enlargeimage(path, optWidth, optHeight){ //function to enlarge image. Change as desired.
var actualWidth=typeof optWidth!="undefined" ? optWidth : "600px" //set 600px to default width
var actualHeight=typeof optHeight!="undefined" ? optHeight : "500px" //set 500px to  default height
var winattributes="width="+actualWidth+",height="+actualHeight+",resizable=yes"
window.open(path,"", winattributes)
}

////NO NEED TO EDIT BELOW THIS LINE////////////
var iedom=document.all||document.getElementById
var iedom1=document.all||document.getElementById
var scrollspeed=0
var movestate=""
var movestate1=""
var actualwidth=''
var actualwidth1=''
var cross_scroll, ns_scroll, cross_scroll1
var loadedyes=0
var loadedyes1=0

function changeImage(filename){
   document.mainimage.src = filename;
}

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft: what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function moveleft(){
if (loadedyes){
movestate="left"
if (iedom&&parseInt(cross_scroll.style.left)>(menuwidth-actualwidth+2)){
cross_scroll.style.left=parseInt(cross_scroll.style.left)-scrollspeed+"px"
}
}
lefttime=setTimeout("moveleft()",10)
}

function moveright(){
if (loadedyes){
movestate="right"
if (iedom&&parseInt(cross_scroll.style.left)<0){
cross_scroll.style.left=parseInt(cross_scroll.style.left)+scrollspeed+"px"
}
}
righttime=setTimeout("moveright()",10)
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function stopmotion(e){
if (window.lefttime) clearTimeout(lefttime)
if (window.righttime) clearTimeout(righttime)
movestate=""
}

function fillup(){
if (iedom){
crossmain=document.getElementById? document.getElementById("motioncontainer") : document.all.motioncontainer
menuwidth=parseInt(crossmain.style.width)
mainobjoffset=getposOffset(crossmain, "left")
cross_scroll=document.getElementById? document.getElementById("motiongallery") : document.all.motiongallery
actualwidth=document.all? cross_scroll.offsetWidth : document.getElementById("motiongallery").offsetWidth
leftmain=document.getElementById? document.getElementById("leftbutt") : document.all.leftbutt
rightmain=document.getElementById? document.getElementById("rightbutt") : document.all.rightbutt

leftmain.onmouseover=function(e){
scrollspeed=2
moveright()
}

rightmain.onmouseover=function(e){
scrollspeed=2
moveleft()
}

leftmain.onmouseout=function(e){
stopmotion(e)
}

rightmain.onmouseout=function(e){
stopmotion(e)
}
}

loadedyes=1
if (endofgallerymsg!=""){
creatediv()
positiondiv()
}
cross_scroll.style.left="0px"
}

function start() {
fillup();
}
/*** end photo gallery ***/

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 = ' ';
		var base = 1.0; // 1em is equiv to 100%

		cssStr += '.art';
		cssStr += ', .rss, .rss-Blogs';
		cssStr += ', .ser, .ser-CarouselStrip, .ser-FeatureList, .ser-Gallery, .ser-GalleryMini, .ser-Grid2, .ser-TopStories, .ser-TopStoriesLite, .ser-NavBox, .ser-People, .ser-RelatedArticles, .ser-Result, .ser-ResultExpanded, .ser-ResultExpanded2, .ser-ResultFeature, .ser-ResultFeatureImg, .ser-ResultLite, .ser-ResultThumbnail, .ser-ResultTitleOnly, .ser-Review, ser-SpotLight, .ser-Staff, .ser-TopStory, .ser-TopStory, .ser-TopStoriesLite, .ser-WeRecommend';
		cssStr += '{font-size:' + (base+(x/10)) +'em;}';

		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();
}

/**** tabs change content on click ******/
function hideall(thisCount,lastCount){
  for (count=thisCount; count<lastCount; count++) // set "lastcount" to one more than the total images/links
  document.getElementById('box'+count).style.display='none';
}

function showbox(box){
  document.getElementById(box).style.display='block';
}

var lastID = 0;
var thisID = 3;
var finalID = 11;
function SelectImg(id,tabs) {
  if (lastID > 0) {
    document.getElementById(lastID).className = "tabNormal";
  }
  document.getElementById(id).className = tabs;
  lastID = id;
}

function SelectImg2(id,tabs) {
  if (thisID > 3) {
    document.getElementById(thisID).className = "tabNormal";
  }
  document.getElementById(id).className = tabs;
  thisID = id;
}

function SelectImg3(id,tabs) {
  if (finalID > 11) {
    document.getElementById(finalID).className = "tabNormal";
  }
  document.getElementById(id).className = tabs;
  finalID = id;
}
/**** end tabs change content on click ******/

$.extend({
    clientID: function(id) {
        return $("[id$='_" + id + "']");
    }
}); 


/*** Cookie for default chart ***/
function setTabDefault(container, chart) {

    var tabId = 1;
    var elementId = container.attr('id');
    
    switch(chart)
    {
        case 'Film':
          tabId = 1;
          break;
        case 'TV Ratings':
          tabId = 2;
          break;
        case 'Legit':
          tabId = 3;
          break;
        case 'Music':
          tabId = 4;
          break;
        case 'Web Video':
          tabId = 5;
          break;
        case 'Social Net Film':
          tabId = 6;
          break;  
        case 'Social Net TV':
          tabId = 7;
          break;      
        
        default:
          tabId = 1;
    }

    var tabElementId = $('#'+elementId).find("[id$='_Tab" + tabId + "']").attr('id');
    var stub = tabElementId.match(/(.*)_Tab/)[1];
        
    toggleTabControl(stub+"_Tab"+tabId, stub+"_LayoutPanel"+tabId, 6);
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function setTabCookie(c_name,value,expiredays)
{
	checkingChart=getCookie('v_chartDefault');
	if (checkingChart!=value)
	{
		setTabCookie2(c_name,value,expiredays);
		alert('Your default chart is now set to ' + value+ '.\n' + value + ' will display as your default chart the next time you visit Variety.');
	}
	else
	{
	expiredays=expiredays - 400;
	setTabCookie2(c_name,value,expiredays);
  }
}

function setTabCookie2(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function applyDefaultTab()
{
    var container = $.clientID('MainTabContainer');
    var tabRememberMe = $('.tabRememberMe');

    if ((tabRememberMe.length) && (container != null)) {
		tabRememberMe.each(function(index) {
			var strTab=getTabCheckbox($(this).text());
			$(this).before(strTab);
		});

	    dChart=getCookie('v_chartDefault');
	    if (dChart!=null && dChart!="")
	    {
	        try{
	          setTabDefault(container, dChart);
	        }
	        catch(err)
	        {
	          $(".chartsFooterCheckbox").append('<span style="display:none">ERROR: Possible tab id miss matchbetween HTML and JS</span>')
	          $(".chartsFooterCheckbox input").attr("disabled", true);
	        }
	    }
	}
}

/* for activating chart checkbox */
function getTabCheckbox(thisTab) {
	 dChart=getCookie('v_chartDefault');
    if( dChart == thisTab ) {
	 	return('<div class="chartsFooterCheckbox">My default chart: '+thisTab+' &nbsp;</div>');
	 } else {
		return('<div class="chartsFooterCheckbox">Make this my default chart <input name="chartsDefault" value="1" type="checkbox" onc'+'lick="setTabCookie(\'v_chartDefault\',\''+thisTab+'\',365);"></div>');
	 }
}

function checkCookieCheckbox(boxID)
{
	dChart=getCookie('v_chartDefault');
	if (dChart!=null && dChart!="")
	{
	setCheckbox(boxID);
	}
	else
	{
	document.write('<div class="chartsFooterCheckbox">Make this my default chart <input name="chartsDefault" value="1" type="checkbox" onc'+'lick="setTabCookie(\'v_chartDefault\',\''+boxID+'\',365);"></div>');
  }
}
/*** end Cookie for default chart ***/

// customized newstogram
function getUser(){
var cookie = getCookie("FullName");
if ((cookie == null || cookie == "")) {
    fname = 'Guest';
}else {
    if (document.cookie.length >= 0) {
        endString = cookie.indexOf("+");
        if (endString != -1) {
			fname = cookie.substr(0,endString);
        }
		else {
			fname = cookie;
		}
    }
}
document.writeln(fname + ', ');
}

/*** Omniture meta ***/
function extractValue(item, extract_from, delim) {
    if (document.cookie.length > 0) {
        c_start = extract_from.indexOf(item + "=");
        if (c_start != -1) {
            c_start = c_start + item.length + 1;
            c_end = extract_from.indexOf(delim, c_start);
            if (c_end == -1) c_end = extract_from.length;
            return unescape(extract_from.substring(c_start, c_end));
        }
    }
    return "";
}

function parseAuthValue(){
//this script parse out the cookie value to get gwa_userId and gwa_authStatus.
var auth = 'Logged Out';
var userid = '';

var cookie = getCookie("eLevUidses");
var login = extractValue("li", cookie, "&");
var rid = extractValue("rv", cookie, "&");

if ((cookie == null || cookie == "") || (login == undefined || login=="0") || (rid == null || rid == "" || rid == undefined || rid=="0")) {
    auth = 'Logged Out';
    userid = '';
}else {
    auth = 'Logged In';
    userid = rid;
}

document.writeln('<meta name="gwa_userId" content="' + userid + '" />');
document.writeln('<meta name="gwa_authStatus" content="' + auth + '" />');
}
/*** end Omniture ***/

/** onLoad **/
// Multiple onload function created by: Simon Willison
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

$(document).ready(function() {
	/*Get date and output*/
	var strDateTime = DateTime();
	$('.DateTime').append(strDateTime);
	
	/*Initialise Share hover menu*/
	var addthis_config = {"data_track_clickback":true};

	applyDefaultTab();
});


