var divCount = '';
var entInterval;
var msgObj = null;
var is_aol = navigator.userAgent.toLowerCase().indexOf("aol") != -1;
var is_mac = navigator.userAgent.indexOf('Mac') != -1;

var celebBucketNum;
var celebListBlock;
window.onload = channel_init;

function trimString(str) {
	if(str != undefined) {
		return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	} else {
		return str;
	}
}

// start channel functions
function channel_init(){
    onLoadDalaiLlama();
    photoLead_playPhotos();
    if(currentPage=="main"||currentPage=="celebrities"){
    	celebBucketNum = 0;
    	getTopCelebs("next");
    }
    /*if(currentPage=="main"){
    	getFlyoutTemplate();
    }*/
}

//home page ajax functions
function getTopCelebs(cl){
	switch(cl){
	case "next":
		if(celebBucketNum!=15){
			celebBucketNum+=5;
		}else{
			return;
		}break;
	case "prev":
		if(celebBucketNum!=5){
			celebBucketNum-=5;
		}else{
			return;
		}break;
	}
	celebListBlock = (celebBucketNum-4)+" - "+(celebBucketNum);
	new Ajax(ajaxLinkBaseUrl+"/celebrity/components/mostViewedContent.jspf?celebBlock="+celebBucketNum, { method: 'get', onComplete: showCelebs}).request();
}
function showCelebs(request){
	if(document.getElementById("celebcontainer")!=null){
		document.getElementById("celebcontainer").innerHTML = request;
	}
	if(document.getElementById("topCelebPageStatus")!=null){
		document.getElementById("topCelebPageStatus").innerHTML = celebListBlock;
	}
}
function getFlyoutTemplate(){
	new Ajax(ajaxLinkBaseUrl+"/movie/components/movieFlyout.jspf", { method: 'get', onComplete: placeTemplate}).request();
}
function placeTemplate(request){
	document.getElementById("movieFlyoutContainer").innerHTML = request;
}
function getTopFive(item,url){
	var navItems = document.getElementById('topFiveNav').getElementsByTagName("ul")[0].getElementsByTagName("li");
	for(a=0;a<navItems.length;a++){
		navItems[a].className = "top5item";
	}
	item.className = "selected";
	new Ajax(ajaxLinkBaseUrl+url + "?time="+ new Date().getTime(), { method: 'get', onComplete: placeTopFive}).request();
}
function getTopFiveDvd(item,ids,dvdurl){
	var navItems = document.getElementById('topFiveNav').getElementsByTagName("ul")[0].getElementsByTagName("li");
	for(a=0;a<navItems.length;a++){
		navItems[a].className = "top5item";
	}
	item.className = "selected";
	var jsonObj;
	var top5DVDs = "";
	dojo.xhrGet( { // 
	    // The following URL must match that used to test the server.
	    url: dvdurl+'/api/movie?f=json&ids='+ids + "&objectIdTemplateName=homeNew&objectIdKeyPrefixes=MF5-DVD-Poster,MF5-DVD-Title,MF5-DVD-Trailer,MF5-DVD-AllMovies&time="+ new Date().getTime(), 
	    handleAs: "text",
	    timeout: 5000, // Time in milliseconds
	
	    // The LOAD function will be called on a successful response.
	    load: function(response, ioArgs) { // 
			jsonObj =  eval(response);
			var lastClass = "";
			for(j=0;j<5;j++){
				if(j==4){
					lastClass = " noBorder";
				}else{
					lastClass = "";
				}
		      	 top5DVDs +=  '<div class="top5container'+lastClass+'">';
			     top5DVDs +=  '<div class="dimsPoster">';
			     top5DVDs +=  '<a href="'+jsonObj[j]['movieLink']+'" id="movieLink'+jsonObj[j]['movieId'] + '" ' + jsonObj[j]['MF5-DVD-Poster'+(j+1)] + ' >';
			     top5DVDs +=  '<img src="'+jsonObj[j]['dvdPoster']+'" id="moviePoster'+jsonObj[j]['movieId']+'" width="90px" height="133px"onmouseover="toggleDvdFlyout(document.getElementById(\'dvdFlyout'+jsonObj[j]['movieId']+'\'),this);" onmouseout="toggleDvdFlyout(document.getElementById(\'dvdFlyout'+jsonObj[j]['movieId']+'\'));" /></a>';
			     top5DVDs +=  '<div id="dvdFlyout'+jsonObj[j]['movieId']+'" class="showtimesfly" onmouseover="this.style.display = \'block\';" onmouseout="this.style.display = \'none\';">';
			     top5DVDs +=  '<div class="dvdtitle"><a href="'+jsonObj[j]['movieLink']+'" ' + jsonObj[j]['MF5-DVD-Title'+(j+1)] + ' >'+jsonObj[j]['movieTitle']+'</a></div>';
			     top5DVDs +=  '<div class="dvdlinks">';
			     top5DVDs +=  '<a href="'+jsonObj[j]['firstTrailerLink']+'" ' + jsonObj[j]['MF5-DVD-Trailer'+(j+1)] + ' class="movieTrailer">Watch Trailer</a>&nbsp;|&nbsp;';
			     if(jsonObj[j]['netflixLink']){
			    	 top5DVDs +=  '<a href="'+jsonObj[j]['netflixLink']+'" class="movieRent">Rent from Netflix</a>';
			     }
			     if(jsonObj[j]['aolShoppingLink']){
				     top5DVDs +=  '<a href="'+jsonObj[j]['aolShoppingLink']+'" class="movieBuy">Buy Now</a>';
				 }
				 top5DVDs +=  '</div>';
			     top5DVDs +=  '<div class="flycaret"></div></div>';
			     top5DVDs +=  '</div>';
			     top5DVDs +=  '<div class="movietitle">';
			     top5DVDs +=  '<a href="'+jsonObj[j]['movieLink']+'" id="movieLinkTitle'+jsonObj[j]['movieId']+'">';
			     top5DVDs +=  jsonObj[j]['movieTitle']+'</a></div>';
			     top5DVDs +=  '<div class="movielinks">';
			     if(jsonObj[j]['netflixLink']){
			    	 top5DVDs +=  '<a href="'+jsonObj[j]['netflixLink']+'" class="movieRent">Rent</a>';
			     }
			     if(jsonObj[j]['aolShoppingLink']){
				     top5DVDs +=  '<a href="'+jsonObj[j]['aolShoppingLink']+'" class="movieBuy">Buy</a>';
				 }
			     top5DVDs +=  '<a href="'+jsonObj[j]['firstTrailerLink']+'" style="display:block;" class="movieTrailer">Trailer</a>';
				 top5DVDs +=  '</div></div>';
		  }
		 top5DVDs += '<div class="top5foot"><a href="'+dvdurl+'/dvd" ' + jsonObj[1]['MF5-DVD-AllMovies'] + ' >See all movies on dvd</a></div>';
		  placeTopFive(top5DVDs); // 
	    },
	
	    // The ERROR function will be called in an error case.
	    error: function(response, ioArgs) { // 
	      //console.error("HTTP status code: ", ioArgs.xhr.status); // 
	      return response; // 
	      }
	 });

}
function placeTopFive(request){
	document.getElementById("topFive").innerHTML = request;
}
var showFlyDiv;
var showFlyPos;
function toggleShowtimesFlyout(div, pos){
	cancelCloseFlyout();
	if(showFlyDiv){
		showFlyDiv.style.display = "none";
		showFlyDiv.innerHTML = "";
	}
	var divId = div.id;
	if(pos!=undefined){
		showFlyDiv = div;
		showFlyPos = pos;
		var movieId = divId.replace("showtimesFlyout","");
		var linkId = divId.replace("showtimesFlyout","movieLinkTitle");
		if(document.getElementById(linkId)){
			document.getElementById(linkId).style.textDecoration = "underline";
		}
		new Ajax(ajaxLinkBaseUrl+"/inTheaterMovieShowtimesFlyout.jsp?movieId="+movieId + "&time="+ new Date().getTime(), { method: 'get', onComplete: placeShowtimesFlyout}).request();
	}else{
		div.style.display = "none";
	}
}
function placeShowtimesFlyout(request){
	showFlyDiv.style.left=(getLeftPos(showFlyPos)-175)+'px';
	showFlyDiv.style.top=(getTopPos(showFlyPos)-50)+'px';
	showFlyDiv.innerHTML = request;
	showFlyDiv.style.display="block";
}
function toggleMoviesFlyout(div, pos){
	cancelCloseFlyout();
	if(showFlyDiv){
		showFlyDiv.style.display = "none";
	}
	var divId = div.id;
	showFlyDiv = div;
	showFlyPos = pos;
	var theaterId = divId.replace("showtimesFlyout","");
	new Ajax(ajaxLinkBaseUrl+"/moviesPlayingInTheaterFlyout.jsp?theaterId="+theaterId + "&time="+ new Date().getTime(), { method: 'get', onComplete: placeMoviesFlyout}).request();
	
}
var toggletime = 1000;
var toggletimeout = 0;
function toggleOffMoviesFlyout(div,tempus){
	toggletime = 1000;
	showFlyDiv = div;
	var divId = div.id;
	var linkId = divId.replace("showtimesFlyout","movieLinkTitle");
	if(document.getElementById(linkId)){
		document.getElementById(linkId).style.textDecoration = "none";
	}
	if(tempus){
		toggletime = tempus;
	}
	
	toggletimeout = window.setTimeout(closeMoviesFlyout,toggletime);
}
function closeMoviesFlyout(){
	showFlyDiv.style.display = "none";
}
function cancelCloseFlyout(){
	if(toggletimeout){
		clearTimeout(toggletimeout);
		toggletimeout = null;
	}
	
}
function placeMoviesFlyout(request){
	showFlyDiv.style.left=(getLeftPos(showFlyPos)-310)+'px';
	showFlyDiv.style.top=(getTopPos(showFlyPos)-35)+'px';
	showFlyDiv.innerHTML = request;
	showFlyDiv.style.display="block";
}
function toggleDvdFlyout(div, pos){
	var divId = div.id;
	var linkId = divId.replace("dvdFlyout","movieLinkTitle");
	if(pos!=undefined){
		if(document.getElementById(linkId)){
			document.getElementById(linkId).style.textDecoration = "underline";
		}
		/*div.style.left=(getLeftPos(pos))+'px';
		div.style.top=(getTopPos(pos))+'px';
		div.style.display = "block";*/
	}else{
		if(document.getElementById(linkId)){
			document.getElementById(linkId).style.textDecoration = "none";
		}
		//div.style.display = "none";
	}
}

function toggleMoreChannels(){
	cancelCloseFlyout();
	var toggleDiv = document.getElementById("globalnavlist");
	toggleDiv.style.display = "block";
}
function toggleOffMoreChannels(){
	toggletimeout = window.setTimeout(closeMoreChannels,toggletime);
}
function closeMoreChannels(){
	var toggleDiv = document.getElementById("globalnavlist");
	toggleDiv.style.display = "none";
}

//end homepage ajax functions

function checkNull (elem) {
	if(elem.value.length == 0){
		elem.focus();
		return true;
	}
	return false;
}
// helper functions
function popup_window(url,width,height){
	var features="status=0,menubar=0,location=0,toolbar=0";
	if (!isNaN(parseInt(width))){features+=",width="+width;}
	if (!isNaN(parseInt(height))){features+=",height="+height;}
	if (typeof(window.screenLeft)!="undefined"){
		features+=",left="+window.screenLeft;
		features+=",left="+Math.round(window.screenLeft+((document.body.clientWidth/2)-(width/2)));
	} else if (typeof(window.screenX)!="undefined"){
		features+=",left="+Math.round(window.screenX+((window.outerWidth/2)-(width/2)));
	}
	if (typeof(window.screenTop)!="undefined"){
		features+=",top="+window.screenTop;
		features+=",top="+Math.round(window.screenTop+150);
	} else if (typeof(window.screenY)!="undefined"){
		features+=",top="+Math.round(window.screenY+((window.outerHeight-window.innerHeight)+150));
	}
	var popupWin=window.open(url,"popupWin",features);
	if (popupWin.focus){popupWin.focus();}
}

function popupWindow(url,width,height,features) {
	if (!isNaN(parseInt(width))){features+=",width="+width;}
	if (!isNaN(parseInt(height))){features+=",height="+height;}
	if (typeof(window.screenLeft)!="undefined"){
		features+=",left="+window.screenLeft;
		features+=",left="+Math.round(window.screenLeft+((document.body.clientWidth/2)-(width/2)));
	} else if (typeof(window.screenX)!="undefined"){
		features+=",left="+Math.round(window.screenX+((window.outerWidth/2)-(width/2)));
	}
	if (typeof(window.screenTop)!="undefined"){
		features+=",top="+window.screenTop;
		features+=",top="+Math.round(window.screenTop+150);
	} else if (typeof(window.screenY)!="undefined"){
		features+=",top="+Math.round(window.screenY+((window.outerHeight-window.innerHeight)+150));
	}
	var popupWin=window.open(url,"popupWin",features);
	//if (popupWin.focus){popupWin.focus();}
}

function ctaPopup(ctaUrl)
{
	if (ctaUrl) {
		window.open (ctaUrl,'CTA','scrollbars=no,location=no,directories=no,height=265,width=275,menubar=no,resizable=no,titlebar=no');
	} else {
		window.open ("",'CTA','scrollbars=no,location=no,directories=no,height=265,width=275,menubar=no,resizable=no,titlebar=no');
	}
}

var is_flash = false; var flashVer = 7;
if (window.ActiveXObject && !is_mac) {document.write('<scr' + 'ipt language="VBScript">' + '\n' + 'On Error Resume Next' + '\n' + 'is_Flash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & flashVer)))' + '\n' + '<\/sc' + 'ript>'); }
else {var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0; var pluginStr = plugin.description; if (plugin){ if (parseInt(pluginStr.substring(pluginStr.indexOf(".")-1)) >= flashVer) { is_flash = true; }}}

function openWindow (url) {
	var argv = openWindow.arguments;
	var argc = argv.length;
	if (argc == 1) {var handle = window.open(url);}
	else if (argc == 2) {var handle = window.open(url,argv[1]);}
	else {var handle = window.open(url,argv[1],argv[2]);}
	handle.focus();
}

function onLoadDalaiLlama() {
    if (typeof onLoadDalaiLlamaMxid != 'undefined') {
        if ((typeof onLoadDalaiLlamaMxidType != 'undefined') && (onLoadDalaiLlamaMxidType == 'audio')) {
            DalaiLlama.OpenAudioFullMXID("mp.aol.com", onLoadDalaiLlamaMxid)
        } else {
            DalaiLlama.OpenFullMXID("mp.aol.com", onLoadDalaiLlamaMxid)
        }
	setOptCookie("bbDL"+onLoadDalaiLlamaMxid,onLoadDalaiLlamaMxid);
    }
}

// gets the value of the query string
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
}

// check for the valid object
function testIsValidObject(objToTest) {
    if (objToTest == null || objToTest == undefined) {
        return false;
    }
    return true;
}

// Omniture Custom Link Tracking Script For Info Themed List Modules
function doNMClick(oLink){
	/*the value of s_linkTrackVars should be set to include the variables that need to related to the link. The values of s_channel and s_prop19 will be gathered from the underlying page. s_prop19 contains the value of s_pageName from the underlying page. */
    s_linkTrackVars="s_channel,s_prop16,s_prop17,s_prop18,s_prop19,s_prop20";
	//s_linkType is the same for all links, type "o" refers to Custom Links
    s_linkType='o';
	//set Link Name to equal the innerHTML from the Link Object
    s_linkName=oLink.innerHTML;
	/* back up the original values in the s_props on the page */
    var s_prop16bu=s_prop16;
    var s_prop17bu=s_prop17;
    var s_prop18bu=s_prop18;
    var s_prop19bu=s_prop19;
    var s_prop20bu=s_prop20;
	//set the various s_props
    s_prop16=oLink.getAttribute("mt");
    if (this.arrXpromoIncModules == undefined)
    {
        var s_account="aolnwmoduledev";
    } else {
        flag = false;
        var loc = window.location.href;
        for (var i=0;i<arrXpromoIncModules.length;i++)
        {
            if (arrXpromoIncModules[i] == s_prop16)
            {
                flag = true;
                break;
            }
        }
        if (flag == true)
        {
            s_account="aolxpromo";
        } else {
            s_account="aolnwmoduledev";
        }
        if (loc.indexOf('office')!=-1 || loc.indexOf('stage')!=-1 || loc.indexOf('estage')!=-1 || loc.indexOf('adpqa')!=-1)
        {
            s_account="aolxpromodev";
        } else {
            s_account="aolxpromo";
        }
    }
    s_prop17= (window['s_channel']==undefined||window['s_channel']=="")?"unavailable":s_channel;
    s_prop18=(window['s_pageName']==undefined||window['s_pageName']=="")?document.title:s_pageName;
    s_prop19=document.URL
    s_prop20=oLink.href;
	//these functions are called for every link
    if (window['s_account'] != undefined){
      	s_lnk=s_co(oLink);
        s_gs(s_account);
    }
	/* replace the original values in the s_props on the page */
    s_prop16=s_prop16bu;
    s_prop17=s_prop17bu;
    s_prop18=s_prop18bu;
    s_prop19=s_prop19bu;
    s_prop20=s_prop20bu;
}

/*Omniture Custom Link Tracking Script For Info Themed List Modules*/
function doNMClickimg(oLink,image){
	/*the value of s_linkTrackVars should be set to include the variables that need to related to the link. The values of s_channel and s_prop19 will be gathered from the underlying page. s_prop19 contains the value of s_pageName from the underlying page. */
    s_linkTrackVars="s_channel,s_prop16,s_prop17,s_prop18,s_prop19,s_prop20";
	//s_linkType is the same for all links, type "o" refers to Custom Links
    s_linkType='o';
	//set Link Name to equal the innerHTML from the Link Object
    s_linkName=image;
	/* back up the original values in the s_props on the page */
    var s_prop16bu=s_prop16;
    var s_prop17bu=s_prop17;
    var s_prop18bu=s_prop18;
    var s_prop19bu=s_prop19;
    var s_prop20bu=s_prop20;
	//set the various s_props
    s_prop16=oLink.getAttribute("mt");
    if (this.arrXpromoIncModules == undefined)
    {
        var s_account="aolnwmoduledev";
    } else {
        flag = false;
        var loc = window.location.href;
        for (var i=0;i<arrXpromoIncModules.length;i++)
        {
            if (arrXpromoIncModules[i] == s_prop16)
            {
                flag = true;
                break;
            }
        }
        if (flag == true)
        {
            s_account="aolxpromo";
        } else {
            s_account="aolnwmoduledev";
        }
        if (loc.indexOf('office')!=-1 || loc.indexOf('stage')!=-1 || loc.indexOf('estage')!=-1 || loc.indexOf('adpqa')!=-1)
        {
            s_account="aolxpromodev";
        } else {
            s_account="aolxpromo";
        }
    }
    s_prop17= (window['s_channel']==undefined||window['s_channel']=="")?"unavailable":s_channel;
    s_prop18=(window['s_pageName']==undefined||window['s_pageName']=="")?document.title:s_pageName;
    s_prop19=document.URL
    s_prop20=oLink.href;
	//these functions are called for every link
    if (window['s_account'] != undefined){
      	s_lnk=s_co(oLink);
        s_gs(s_account);
    }
	/* replace the original values in the s_props on the page */
    s_prop16=s_prop16bu;
    s_prop17=s_prop17bu;
    s_prop18=s_prop18bu;
    s_prop19=s_prop19bu;
    s_prop20=s_prop20bu;
}

// you said it
var activeYousaidit = 0;
function toggle_yousaidit(){
	if (document.getElementById("yousaidit"+(activeYousaidit+1))){
		toggle_display("yousaidit"+activeYousaidit,false);
		toggle_display("yousaidit"+(++activeYousaidit),true);
	} else {
		toggle_display("yousaidit"+activeYousaidit,false);
		toggle_display("yousaidit"+(activeYousaidit=0),true);
	}
}

function toggle_display(id,state){
	if (document.getElementById(id)){
		if (typeof(state)=="undefined"){state=document.getElementById(id).style.display=="block"?false:true;}
		document.getElementById(id).style.display=state?"block":"none";
	}
}

// newsmaker
var maxNewsmaker=new Array(), activeNewsmaker=new Array();
function swapNewsmaker(id,direction){
	if (typeof(maxNewsmaker[id])=="undefined" && document.getElementById("newsmaker"+id+"."+1)){
		maxNewsmaker[id]=activeNewsmaker[id]=1;
		while (document.getElementById("newsmaker"+id+"."+(++maxNewsmaker[id]))){}
		maxNewsmaker[id]--;
	}
	if (maxNewsmaker[id]>1){
		toggle_display("newsmaker"+id+"."+activeNewsmaker[id],false);
		if (direction=="next"){
			if (document.getElementById("newsmaker"+id+"."+(activeNewsmaker[id]+1))){
				toggle_display("newsmaker"+id+"."+(++activeNewsmaker[id]),true);
			} else {
				toggle_display("newsmaker"+id+"."+(activeNewsmaker[id]=1),true);
			}
		} else if (direction=="previous"){
			if (document.getElementById("newsmaker"+id+"."+(activeNewsmaker[id]-1))){
				toggle_display("newsmaker"+id+"."+(--activeNewsmaker[id]),true);
			} else {
				toggle_display("newsmaker"+id+"."+(activeNewsmaker[id]=maxNewsmaker[id]),true);
			}
		}
		document.getElementById("newsmakerTally"+id).innerHTML=activeNewsmaker[id]+"/"+maxNewsmaker[id];
	}
}

// what's hot
var activeTab = new Array();
var d = document;
var whTimer=9;
var startFrom=0;
var pause = 0;
var activeTab = 0;

function decrTimer() {
	if (pause) {
		d.getElementById("timerText").innerHTML="Paused"
		d.getElementById("playid").onmouseout = function(){d.getElementById("playid").src="http://cdn.channel.aol.com/ch_sports/info_play";};
		d.getElementById("playid").onmouseover = function(){d.getElementById("playid").src="http://cdn.channel.aol.com/ch_sports/info_play_rollover";};
		d.getElementById("pauseid").onmouseout = function(){return;};
		return;
	}
	d.getElementById("pauseid").onmouseover = function(){d.getElementById("pauseid").src="http://cdn.channel.aol.com/ch_sports/info_pause_rollover";};
	d.getElementById("pauseid").onmouseout = function(){d.getElementById("pauseid").src="http://cdn.channel.aol.com/ch_sports/info_pause";};
	d.getElementById("playid").onmouseout = function(){return;};
	whTimer--;
	if(whTimer<=0){
		showWhatsHot();
		whTimer=9;
	}
	d.getElementById("timerText").innerHTML="Updates in " +whTimer+" seconds"
}

function showWhatsHot(){
	listObj=document.getElementById("whatsHot");
	for(i=0;i<listObj.childNodes.length;i++) {

		if (el[startFrom][2] == "e"){
			trendimg = "http://cdn.channel.aol.com/ch_sports/info_dash";
		} else {
			if (el[startFrom][2] == "u"){
				trendimg = "http://cdn.channel.aol.com/ch_sports/info_up_arrow";
			} else {
				trendimg = "http://cdn.channel.aol.com/ch_sports/info_down_arrow";
			}
		}
		if(listObj.childNodes[i].nodeType == 1) {
			listObj.childNodes[i].innerHTML = "";
			if (startFrom<el.length/2){
				y = listObj.childNodes[i].appendChild(document.createElement("img"));
				y.src = trendimg;
			}
			x = listObj.childNodes[i].appendChild(document.createElement("a"));
			tempURL = unescape(el[startFrom][0]);
			spot = '&_s=htsitelnk_' + i;
			if (tempURL.substring(0,3) == 'aol'){
				x.href = tempURL;
			} else {
				x.href = redirUrl + spot + '&_u=' + el[startFrom][0];
			}
			x.innerHTML = el[startFrom][1];
			startFrom++;
			if(!activeTab) {
				if(startFrom>=el.length/2)startFrom=0;
			} else {
				if(startFrom>=el.length) startFrom = el.length/2;
			}
		}
	}
}

// photoLead
var picHostURL = "http://cdn.channel.aol.com/ch_pf/";
var activeButton, playingForward, playingBackward, photoPlayer, playControlActive, storyControlActive, maxStory
var timeDelay = 10
var autoPlay = "on"
var playDirection = "forward"
var x = 0
var offImg = new Array("info_btn_1_off-pf","info_btn_2_off-pf","info_btn_3_off-pf","info_btn_4_off-pf","info_btn_5_off-pf","info_btn_6_off-pf","info_btn_7_off-pf","info_btn_8_off-pf","info_btn_9_off-pf","info_btn_10_off-pf","info_btn_11_off-pf","info_btn_12_off-pf","info_btn_prev_off-pf","info_btn_pause_off-pf","info_btn_next_off-pf")
var onImg = new Array("info_btn_1_on-pf","info_btn_2_on-pf","info_btn_3_on-pf","info_btn_4_on-pf","info_btn_5_on-pf","info_btn_6_on-pf","info_btn_7_on-pf","info_btn_8_on-pf","info_btn_9_on-pf","info_btn_10_on-pf","info_btn_11_on-pf","info_btn_12_on-pf","info_btn_prev_on-pf","info_btn_pause_on-pf","info_btn_next_on-pf")

function photoLead_playPhotos(seconds,onOff,direction){
	if (document.getElementById("photoGalleryParent")){
		if (seconds!=undefined){timeDelay = seconds}
		timeDelay = timeDelay * 1000
		if (typeof(maxStory)=="undefined"){
			maxStory = 0;
			while (document.getElementById("pic"+maxStory)){
				maxStory++;
			}
		}
		if (onOff!=undefined){autoPlay=onOff.toLowerCase()}
		else{autoPlay=autoPlay.toLowerCase()}
		if (direction!=undefined){playDirection=direction.toLowerCase();}
		else{playDirection=playDirection.toLowerCase();}
		if (playDirection=="forward"){
			playingForward=true
			playingBackward=false
			playControlActive=14
		} else {
			playingForward=false
			playingBackward=true
			playControlActive=12
		}
		if (autoPlay=="on"){photoLead_startTimer()}
		else (photoLead_changePhotoStory(1))
	}
}

function photoLead_startTimer(){
	if (playingForward==true){
		if (document.getElementById("pic14")){document.getElementById("pic14").src = picHostURL + onImg[14]}
		if (document.getElementById("photostory" + (x+1)) && document.getElementById("pic" + x)){x=x+1}
		else{maxStory=x; x=1;}
	}
	if (playingBackward==true){
		if (document.getElementById("pic12")){document.getElementById("pic12").src = picHostURL + onImg[12]}
		x=x-1;
		if (x<1){x=maxStory}
	}
	if (document.getElementById("titledefault") && document.getElementById("photo" + x + "title") && document.getElementById("photo" + x + "title").innerHTML!=""){document.getElementById("titledefault").innerHTML=document.getElementById("photo" + x + "title").innerHTML}
	if (document.getElementById("photodefault") && document.getElementById("photostory" + x + "photo") && document.getElementById("photostory" + x + "photo").innerHTML!=""){document.getElementById("photodefault").innerHTML=document.getElementById("photostory" + x + "photo").innerHTML}
	if (document.getElementById("textdefault") && document.getElementById("photostory" + x + "text") && document.getElementById("photostory" + x + "text").innerHTML!=""){document.getElementById("textdefault").innerHTML=document.getElementById("photostory" + x + "text").innerHTML}
	if (document.getElementById("linkWrapperDefault") && document.getElementById("linkWrapper" + x) && document.getElementById("linkWrapper" + x).innerHTML!=""){document.getElementById("linkWrapperDefault").innerHTML=document.getElementById("linkWrapper" + x).innerHTML}
	storyControlActive=x-1;
	photoLead_makeActive(x);
	photoPlayer=setTimeout("photoLead_startTimer()", timeDelay);
}

function photoLead_stopTimer(){
	if (playingForward==true && document.getElementById("pic14")){document.getElementById("pic14").src = picHostURL + offImg[14]}
	if (playingBackward==true && document.getElementById("pic12")){document.getElementById("pic12").src = picHostURL + offImg[12]}
	playingForward=false;
	playingBackward=false;
	playControlActive=-1;
	if (photoPlayer){clearTimeout(photoPlayer);}
	else {if (photoPlayer==undefined && document.getElementById("pic13")){document.getElementById("pic13").src = picHostURL + offImg[13]}}
}

function photoLead_rollover(buttonID,buttonNumber,buttonState){
	if (document.getElementById(buttonID)){
		switch (buttonState){
			case "on":
				document.getElementById(buttonID).src = picHostURL + onImg[buttonNumber];
				break;
			case "off":
				if (activeButton!=buttonNumber && playControlActive!=buttonNumber && storyControlActive!=buttonNumber){
					document.getElementById(buttonID).src = picHostURL + offImg[buttonNumber];
				}
				break;
		}
	}
}

function photoLead_makeActive(isActiveNum){
	activeButton = isActiveNum - 1;
	if (activeButton==13){}
	else{
		for (i=0;i<15;i++){
			if (playingForward==true && i!=14 && document.getElementById("pic" + i)){document.getElementById("pic" + i).src = picHostURL + offImg[i]}
			else if (playingBackward==true && i!=12 && document.getElementById("pic" + i)){document.getElementById("pic" + i).src = picHostURL + offImg[i]}
			else if (playingForward==false && playingBackward==false && document.getElementById("pic" + i)){document.getElementById("pic" + i).src = picHostURL + offImg[i]}
		}
	}
	if (document.getElementById("pic" + activeButton)){document.getElementById("pic" + activeButton).src = picHostURL + onImg[activeButton]}
}

function photoLead_changePhotoStory(photStorNumber){
	if (photStorNumber>maxStory){photStorNumber=maxStory}
	storyControlActive=photStorNumber-1;
	x=photStorNumber;
	photoLead_makeActive(photStorNumber);
	if (document.getElementById("titledefault") && document.getElementById("photo" + photStorNumber + "title") && document.getElementById("photo" + photStorNumber + "title").innerHTML!=""){document.getElementById("titledefault").innerHTML=document.getElementById("photo" + photStorNumber + "title").innerHTML}
	if (document.getElementById("photodefault") && document.getElementById("photostory" + photStorNumber + "photo") && document.getElementById("photostory" + photStorNumber + "photo").innerHTML!=""){document.getElementById("photodefault").innerHTML=document.getElementById("photostory" + photStorNumber + "photo").innerHTML}
	if (document.getElementById("textdefault") && document.getElementById("photostory" + photStorNumber + "text") && document.getElementById("photostory" + photStorNumber + "text").innerHTML!=""){document.getElementById("textdefault").innerHTML=document.getElementById("photostory" + photStorNumber + "text").innerHTML}
	if (document.getElementById("linkWrapperDefault") && document.getElementById("linkWrapper" + photStorNumber) && document.getElementById("linkWrapper" + photStorNumber).innerHTML!=""){document.getElementById("linkWrapperDefault").innerHTML=document.getElementById("linkWrapper" + photStorNumber).innerHTML}
}

// ad support
function rsiAdInit(segmax) {
    var segQS="";
    var segs_beg=document.cookie.indexOf('rsi_segs=');
    if(segs_beg>=0){
        segs_beg=document.cookie.indexOf('=',segs_beg)+1;
        if(segs_beg>0){
            var segs_end=document.cookie.indexOf(';',segs_beg);
            if(segs_end==-1)segs_end=document.cookie.length;
            rsi_segs=document.cookie.substring(segs_beg,segs_end).split('|');
            for (var i=0;i<Math.min(segmax,rsi_segs.length);i++){
                segQS+=rsi_segs[i].replace(/.*_(.*)/,"rsi=$1;");
            }
            adSetOthDclk(segQS);
       }
    }
}


// movie search
function domoviesearch (sWidNum) {
    eval('var sformObj = document.movieSearchForm' + (sWidNum?sWidNum:''));
    for (i=0; i < sformObj.searchby.length; i++) {
        if (sformObj.searchby[i].checked) {
            var selectedField = sformObj.searchby[i].value;
        }
    }
    var searchQuery = sformObj.qfth.value
    switch (selectedField) {
        case 'movies' :
            str = 'http://movies.aol.com/search/movieanddvdresults.adp?query=';
            break;
        case 'people' :
            str = 'http://search.aol.com/aol/search';
            break;
        case 'location' :
            str = 'http://movies.aol.com/search/locationresults.adp?csz=';
        break;
    }
    realString = str + escape(searchQuery).replace(/\+/g,'%2b')
    parent.location.href = realString
}

// hide/display div
function dataFlip(off,on) {
    document.getElementById(off).style.display = "none";
    document.getElementById(on).style.display = "block";
}

// hide/display div for header
function dataFlipExact(name, vis) {
    var el = name + 'searchmorepop';
    var tag = name + 'searchmore';
    if (!document.getElementById(el))  // menu object not found
        return;
    if (vis == 0) {  // hide the menu
        document.getElementById(el).style.visibility = 'hidden';
        return;
    }
    var pos = document.getElementById(tag);
    var dx = getElementAbsPosX(pos)-135;
    var dy = getElementAbsPosY(pos)-100;
    var abspopupbottom = dy + document.getElementById(el).clientHeight + 10;
    var abswindowbottom = GetAbsWindowBottom();
    if (abspopupbottom > abswindowbottom)
        dy = dy - (abspopupbottom - abswindowbottom);
    document.getElementById(el).style.left = dx + 'px';
    document.getElementById(el).style.top = dy + 'px';
    if (vis > 0)
        document.getElementById(el).style.visibility = 'visible';
}

//hide/display div for header
function dataFlipExactFoot(name, vis) {
    var el = 'menusearchmorepop';
    var tag = name + 'searchmore';
    if (!document.getElementById(el))  // menu object not found
        return;
    if (vis == 0) {  // hide the menu
        document.getElementById(el).style.visibility = 'hidden';
        return;
    }
    var pos = document.getElementById(tag);
    var dx = getElementAbsPosX(pos)-135;
    var dy = getElementAbsPosY(pos)-100;
    var abspopupbottom = dy + document.getElementById(el).clientHeight + 10;
    var abswindowbottom = GetAbsWindowBottom();
    if (abspopupbottom > abswindowbottom)
        dy = dy - (abspopupbottom - abswindowbottom);
    document.getElementById(el).style.left = dx + 'px';
    document.getElementById(el).style.top = dy + 'px';
    if (vis > 0)
        document.getElementById(el).style.visibility = 'visible';
}

function getElementAbsPosX(el) {
    var dx = 0;
    if (el.offsetParent) {
        dx = el.offsetLeft + 8;
        while (el = el.offsetParent) {
            dx += el.offsetLeft;
        }
    }
    return dx;
}

function getElementAbsPosY(el) {
    var dy = 0;
    if (el.offsetParent) {
        dy = el.offsetTop + el.offsetHeight / 2;
        while (el = el.offsetParent) {
            dy += el.offsetTop;
        }
    }
    return dy;
}

function GetAbsWindowBottom() {
    var abswindowbottom = 0;
    if (typeof(window.innerHeight) == 'number')
        abswindowbottom = window.innerHeight;
    else if (document.documentElement && document.documentElement.clientHeight)
        abswindowbottom = document.documentElement.clientHeight;
    else if (document.body && document.body.clientHeight)
        abswindowbottom = document.body.clientHeight;
    if (typeof(window.pageYOffset) == 'number')
        abswindowbottom = abswindowbottom + window.pageYOffset;
    else if (document.body && document.body.scrollTop)
        abswindowbottom = abswindowbottom + document.body.scrollTop;
    else if (document.documentElement && document.documentElement.scrollTop)
        abswindowbottom = abswindowbottom + document.documentElement.scrollTop;
    return abswindowbottom;
}

//close child and refresh parent
function closeRef() {
    opener.location.reload();
    self.close();
}

//validate if blank form
function validateForm(thisform){
	with (thisform) {
		if (validateReq(qa_s,"Please enter an Address")==false) {
			qa_s.focus();
			return false
		}
		if (validateReq(qc_s,"Please enter a City")==false) {
			qc_s.focus();
			return false
		}
		if (validateReq(qz_s,"Please enter a Zip")==false) {
			qz_s.focus();
			return false
		}
	}
}

function validateReq(field,popalert) {
	with (field) {
		if (value==null||value=="")
			{alert(popalert);return false}
		else {return true}
	}
}

// aolclient
function parseURL(args) {
	var desiredUrl = urlMatrix[args];
	if (!is_aol) {
		if (desiredUrl.substring(0,3) == 'aol') {alert("This area is only available within the AOL client.");}
		else {document.location = desiredUrl;}
	} else {
		document.location = desiredUrl;
	}
}

// pulldown menu for header
function getposOffset (moviesmenu, offsettype) {
	var totaloffset=(offsettype=="left")? moviesmenu.offsetLeft : moviesmenu.offsetTop;
	var parentEl=moviesmenu.offsetParent;
		while (parentEl!=null){
			totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
			parentEl=parentEl.offsetParent;
		}
	return totaloffset;
}

function moviesmenu (curobj, subobjstr, opt_position) {
	if (document.getElementById) {
		var subobj=document.getElementById(subobjstr);
		subobj.style.display=(subobj.style.display!="block")? "block" : "none";
		var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0);
		var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0);
		xpos = xpos - 141;
		ypos = ypos - 127;
			subobj.style.left=xpos+"px"
			subobj.style.top=ypos+"px"
			return false;
	} else {
		return true;
	}
}

function moviesmenuNew (curobj, subobjstr, opt_position) {
	
	if (document.getElementById) {
		var subobj=document.getElementById(subobjstr);
		var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0);
		var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0);
		xpos = xpos-114;
		ypos = ypos-3;
			subobj.style.left=xpos+"px"
			subobj.style.top=ypos+"px"
			return false;
	} else {
		return true;
	}
}

function moviesmenuclose (subobj) {
	document.getElementById(subobj).style.display="none"
}

// crosspromo
/*var d=document; var w=window;var docHg;
var range=400;
var cod_arr=new Array();
var arrLen = 0;
var modSpan = 6;
var currId = 0;
var opt = {
	ae:function(o,et,fn){if(o.addEventListener)o.addEventListener(et,fn,false);else if(o.attachEvent)o.attachEvent("on"+et,fn);},
	gt:function(t,o){o=o?o:document;return o.getElementsByTagName(t)},
	gc:function(c,t,s,o){var r=new Array();var os=opt.gt(t,o);for(var i=0,j=0,l=os.length;i<l;i++){var sc = s + os[i].className + s;if(sc.indexOf(s+c+s)!=-1){r[j] = os[i];j++;}}return r;},
        nview:function(obj,i) {
                if (obj.loaded==null) {
                    obj.loaded=0;
                }
                if (obj.loaded==0) {
                    var relTop=obj.offsetTop-(w.scrollY||d.documentElement.scrollTop);
                    if((relTop-docHg-20)<range) {
                      var codUrl=opt.gt('a',obj)[0].href;
                      opt.xhr(codUrl,obj,i);
                    }
                }
        },
        doCod:function(){
                var l=cod_arr.length;
                for (var i=0;i<l;i++) {
                        opt.nview(cod_arr[i],i);
                }
        },
        xhr:function(u,obj,i){
                obj.loaded=1;
                var f,r,m='GET';
                f=function(){if(r.readyState>3)opt.update(obj,r,i);}
                r= window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");
                r.onreadystatechange=f;
                r.open(m,u,1);
                r.setRequestHeader('content-type','text/xml');
                r.send('');
        },
        update:function(obj,r,i) {
                if(r.status==200){
                        obj.innerHTML=r.responseText;
                } else {obj.loaded=0;}
        },
        init:function() {
                        cod_arr=opt.gc('cod','div','',document);
                        docHg=w.innerHeight||d.documentElement.offsetHeight;
                        opt.doCod();
                        opt.ae(window,'scroll',opt.doCod);
        },
        res:function(){
                docHg=w.innerHeight||d.documentElement.offsetHeight;
                opt.doCod();
        }

}
opt.ae(window,'resize',opt.res);
opt.ae(window,'load',opt.init);
*/
function countCartridges() {
   var cartCount = 0;
   end = false;
   do {
      if(document.getElementById('cart'+cartCount)) {
         cartCount++;
      } else {
         end = true;
      }
   } while (end == false)
   arrLen = cartCount;
}

function showCartridges( startId ) {
  if(arrLen == 0) {
    countCartridges();
  }
  var i,j;
  for (i=0,j=startId; i < modSpan; i++,j++) {
     var strCart = j%arrLen;
     document.getElementById('cartridge'+i).innerHTML = document.getElementById('cart'+strCart).innerHTML;
  }
}

function isModFetched (modId) {
  if(document.getElementById('cart'+modId).innerHTML.length>0) {
      return true;
  } else {
      return false;
  }
}

function nextCartridge () {
  if(arrLen == 0) {
     countCartridges();
  }
  currId = currId + 1;
  if ( !isModFetched( (currId+modSpan)%arrLen ) ) {
      fetchModule((currId+modSpan)%arrLen);
  }
  showCartridges(currId);
}

function prevCartridge () {
  if(arrLen == 0) {
    countCartridges();
  }
  if(currId!=0) {
      currId = currId - 1
  } else {
      currId=arrLen-1;
  }

  if ( !isModFetched( (currId+modSpan)%arrLen ) ) {
      fetchModule((currId+modSpan)%arrLen);
  }
  showCartridges(currId);
}

// cards on the table
var cott = {
	timeout: 3750,
	maxLink: 0,
	init: function() {
		var topLink = document.getElementById("toplink");
		var links = topLink.getElementsByTagName("A");
		cott.maxLink = links.length;
		if (links.length == 0) { return; }
		for(var i=0;i<links.length;i++) {
			links[i].style.backgroundColor = '#fff';
			links[i].style.zoom = 1;
			if (i>0) { links[i].style.display = 'none'; }
		}
	        setTimeout("cott.rotateLink(2)", cott.timeout);
	},
	fadeTo: function(obj, lvl) {
		obj.style.filter = 'alpha(opacity=' + lvl*10 + ')';
		obj.style.opacity = lvl/10;
	},
	rotateLink: function (linkNo) {
		cott.displayNextLink(linkNo);
		var nextLink = linkNo + 1;
		if (nextLink > cott.maxLink) {
			nextLink = 1;
		}
		var t = setTimeout("cott.rotateLink(" + nextLink + ")", cott.timeout);
	},
	displayNextLink: function(linkNo) {
		var lastLink = linkNo-1;
		if (lastLink == 0) {
			lastLink = cott.maxLink;
		}
		cott.fade("cottLink"+lastLink, "cottLink"+linkNo, -10);
	},
	fade: function(from, to, stage) {
		if (!document.getElementById(from)) { return; }
		fobj = document.getElementById(from);
		if (!document.getElementById(to)) { return; }
		tobj = document.getElementById(to);
		if (stage < 0) {
			cott.fadeTo(fobj, Math.abs(stage));
		} else if (stage == 0) {
			fobj.style.display = 'none';
			cott.fadeTo(tobj, 1);
			tobj.style.display = 'inline';
		} else {
			cott.fadeTo(tobj, stage);
		}
		if (stage != 10) {
		var b = setTimeout("cott.fade('" + from + "', '" + to + "', " + parseInt(stage+1) + ")", 40);
		}
	}
};

function buildCottImg(num) {

   var cPar = document.getElementById('card_' + num);
   var cImg = document.getElementById('image_' + num);
   var cPhoto = document.getElementById('photo_' + num);

   var newImg = document.createElement('img');
   newImg.setAttribute('src', cImg.href);
   newImg.setAttribute('alt', cImg.innerHTML);
  
   if (cPhoto != null) {
      cPhoto.appendChild(newImg);
      cPhoto.removeAttribute("id");
      cPar.removeChild(cImg);
   } else {
      cPar.replaceChild(newImg, cImg);
   }
}

function displayCottMods(firstMod) {

  modInst = modInst + firstMod;
  if(modInst == -1) {
      modInst = maxCards - 1;
  }

  for (var m=0; m<3; m++) {
     var inst = (modInst + m)%(maxCards);
     var topcard='showcard'+ m;
     var hiddenCardId = "card_" + inst;
     var parentDiv = document.createElement("div");
     var hiddenCard = document.createElement("div");

     if(document.getElementById('image_'+inst)) {
         buildCottImg(inst);
     }

     hiddenCard.id = "slot_" + inst;
     hiddenCard.className = "card";
     hiddenCard.innerHTML = (document.getElementById(hiddenCardId).innerHTML);
     parentDiv.appendChild(hiddenCard);
     document.getElementById(topcard).innerHTML = parentDiv.innerHTML;
  }
}

function cottInit() {
   displayCottMods(0);
   document.getElementById('topHiddenModules').className="hideCards";
   document.getElementById('arrows').className="show_arws";
   document.getElementById('showcard0').className="showCards";
   document.getElementById('showcard1').className="showCards";
   document.getElementById('showcard2').className="showCards";
}

/* some ajax functionality for modules */
var enableCache = true;
var jsCache = new Array();
var ajaxObjects = new Array();
var x_offset_dvddual = 5;
var y_offset_dvddual = 0;
var providerObj = false;
var providerObj_iframe = false;
var providerObj_MSIE = false;
if(navigator.userAgent.indexOf('MSIE')>=0)providerObj_MSIE=true;

function showSnagFeed(externalFile,inputObj) {
	
	//NOTE: the code below is a temporary fix to enable snag of the modules coming from BB
	//It should be removed once these modules are transfered to dynapub 
	var checkLink = externalFile.search("http://movies.aol.com/feedsnagajax.adp");
	if(checkLink!=-1){
		externalFile = externalFile.replace("http://movies.aol.com/feedsnagajax.adp", "modules/snag-feed-popup.jspf");
	}
	//END of NOTE
	
	if(!providerObj)
	{
		providerObj = document.createElement('DIV');
		providerObj.style.position = 'absolute';
		providerObj.id = 'providerObj';
		document.body.appendChild(providerObj);
		var contentDiv = document.createElement('DIV');
		contentDiv.className = 'snagfeed';
		providerObj.appendChild(contentDiv);
		contentDiv.id = 'snagfeed';
		if(providerObj_MSIE){
			providerObj_iframe = document.createElement('<IFRAME frameborder="0">');
			providerObj_iframe.style.position = 'absolute';
			providerObj_iframe.border='0';
			providerObj_iframe.frameborder='0';
			providerObj_iframe.style.backgroundColor='#FFF';
			providerObj_iframe.src = 'about:blank';
			contentDiv.appendChild(providerObj_iframe);
			providerObj_iframe.style.left = '0px';
			providerObj_iframe.style.top = '0px';
		}
	}
	providerObj.style.display='block';
	loadContent('snagfeed',externalFile);
	if(providerObj_MSIE){
		providerObj_iframe.style.width = providerObj.clientWidth + 'px';
		providerObj_iframe.style.height = providerObj.clientHeight + 'px';
	}
	positionProviders(inputObj);
}

function showProviders(externalFile,inputObj) {
	if(!providerObj)
	{
		providerObj = document.createElement('DIV');
		providerObj.style.position = 'absolute';
		providerObj.id = 'providerObj';
		document.body.appendChild(providerObj);
		var contentDiv = document.createElement('DIV');
		contentDiv.className = 'providerpop';
		providerObj.appendChild(contentDiv);
		contentDiv.id = 'providerpop';
		if(providerObj_MSIE){
			providerObj_iframe = document.createElement('<IFRAME frameborder="0">');
			providerObj_iframe.style.position = 'absolute';
			providerObj_iframe.border='0';
			providerObj_iframe.frameborder='0';
			providerObj_iframe.style.backgroundColor='#FFF';
			providerObj_iframe.src = 'about:blank';
			contentDiv.appendChild(providerObj_iframe);
			providerObj_iframe.style.left = '0px';
			providerObj_iframe.style.top = '0px';
		}
	}
	providerObj.style.display='block';
	loadContent('providerpop',externalFile);
	if(providerObj_MSIE){
		providerObj_iframe.style.width = providerObj.clientWidth + 'px';
		providerObj_iframe.style.height = providerObj.clientHeight + 'px';
	}
	positionProviders(inputObj);
}

function hideProviders() {
	providerObj.style.display='none';
}

function showContent(divId,ajaxIndex,url) {
	document.getElementById(divId).innerHTML = ajaxObjects[ajaxIndex].response;
	if(enableCache){
		jsCache[url] = ajaxObjects[ajaxIndex].response;
	}
	ajaxObjects[ajaxIndex] = false;
}

function loadContent(divId,url) {
	if(enableCache && jsCache[url]){
		document.getElementById(divId).innerHTML = jsCache[url];
		return;
	}
	var ajaxIndex = ajaxObjects.length;
	document.getElementById(divId).innerHTML = '<img src="http://www.aolcdn.com/ch_movies/please_wait_indicator" /><br>Loading content - please wait a moment...';
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = url;
	ajaxObjects[ajaxIndex].onCompletion = function(){ showContent(divId,ajaxIndex,url); };
	ajaxObjects[ajaxIndex].runAJAX();
}

function showIncludeContent(divId,ajaxIndex,url) {
	var targetObj = document.getElementById(divId);
	targetObj.innerHTML = ajaxObjects[ajaxIndex].response;
	if(enableCache){
		jsCache[url] = ajaxObjects[ajaxIndex].response;
	}
	ajaxObjects[ajaxIndex] = false;
}

function includeContent(divId,url) {
	if(enableCache && jsCache[url]){
		document.getElementById(divId).innerHTML = jsCache[url];
		return;
	}
	var ajaxIndex = ajaxObjects.length;
	document.getElementById(divId).innerHTML = '<img src="http://www.aolcdn.com/ch_movies/please_wait_indicator" /><br>Loading content - please wait a moment...';
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = url;
	ajaxObjects[ajaxIndex].onCompletion = function(){ showIncludeContent(divId,ajaxIndex,url); };
	ajaxObjects[ajaxIndex].runAJAX();
}

function positionProviders(inputObj) {
	var leftPos = (getLeftPos(inputObj) + inputObj.offsetWidth);
	var topPos = getTopPos(inputObj);
	providerObj.style.left = leftPos + 'px';
	providerObj.style.top = topPos + 'px';
}

function getTopPos(inputObj) {
	var topValue = 0;
	if (inputObj.offsetParent) {
		while (inputObj.offsetParent) {
			topValue += inputObj.offsetTop
			inputObj = inputObj.offsetParent;
		}
	} else if (inputObj.y) topValue += inputObj.y;
	return topValue;
}

function getLeftPos(inputObj) {
	var leftValue = 0;
	if (inputObj.offsetParent) {
		while (inputObj.offsetParent) {
			leftValue += inputObj.offsetLeft
			inputObj = inputObj.offsetParent;
		}
	} else if (inputObj.x) leftValue += inputObj.x;
	return leftValue;
}

//trri module
function handleFormAjax (thisform,formhandler) {
    var formdata = "";
    try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) { alert("Error: Could not load page.");}
    for (i=0; i < thisform.length; i++)  {
         if (thisform.elements[i].type == "textarea" || thisform.elements[i].type == "hidden") {
                  formdata = formdata + thisform.elements[i].name + "=" + escape(thisform.elements[i].value) + "&";
         }
    }
    //Send Ajax Request
    xmlhttp.onreadystatechange = function() {
               if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
                      document.getElementById("trricomments").innerHTML = xmlhttp.responseText;
               }
    }
    xmlhttp.open("POST", formhandler);
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.send(formdata);
    return false;
}

// mini sns pop up for tirri
function snsPop () {
 	pSNS = getEl("snsMiniUI");
	pSNS.innerHTML = "";
	pSNS.innerHTML = _sns_var_;
	pSNS.style.display = 'block';
 	pSNS.style.position = 'relative';
	pSNS.style.left = 375;
	pSNS.style.top = -225;
	pSNS.style.zIndex = 1000;
}

function getSelectedValue( selObj ){
	return selObj.options[selObj.selectedIndex].value;
}

function getEl( id ){
    return document.getElementById( id );
}

/* Simple AJAX Code-Kit (SACK) v1.6.1 */
/* ?2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence, see documentation or authors website for more details */
function sack(file) {
	this.xmlhttp = null;
	this.resetData = function() {
		this.method = "GET";
  		this.queryStringSeparator = "&";
		this.argumentSeparator = "";
		this.URLString = "";
		this.encodeURIString = true;
  		this.execute = false;
  		this.element = null;
		this.elementObj = null;
		this.requestFile = file;
		this.vars = new Object();
		this.responseStatus = new Array(2);
  	};

	this.resetFunctions = function() {
  		this.onLoading = function() { };
  		this.onLoaded = function() { };
  		this.onInteractive = function() { };
  		this.onCompletion = function() { };
  		this.onError = function() { };
		this.onFail = function() { };
	};

	this.reset = function() {
		this.resetFunctions();
		this.resetData();
	};

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				this.xmlhttp = null;
			}
		}

		if (! this.xmlhttp) {
			if (typeof XMLHttpRequest != "undefined") {
				this.xmlhttp = new XMLHttpRequest();
			} else {
				this.failed = true;
			}
		}
	};

	this.setVar = function(name, value){
		this.vars[name] = Array(value, false);
	};

	this.encVar = function(name, value, returnvars) {
		if (true == returnvars) {
			return Array(encodeURIComponent(name), encodeURIComponent(value));
		} else {
			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
		}
	}

	this.processURLString = function(string, encode) {
		encoded = encodeURIComponent(this.argumentSeparator);
		regexp = new RegExp(this.argumentSeparator + "|" + encoded);
		varArray = string.split(regexp);
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split("=");
			if (true == encode){
				this.encVar(urlVars[0], urlVars[1]);
			} else {
				this.setVar(urlVars[0], urlVars[1]);
			}
		}
	}

	this.createURLString = function(urlstring) {
		if (this.encodeURIString && this.URLString.length) {
			this.processURLString(this.URLString, true);
		}

		if (urlstring) {
			if (this.URLString.length) {
				this.URLString += this.argumentSeparator + urlstring;
			} else {
				this.URLString = urlstring;
			}
		}

		// prevents caching of URLString
		this.setVar("rndval", new Date().getTime());

		urlstringtemp = new Array();
		for (key in this.vars) {
			if (false == this.vars[key][1] && true == this.encodeURIString) {
				encoded = this.encVar(key, this.vars[key][0], true);
				delete this.vars[key];
				this.vars[encoded[0]] = Array(encoded[1], true);
				key = encoded[0];
			}

			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
		}
		if (urlstring){
			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
		} else {
			this.URLString += urlstringtemp.join(this.argumentSeparator);
		}
	}

	this.runResponse = function() {
		eval(this.response);
	}

	this.runAJAX = function(urlstring) {
		if (this.failed) {
			this.onFail();
		} else {
			this.createURLString(urlstring);
			if (this.element) {
				this.elementObj = document.getElementById(this.element);
			}
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
					try {
						this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
					} catch (e) { }
				}

				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState) {
						case 1:
							self.onLoading();
							break;
						case 2:
							self.onLoaded();
							break;

						case 3:
							self.onInteractive();
							break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;

							if (self.execute) {
								self.runResponse();
							}

							if (self.elementObj) {
								elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input"
								|| elemNodeName == "select"
								|| elemNodeName == "option"
								|| elemNodeName == "textarea") {
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							if (self.responseStatus[0] == "200") {
								self.onCompletion();
							} else {
								self.onError();
							}

							self.URLString = "";
							break;
					}
				};

				this.xmlhttp.send(this.URLString);
			}
		}
	};

	this.reset();
	this.createAJAX();
}

// ActiveX patch for IE/IE7
function FlashTag(src, width, height, version) {
    if (arguments.length < 4)
    {
        throw new Exception('RequiredAttributeException',
                            'You must pass in a src, width, height, and version when creating a FlashTag.');
    }

    for (var i = 0; i < arguments.length; ++i)
    {
        if (arguments[i] == undefined || arguments[i] == null)
        {
            throw new Exception('RequiredAttributeException',
                                'All constructor arguments must have values.');
        }
    }

    // Required
    this.src            =  src;
    this.width          =  width;
    this.height         =  height;
    this.version        =  version;

    this.id             =  null;
    this.flashVars      =  null;
    this.flashVarsStr   =  null;
    this.genericParam   = new Object();
    this.ie = (navigator.appName.indexOf ("Microsoft") != -1) ? 1 : 0;
}
FlashTag.prototype.setSource = function(src) {
    this.src = src;
}
FlashTag.prototype.setWidth = function(w) {
    this.width = width;
}
FlashTag.prototype.setHeight = function(h) {
    this.h = height;
}
FlashTag.prototype.setVersion = function(v) {
    this.version = v;
}
FlashTag.prototype.setId = function(id) {
    this.id = id;
}
FlashTag.prototype.setBgcolor = function(bgc) {
    if (bgc.charAt(0) != '#') bgc = '#' + bgc;
    this.genericParam['bgcolor'] = bgc;
}
FlashTag.prototype.addFlashVars = function(fvs) {
    this.flashVarsStr = fvs;
}
FlashTag.prototype.addFlashVar = function(n, v) {
    if (this.flashVars == null) this.flashVars = new Object();
    this.flashVars[n] = v;
}
FlashTag.prototype.removeFlashVar = function(n) {
    if (this.flashVars != null) this.flashVars[n] = undefined;
}
FlashTag.prototype.setSwliveconnect = function(swlc) {
    this.genericParam['swliveconnect'] = swlc;
}
FlashTag.prototype.setPlay = function(p) {
    this.genericParam['play'] = p;
}
FlashTag.prototype.setLoop = function(l) {
    this.genericParam['loop'] = l;
}
FlashTag.prototype.setMenu = function(m) {
    this.genericParam['menu'] = m;
}
FlashTag.prototype.setQuality = function(q) {
    if (q != 'low' && q != 'high' && q != 'autolow' && q != 'autohigh' && q != 'best')
    {
        throw new Exception('UnsupportedValueException',
                            'Supported values are "low", "high", "autolow", "autohigh", and "best".');
    }
    this.genericParam['quality'] = q;
}
FlashTag.prototype.setScale = function(sc) {
    if (sc != 'showall' && sc != 'noborder' && sc != 'exactfit' && sc != 'noscale')
    {
        throw new Exception('UnsupportedValueException',
                            'Supported values are "showall", "noborder", "exactfit, and "noscale".');
    }
    this.genericParam['scale'] = sc;
}
FlashTag.prototype.setAlign= function(a) {
    if (a != 'l' && a != 't' && a != 'r' && a != 'b')
    {
        throw new Exception('UnsupportedValueException',
                            'Supported values are "l", "t", "r" and "b".');
    }
    this.genericParam['align'] = a;
}
FlashTag.prototype.setSalign= function(sa) {
    if (sa != 'l' && sa != 't' && sa != 'r' && sa != 'b' && sa != 'tl' && sa != 'tr' && sa != 'bl' && sa != 'br')
    {
        throw new Exception('UnsupportedValueException',
                            'Supported values are "l", "t", "r", "b", "tl", "tr", "bl" and "br".');
    }
    this.genericParam['salign'] = sa;
}
FlashTag.prototype.setWmode = function(wm) {
    if (wm != 'window' && wm != 'opaque' && wm != 'transparent')
    {
        throw new Exception('UnsupportedValueException',
                            'Supported values are "window", "opaque", and "transparent".');
    }
    this.genericParam['wmode'] = wm;
}
FlashTag.prototype.setBase = function(base) {
    this.genericParam['base'] = base;
}
FlashTag.prototype.toString = function() {
    var flashTag = new String();
    if (this.ie)
    {
        flashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
        if (this.id != null)
        {
            flashTag += 'id="'+this.id+'" ';
        }
        flashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this.version+'" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'">';
        flashTag += '<param name="movie" value="'+this.src+'"/>';

        for (var n in this.genericParam)
        {
            if (this.genericParam[n] != undefined && this.genericParam[n] != null)
            {
                flashTag += '<param name="'+n+'" value="'+this.genericParam[n]+'"/>';
            }
        }

        if (this.flashVars != null)
        {
            var fv = this.getFlashVarsAsString();
            if (fv.length > 0)
            {
                flashTag += '<param name="flashvars" value="'+fv+'"/>';
            }
        }
        flashTag += '</object>';
    }
    else
    {
        flashTag += '<embed src="'+this.src+'"';
        flashTag += ' width="'+this.width+'"';
        flashTag += ' height="'+this.height+'"';
        flashTag += ' type="application/x-shockwave-flash"';
        if (this.id != null)
        {
            flashTag += ' name="'+this.id+'"';
        }

        for (var n in this.genericParam)
        {
            if (this.genericParam[n] != undefined && this.genericParam[n] != null)
            {
                flashTag += (' '+n+'="'+this.genericParam[n]+'"');
            }
        }
        if (this.flashVars != null || this.flashVarsStr != null)
        {
            var fv = this.getFlashVarsAsString();
            if (fv.length > 0)
            {
                flashTag += ' flashvars="'+fv+'"';
            }
        }
        flashTag += ' pluginspage="http://www.macromedia.com/go/getflashplayer">';
        flashTag += '</embed>';
    }
    return flashTag;
}
FlashTag.prototype.write = function(doc) {
    doc.write(this.toString());
}
FlashTag.prototype.getFlashVarsAsString = function() {
    var qs = new String();
    for (var n in this.flashVars)
    {
        if (this.flashVars[n] != undefined && this.flashVars[n] != null)
        {
            qs += (escape(n)+'='+escape(this.flashVars[n])+'&');
        }
    }

    if (this.flashVarsStr != null) return qs + this.flashVarsStr;

    return qs.substring(0, qs.length-1);
}
FlashTag.prototype.setParams = function( id, bgc, fvs, swlc, p, l, m, q, sc, a, wm, base ) {
    if (id != null) this.id             =  id;
    if (fvs != null) this.flashVarsStr   =  fvs;

    if (bgc != null) this.setBgcolor(bgc);
    if (swlc != null) this.setSwliveconnect(swlc);
    if (p != null) this.setPlay(p);
    if (l != null) this.setLoop(l);
    if (m != null) this.setMenu(m);
    if (q != null) this.setQuality(q);
    if (sc != null) this.setScale(sc);
    if (a != null) this.setAlign(a);
    if (wm != null) this.setWmode(wm);
    if (base != null) this.setBase(base);
}
function writeOnLoad() {
         try {
                 if ( flashTagParams != undefined ) {
                         var tag =  new FlashTag(flashTagParams.src, flashTagParams.width, flashTagParams.height, flashTagParams.version );
                         document.write(tag.toString());
                 }
         } catch(ex) {
                // Do nothing
         }
}
writeOnLoad();


/* Tags ToolTip */

var tooltip = {

  show: function(caller, tipid) {
    document.getElementById(tipid).style.display = "block";
    },
  hide: function(caller, tipid){ 
    document.getElementById(tipid).style.display = "none"
    }

};

/* */

/* utility panel test*/
//============================================================================//
//============================ UTILITY PANEL==================================//

//tabbed support for modules
// tab persistence set to NO
var tabPersistence=0 
var tabContentIDs=new Object()

function expandContent(linkobj){
   var ulid=linkobj.parentNode.parentNode.id
   var ullist=document.getElementById(ulid).getElementsByTagName("li")
   for (var i=0; i<ullist.length; i++){
      ullist[i].className=""
         if (typeof tabContentIDs[ulid][i]!="undefined")
      document.getElementById(tabContentIDs[ulid][i]).style.display="none"
   }
   linkobj.parentNode.className="selected"
   document.getElementById(linkobj.getAttribute("rel")).style.display="block"
   saveSelectedTabContentID(ulid, linkobj.getAttribute("rel"))
}

function expandTab(tabcontentid, tabnumber) {
   var thetab=document.getElementById(tabcontentid).getElementsByTagName("a")[tabnumber]
      if (thetab.getAttribute("rel"))
         expandContent(thetab)
}

function saveTabContentIDs(ulid, relattribute){
   if (typeof tabContentIDs[ulid]=="undefined")
      tabContentIDs[ulid]=new Array()
      tabContentIDs[ulid][tabContentIDs[ulid].length]=relattribute
}

function saveSelectedTabContentID(ulid, selectedtabid){
   if (tabPersistence==1)
      setTabCookie(ulid, selectedtabid)
}

function getULbyID(ulid, tabcontentid){
   var ullist=document.getElementById(ulid).getElementsByTagName("li")
   for (var i=0; i<ullist.length; i++){
      if (ullist[i].getElementsByTagName("a")[0].getAttribute("rel")==tabcontentid){
         return ullist[i].getElementsByTagName("a")[0]
      break
      }
   }
}

function initTabContent() {
   for (var i=0; i<arguments.length; i++){
   if (tabPersistence==0 && getTabCookie(arguments[i])!="")
   setTabCookie(arguments[i], "")
      var clickedontab=getTabCookie(arguments[i])
      var ulobj=document.getElementById(arguments[i])
      var ulist=ulobj.getElementsByTagName("li")
      for (var x=0; x<ulist.length; x++){
         var ulistlink=ulist[x].getElementsByTagName("a")[0]
         if (ulistlink.getAttribute("rel")){
            saveTabContentIDs(arguments[i], ulistlink.getAttribute("rel"))
            ulistlink.onclick=function(){
            expandContent(this)
         return false
      }
      if (ulist[x].className=="selected" && clickedontab=="")
         expandContent(ulistlink)
      }
   }
   if (clickedontab!="") {
   var culistlink=getULbyID(arguments[i], clickedontab)
   if (typeof culistlink!="undefined")
      expandContent(culistlink)
         else
            expandContent(ulist[0].getElementsByTagName("a")[0])
      }
   }
}

function getTabCookie(Name) { 
   var re=new RegExp(Name+"=[^;]+", "i");
   if (document.cookie.match(re))
   return document.cookie.match(re)[0].split("=")[1]
   return ""
}

function setTabCookie(name, value) {
   document.cookie = name+"="+value
}



/**
 * Utility Panel Object
 **/
var upanel = {
		sendAim: function (pageurl){
		    // need hyperlink
		    // var _message = "Check out &lt\;a href=\"http:\/\/music.aol.com\/artist\/\"" + artist + "\/" + aolId + "\"&gt\;" + artist + ":  http:\/\/music.aol.com\/artist\/" + artist + "\/" + aolId + "&lt\;\/a&gt\;";
		     var _message = "Check out " + pageurl;
		     window.location = 'aim:GoIm?message=' + _message;
		},
    
    
    /** * Aol Bookmarks */
   myAol: function() {
   
     var url = "http://favorites.my.aol.com/ffclient/AddBookmark?"; 
     url += "title=" + encodeURIComponent(document.title) + "&"; 
     url += "url=" + encodeURIComponent(location.href) + "&"; 
     url += "favelet=true"; 
     var _706 = "scrollbars=0,resizable=1,width=756,height=661,directories=0,menubar=0,location=0,status=0,toolbar=0"; 
     var _707 = (new Date).getTime(); 
     open(url, "addAolBookmark" + _707, _706); 
     setTimeout("window.blur();", 0);
   
   }, 

 
    // send e-mail using mailto
		// Called from movie/mail/utilPan_email
		sendEmail: function(pageURL) {
		  var bolSend = true;
		  var oShareForm = document.forms.email_form;
		  var shFromName = oShareForm.inputYourName.value;
		  //  var shFromName = "";
		  if ( shFromName == "" ) {shFromName = "Your%20Friend"}
		  var shFromEmail = oShareForm.inputYourEmail.value;
		  var shToEmail = oShareForm.inputFriendEmail.value;
		  if ( (shToEmail == "") || (shToEmail == "Enter your friend's email address") ) {
		    alert("Please enter a destination email address.");
		    oShareForm.inputFriendEmail.focus();
		    bolSend = false;
		  }
		  //  var shMsg = oShareForm.personal_message.value;
		  
		  var strMailto = "mailto:";
		  strMailto += shToEmail + "?";
		  strMailto += "&from=" + shFromEmail;
		  strMailto += "&subject=" + shFromName + "%20has%20sent%20you%20a%20Moviefone%20Page";
		  strMailto += "&body=" + pageURL + "%0D%0D" ; //+ shMsg;
		  
		  if (bolSend) { document.location.href = strMailto; };
		},   
   
    // GPL'd courtesy of http://www.jeffothy.com/weblog/clipboard-copy
		// Needs swf file at <cannae.asset_url>/ch_music2/_clipboard.swf
		copyElToClip: function(el, swf ) {
		    var field = document.createElement("textarea");
		    field.appendChild(document.createTextNode(dojo.dom.textContent(el)) );
		    copyFieldToClip(field, swf )
		}, 
		
		copyFieldToClip: function(el, swf ) {
		    console.debug(el + " value: ", el.value);
		    if (el.createTextRange) {
		        var range = el.createTextRange();
		        if (range) range.execCommand('Copy');
		    } else {
		        var flashcopier = 'flashcopier';
		        if(!getEl(flashcopier)) {
		            var divholder = document.createElement('div');
		            divholder.id = flashcopier;
		            document.body.appendChild(divholder);
		        }
		        getEl(flashcopier).innerHTML = '';
		        var divinfo = '<embed src="'+swf+'" FlashVars="clipboard='+escape(el.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
		        getEl(flashcopier).innerHTML = divinfo;
		    }
		}
    
        
};

//============================================================================//
//============================ HUB MOUSE OVER ================================//

if (ovrStte == null || typeof(ovrStte) != "object") var ovrStte = {};
ovrStte.init = function(idToInit, classToFind, onStateName) {
    // add vars to object for later reference
    ovrStte.onStateName = onStateName;
    ovrStte.classToFind = classToFind;
    ovrStte.idToInit = idToInit;

    var divLst = document.getElementById(idToInit).getElementsByTagName('div')

    for (i=0; i<divLst.length; i++) {

        var tstClass = divLst[i].className.split(' ')[0];

        if ( tstClass == classToFind ) {
            divLst[i].onmouseover = ovrStte.onState;
            divLst[i].onmouseout = ovrStte.offState;
        }
    }
}// end Init Function
ovrStte.onState = function() {
    var classNameArry = this.className.split(' ');
    if (classNameArry[1] == null) {
        this.className = ovrStte.onStateName
    } else {
        this.className = ovrStte.onStateName + " " + classNameArry[1];
    }
}
ovrStte.offState = function() {
    var classNameArry = this.className.split(' ');
    if (classNameArry[1] == null) {
        this.className = ovrStte.classToFind
    } else {
        this.className = ovrStte.classToFind + " " + classNameArry[1];
    }
}

ovrStte.lstInit = function(idToInit, classForOn, classForOff) {
    ovrStte.classForOn = classForOn;
    ovrStte.classForOff = classForOff;
    ovrStte.idToInit = idToInit;

    var tableRowLst = document.getElementById(idToInit).getElementsByTagName('tr')
    for (i=0; i<tableRowLst.length;i++) {
        if (tableRowLst[i].className != "tableHeaders") {
        tableRowLst[i].onmouseover = ovrStte.lstOnState;
        tableRowLst[i].onmouseout = ovrStte.lstOffState;
        }
    }
}
ovrStte.lstOnState = function() {
    this.className = ovrStte.classForOn
}
ovrStte.lstOffState = function() {
    this.className = ovrStte.classForOff
}



/* Utility Collapse / Hide Module */

var collapsethis = {

  show: function(caller, id) {
    document.getElementById(id).style.display = "block";
    },
  hide: function(caller, id){ 
    document.getElementById(id).style.display = "none";
    },
  change: function(hidethis,showthis) {
            hideDiv(hidethis);
            showDiv(showthis);
  }
};


//tabbed support for modules
var tabPersistence=0 // do not remember tab selection
var tabContentIDs=new Object()

function expandContent(linkobj){
  var ulid=linkobj.parentNode.parentNode.id
  var ullist=document.getElementById(ulid).getElementsByTagName("li")
  for (var i=0; i<ullist.length; i++){
    ullist[i].className=""
      if (typeof tabContentIDs[ulid][i]!="undefined")
    document.getElementById(tabContentIDs[ulid][i]).style.display="none"
  }
  linkobj.parentNode.className="selected"
  document.getElementById(linkobj.getAttribute("rel")).style.display="block"
  saveSelectedTabContentID(ulid, linkobj.getAttribute("rel"))
}

function expandTab(tabcontentid, tabnumber) {
  var thetab=document.getElementById(tabcontentid).getElementsByTagName("a")[tabnumber]
    if (thetab.getAttribute("rel"))
      expandContent(thetab)
}

function saveTabContentIDs(ulid, relattribute){
  if (typeof tabContentIDs[ulid]=="undefined")
    tabContentIDs[ulid]=new Array()
    tabContentIDs[ulid][tabContentIDs[ulid].length]=relattribute
}

function saveSelectedTabContentID(ulid, selectedtabid){
  if (tabPersistence==1)
    setTabCookie(ulid, selectedtabid)
}

function getULbyID(ulid, tabcontentid){
  var ullist=document.getElementById(ulid).getElementsByTagName("li")
  for (var i=0; i<ullist.length; i++){
    if (ullist[i].getElementsByTagName("a")[0].getAttribute("rel")==tabcontentid){
      return ullist[i].getElementsByTagName("a")[0]
    break
    }
  }
}

function initTabContent() {
  for (var i=0; i<arguments.length; i++){
  if (tabPersistence==0 && getTabCookie(arguments[i])!="")
  setTabCookie(arguments[i], "")
    var clickedontab=getTabCookie(arguments[i])
    var ulobj=document.getElementById(arguments[i])
    var ulist=ulobj.getElementsByTagName("li")
    for (var x=0; x<ulist.length; x++){
      var ulistlink=ulist[x].getElementsByTagName("a")[0]
      if (ulistlink.getAttribute("rel")){
        saveTabContentIDs(arguments[i], ulistlink.getAttribute("rel"))
        ulistlink.onclick=function(){
        expandContent(this)
      return false
    }
    if (ulist[x].className=="selected" && clickedontab=="")
      expandContent(ulistlink)
    }
  }
  if (clickedontab!="") {
  var culistlink=getULbyID(arguments[i], clickedontab)
  if (typeof culistlink!="undefined")
    expandContent(culistlink)
      else
        expandContent(ulist[0].getElementsByTagName("a")[0])
    }
  }
}

function getTabCookie(Name) {
  var re=new RegExp(Name+"=[^;]+", "i");
  if (document.cookie.match(re))
  return document.cookie.match(re)[0].split("=")[1]
  return ""
}

function setTabCookie(name, value) {
  document.cookie = name+"="+value
}

function addLoadEvent(f) {
    var old = window.onload;
    if (typeof old != 'function') window.onload = f
    else { window.onload = function() { old(); f() }} }
// how to call add load event addLoadEvent(function(){ enhanced.mummygame() });


//check quicktime version
function checkQuickTimeVersion(){
	
	var objQTCheck = 0;
	var versionQT_d;
	var versionQT_str;
	var versionQT_substr;
	var versionQT;

	if(navigator.appName=="Microsoft Internet Explorer"){
		try {
			objQTCheck = new ActiveXObject("QuickTimeCheckObject.QuickTimeCheck");
		}
		catch (e) {
			return 0;
		}

		if (objQTCheck){
			versionQT_d = objQTCheck.QuickTimeVersion.toString(16);
			versionQT_str = versionQT_d.toString();
			versionQT_substr = versionQT_str.substring(0,2);
			versionQT = versionQT_substr;
			return versionQT;
		}else {return 0;}

	}else if(navigator.plugins && navigator.plugins.length){
		for(i=0; i<navigator.plugins.length; i++) {
			if (navigator.plugins[i].name.indexOf("QuickTime") >= 0) {
				versionQT_str = navigator.plugins[i].name.substring(18,22);
				versionQT_substr = versionQT_str.replace(/\./g,"");
				versionQT = parseInt(versionQT_substr);
								
				return versionQT;
			}
		}
												
		return 0;
	}	
}
//end of check quicktime version

/* Utility Text Areas / Limit Number of characters entered */

var checklength = {

  textarea: function(obj) {
	// Check if we have words longer then xx chars to break them up.
	    maxlongchar = 68;//Always an even number.
	    var objText = obj.value;
	    var regStrLength = new RegExp("([^\\s]{" + maxlongchar + "})", "i");
	    var ar = regStrLength.exec(objText);
	    if (ar) {
	        var longWord = obj.value.substring(ar.index, ar.index + maxlongchar + 1);
	        var halfWordLength = maxlongchar / 2;
	        var firstHalf = longWord.substring(0, halfWordLength - 1);
	        var lastHalf = longWord.substring(halfWordLength - 1, maxlongchar - 1);
	        var newWord = firstHalf + "- " + lastHalf;
	        objText = objText.replace(longWord, newWord);
	        obj.value = objText;
	    }
	    var maxLength = obj.getAttribute("maxlength");
	    var currentLength = obj.value.length;
	    if(obj.value=="Type your comment here"||obj.value=="Type your review here"){
	    	currentLength = 0;
	    }
	    if (currentLength > maxLength) {
	        obj.value = obj.value.substring(0, maxLength);
			currentLength = maxLength;
	    }
	    var counter = getEl(obj.getAttribute("counter"));
	    counter.firstChild.nodeValue = (currentLength) + "/" + maxLength;
	    // not innerHTML
  }
};
var txtObjId;
function checklengthWait(fldId){
	txtObjId = fldId;
	setTimeout("callCheckLength()",1);
}
function callCheckLength(){
	checklength.textarea(txtObjId);
}
/*for relegence module*/
var curTab;
function SetTab(tab){
	curTab.className = "";
	tab.className = "cur";
	curTab = tab;
	var storyArr = document.getElementById("stories").getElementsByTagName("li");
	for(t=0;t<=storyArr.length;t++){
		if((storyArr[t].value==tab.value)||tab.value=="999"){
			storyArr[t].style.display = "";
		}else{
			storyArr[t].style.display = "none";
		}
	}
	
}
function openNewsWindow(url)
{
	newsWin=window.open(url,'newsWin');
}
function showTabs(){
	var storiesArr = document.getElementById("stories").getElementsByTagName("li");
	for(t=0;t<=storiesArr.length;t++){
		if(storiesArr[t].value=="3000"){
			document.getElementById("aaa").style.display = "";
		}
		if(storiesArr[t].value=="3002"){
			document.getElementById("ccc").style.display = "";
		}
	}
				
}


/*homepage js functions*/
function checkZipBox(zip){
	if(zip.value=="Enter Your ZIP Code"){ 
		document.getElementById("errorMsg").innerHTML = "Incorrect ZIP code. Please try again.";
		zip.style.color="#ab1717";	
		return false;
	}
	else if(zip.value.length < 5){ 
		document.getElementById("errorMsg").innerHTML = "Incorrect ZIP code. Please try again.";
		zip.style.color="#ab1717";	
		return false;
	}
	else{
		document.changeLocation.submit();
	}
}

var mf_popup_timeout = 500;
var closetimer	= 0;
var mf_popup_box = 0;

function mf_popup_open(control,id,moviePoster,movieStatus,movieTitle,movieTitleNorm,movieRuntime,movieId,host,movieRating,status,checkShow,checkTrailer,trailerLink)
{	
	mf_popup_cancel();
	mf_popup_box = document.getElementById(id);
	mf_popup_box.style.opacity=0;
	mf_popup_box.style.display='block';
	mf_popup_box.style.left=(getLeftPos(control)-276)+'px';
	mf_popup_box.style.top=(getTopPos(control)-90)+'px';
	mf_popup_box.style.zIndex ='9999999';
	var dimsImage = moviePoster;
	document.getElementById("moviePoster").src= dimsImage;
	document.getElementById("movieTitle").innerHTML= movieTitle;
	
	var runInfo ="";
	if(movieRating!=""){ runInfo = movieRating; }
	if((movieRuntime!="") && (movieRating!="")){ runInfo = runInfo + ", "; }
	if(movieRuntime!=""){runInfo = runInfo + movieRuntime; }
	document.getElementById("movieRuntime").innerHTML= runInfo;
	
	if(checkShow > 0){
		var showTimeLink = "/movie/" + movieTitleNorm + "/" + movieId + "/showtimes";
		document.getElementById("movieShowLink").href = host + showTimeLink;
		document.getElementById("movieShowLink").style.display="block";
	}else{
		document.getElementById("movieShowLink").style.display="none";
		document.getElementById("movieShowLink").href ="";
		mf_popup_box.style.top=(getTopPos(control)-80)+'px';
	}
	
	if(checkTrailer > 0){
		var trailerLink = trailerLink;
		document.getElementById("movieTrailerLink").href = trailerLink;
		document.getElementById("movieTrailerLink").style.display="block";
	}else{
		document.getElementById("movieTrailerLink").style.display="none";
		document.getElementById("movieTrailerLink").href ="";
		mf_popup_box.style.top=(getTopPos(control)-80)+'px';
	}
	
	if((checkTrailer <= 0) && (checkShow <= 0)){mf_popup_box.style.left=(getLeftPos(control)-266)+'px'; mf_popup_box.style.top=(getTopPos(control)-63)+'px';}
	
	var movieMainLink = "/movie/" + movieTitleNorm + "/" + movieId + "/main";
	document.getElementById("movieLink").href = host + movieMainLink;
	document.getElementById("movieLinkTitle").href = host + movieMainLink;
	document.getElementById("movieStatus").innerHTML = status;
	
}

function mf_popup_close()
{
	if(mf_popup_box) mf_popup_box.style.display = 'none';
}

function mf_popup_closetime()
{
	closetimer = window.setTimeout(mf_popup_close, mf_popup_timeout);
}

function mf_popup_cancel()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

var TimeToFade = 350;
function fadeIn(eid)
{
  var element = document.getElementById(eid);
  if(element == null)
    return;
    element.FadeState = 1;
    element.FadeTimeLeft = TimeToFade;
    setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
}

function animateFade(lastTick, eid)
{ 
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
  var element = document.getElementById(eid);
 
  if(element.FadeTimeLeft <= elapsedTicks)
  {
    element.style.opacity = element.FadeState == 1 ? '1' : '0';
    element.style.filter = 'alpha(opacity = ' + (element.FadeState == 1 ? '100' : '0') + ')';
    element.FadeState = element.FadeState == 1 ? 2 : -2;
    return;
  }
  element.FadeTimeLeft -= elapsedTicks;
  var newOpVal = element.FadeTimeLeft/TimeToFade;
  if(element.FadeState == 1)
  newOpVal = 1 - newOpVal;
  element.style.opacity = newOpVal;
  element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
  setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
} 


function iePNGhack(image){
	var img = document.getElementById(image);
	if(document.all){
		img.parentNode.style.height = "34px";
		img.parentNode.style.width = "18px";
		img.style.width = "18px";
		img.setAttribute("height", "34px");
		img.setAttribute("width", "18px");
		img.parentNode.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale src='" + img.src + "')";
	} else {
		img.style.visibility = "visible";
	}
}

function onRentDvdButtonClick(control,netflixLink, amazonDvd, amazonSoundtrack) {
   showDiv('rentBuyDvdPopup');
   document.getElementById('rentBuyDvdPopup').style.left=(getLeftPos(control)+98)+'px';
   document.getElementById('rentBuyDvdPopup').style.top=(getTopPos(control)+25)+'px';
   // Dont show the netflix link if its not there
   if((netflixLink == null) || (netflixLink == '')) {
	 hideDiv('theNetflix');
	 hideDiv('rentDvdNetflixPopupLinkDiv');
     hideDiv('rentDvdNetflixPopupImgLinkDiv');
   } else {
	 showDiv('theNetflix');
     showDiv('rentDvdNetflixPopupLinkDiv');
     showDiv('rentDvdNetflixPopupImgLinkDiv');
     document.getElementById('rentDvdNetflixPopupLink').href=netflixLink;
     document.getElementById('rentDvdNetflixPopupImgLink').href=netflixLink;
   }
   document.getElementById('rentDvdAolShoppingPopupLink').href=amazonDvd;
   document.getElementById('rentDvdAolShoppingPopupImgLink').href=amazonDvd;
   
   if(amazonSoundtrack){
	   document.getElementById("soundtrackAmazon").style.display ="block";
	   document.getElementById("soundtrackTd").style.padding= "4px 0 4px 1px";
	   document.getElementById('buyAmazonSoundtrackLink').href=amazonSoundtrack;
   	   document.getElementById('buyAmazonSoundtrackLink').href=amazonSoundtrack;
   }else{
	   document.getElementById("soundtrackAmazon").style.display ="none";
	   document.getElementById("soundtrackTd").style.border= "none";
	   document.getElementById("soundtrackTd").style.padding= "0";
   }
   
}

function nextBucket(num,pageNumValue){
   	
   	if(num==0){
   		document.getElementById("bucket0").style.display = "block";
   		if(document.getElementById("bucket5")){
   			document.getElementById("bucket5").style.display = "none";
   		}
   		if(document.getElementById("bucket10")){
   			document.getElementById("bucket10").style.display = "none";
   		}
   		document.getElementById("topCelebPageStatus").innerHTML = "1-5";
   		document.getElementById("arrow1").style.display = "block";
   		document.getElementById("arrow2").style.display = "none";
   		document.getElementById("arrow3").style.display = "none";
   		
   	}else if(num==5){
		
   		document.getElementById("bucket0").style.display = "none";
   		if(document.getElementById("bucket5")){
   			document.getElementById("bucket5").style.display = "block";
   		}
   		if(document.getElementById("bucket10")){
   			document.getElementById("bucket10").style.display = "none";
   		}
   		
   		document.getElementById("topCelebPageStatus").innerHTML = "6-10";
   		document.getElementById("arrow1").style.display = "none";
   		document.getElementById("arrow2").style.display = "block";
   		document.getElementById("arrow3").style.display = "none";
   	}
   	else if(num==10){
   		document.getElementById("bucket0").style.display = "none";
   		if(document.getElementById("bucket5")){
   			document.getElementById("bucket5").style.display = "none";
   		}
   		if(document.getElementById("bucket10")){
   			document.getElementById("bucket10").style.display = "block";
   		}
   		if(document.getElementById("topCelebPageStatus")){
   			document.getElementById("topCelebPageStatus").innerHTML = "11-"+pageNumValue;
   		}
   		document.getElementById("arrow1").style.display = "none";
   		document.getElementById("arrow2").style.display = "none";
   		document.getElementById("arrow3").style.display = "block";
   	}
   	
   	
}

function isPageNumeric(pagenum)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
   for (i = 0; i < pagenum.length && IsNumber == true; i++) 
      { 
      Char = pagenum.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         	IsNumber = false;
         }
      }
   return IsNumber;
   }

//Summer Movies Main Page Tabbed Calendar Module
function getCalendar(navId){
	var calendar_list = document.getElementById("calendarnavs");
    var calendar_elements = calendar_list.getElementsByTagName("li");
    var calendar_panels = document.getElementById("maincalendarpanel");
    var calendar_panel_elements = calendar_panels.getElementsByTagName("div");
    var transNavId = navId.toLowerCase();
    var newCalId = transNavId + "CalDiv";
    for(i=0; i < calendar_elements.length; i++) {
		calendar_elements[i].className = "notcurrent";
    }
    for(j=0; j < calendar_panel_elements.length; j++) {
	    if(calendar_panel_elements[j].className=="visibleCalDivs"){
			calendar_panel_elements[j].className = "hiddenCalDivs";
	    }
    }
    document.getElementById(navId).className = "iscurrent";
    document.getElementById(newCalId).className = "visibleCalDivs";
}
function initCalendar(){
	var calendar_list = document.getElementById("calendarnavs");
    var calendar_elements = calendar_list.getElementsByTagName("li");
    var currId;
    for(i=0; i < calendar_elements.length; i++) {
	    if(calendar_elements[i].className == "iscurrent"){
			currId = calendar_elements[i].id;
			break;
		}
    }
    getCalendar(currId);
}

//Quick Search
var Browser = {
	Version: function() {
	 	var version = 999; 
	    if (navigator.appVersion.indexOf("MSIE") != -1)
	    	version = parseFloat(navigator.appVersion.split("MSIE")[1]);
	    return version;
	}
}
var smartSrchMsg = "";
var prevSearchString = "";
var txtBox;
var isDropDown = false;
var loopInd=-1;
var resultItemId="";
var lastItemId = "";
var isNavigate = false;
var movPullDown = "";
var isPullDown = false;
var srchUl = "";
var srchLi = "";
function smartSearch(textBox, e) {
	txtBox = textBox;
	var keynum = "";
	if(window.event){
		keynum = e.keyCode;
	}
	else if(e.which){
		keynum = e.which;
	}
	if(keynum==40){
		if(isDropDown){
			if((loopInd+1)!=resultArr.length){
				loopInd++;
	            resultItemId = resultArr[loopInd].txt;
	           itemHover(document.getElementById(resultItemId));
				isNavigate = true;
			}
			
		}
	}
	if(keynum==38){
		if(isDropDown){
	   		if(loopInd!=0){
	           	loopInd--;
	           	resultItemId = resultArr[loopInd].txt;
	           	itemHover(document.getElementById(resultItemId));
				isNavigate = true;
	        }else{
				hideResults();
	        }
	 	} 				
	}
	if(keynum==13){
		if(isDropDown&&isNavigate){
			document.location.href=resultArr[loopInd].link;
		}else{
			return;
		}
	}
	var trimmedSearchString = textBox.value.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	if((trimmedSearchString.length > 0) && (trimmedSearchString != prevSearchString)) {
		prevSearchString = trimmedSearchString;
		new Ajax(smartSearchLinkBaseUrl + "/smartSearch.jsp?time=" + new Date().getTime() + "&query=" + escape(textBox.value), { method: 'get', onComplete: showResp}).request();
	    isDropDown = true;
		document.body.onclick = function(){hideResults();};
	} else if(trimmedSearchString.length == 0) {
		prevSearchString="";
	    hideResults();
	}
	
}
function hideResults(){
    document.getElementById("smartSearch").innerHTML = "";
    document.getElementById("smartSearch").className="hideresults";
    isDropDown = false;
    isNavigate = false;
    if (Browser.Version() < 7) {
    	document.getElementById("iebackground").style.display = "none";
    }
    document.body.onclick = "";
    if(isPullDown){
    	movPullDown.style.visibility="visible";
    }
}
var arrInd = 0;
var resultArr = new Array();
function resultObj(link, txt){
	this.link = link;
	this.txt = txt;
}
function showResp(request){
	isNavigate = false;
	resultArr = new Array();
	loopInd=-1;
	arrInd = 0;
	movPullDown = document.getElementById('moviepulldown');
	if(movPullDown.style.display!="none"){
		movPullDown.style.visibility = "hidden";
		isPullDown = true;
	}else{
	    isPullDown = false;
	}
    if(request.match("Theaters Near You")!=null){
    	document.getElementById('smartSearch').innerHTML = request + smartSrchMsg;
    }else{
    	document.getElementById('smartSearch').innerHTML = request;
    }
    srchUl = document.getElementById("smartsel");
    srchLi = srchUl.getElementsByTagName("li");
    var itemLink = "";
    var itemTxt = "";
    for(i=0;i<srchLi.length;i++){
    	if(srchLi[i].className=="srchitem"){
    		itemTxt = srchLi[i].id;
    		itemLink = srchLi[i].getElementsByTagName("a")[0].getAttribute("href");
    		resultArr[arrInd] = new resultObj(itemLink,itemTxt);
    		arrInd++;
    	}
    }
	if(srchLi.length!=0){
		document.getElementById("smartSearch").className="showresults";
		if (Browser.Version() < 7) {
		     document.getElementById("iebackground").style.display = "block";
		}
	}else{
		hideResults();
	}
}
function itemHover(item){
	for(x=0;x<srchLi.length;x++){
		if(srchLi[x].className=="srchitemhov"){
			srchLi[x].className = "srchitem";
		}
	}
	item.className = "srchitemhov";
	for(t=0;t<resultArr.length;t++){
		if(resultArr[t].txt==item.id){
			loopInd = t;
		}
	}

}

//showtimes
function toggleMovieInfoFlyout(flyoutUrl, divId, togg) {
	var divObject = document.getElementById(divId);	
	
	if(divObject.getElementsByTagName("img")[0] != undefined){
		
		if(divObject.getElementsByTagName("img")[0].id == "theloaderimg") {
			
			//new Ajax(flyoutUrl + "&time="+ new Date().getTime(), { method: 'get', update: $(divId)}).request();
			 dojo.xhrGet( { // 
			        // The following URL must match that used to test the server.
			        url: flyoutUrl + "&time="+ new Date().getTime(), 
			        handleAs: "text",
			        timeout: 5000, // Time in milliseconds
	
			        // The LOAD function will be called on a successful response.
			        load: function(response, ioArgs) { // 
			          dojo.byId(divId).innerHTML = response; // 
			          return response; // 
			        },
	
			        // The ERROR function will be called in an error case.
			        error: function(response, ioArgs) { // 
			          //console.error("HTTP status code: ", ioArgs.xhr.status); // 
			          return response; // 
			          }
			        });
	
			togg.className = "closetoggle opentoggle";
		} else {
			divObject.innerHTML = "";
			togg.className = "closetoggle";
		}
	}
}

function showHideZip(formOuterDivId, changeLocationOuterDivId){
	if(typeof formOuterDivId == 'undefined') {
		formOuterDivId = 'zipForm';
	}
	
	if(typeof changeLocationOuterDivId == 'undefined') {
		changeLocationOuterDivId = 'mflocation';
	}
	
	if((document.getElementById(formOuterDivId).style.display=="none")||(!document.getElementById(formOuterDivId).style.display)){
		document.getElementById(formOuterDivId).style.display = "block";
		document.getElementById(changeLocationOuterDivId).className = "opentoggle";
	}else{
		document.getElementById(formOuterDivId).style.display = "none";
		document.getElementById(changeLocationOuterDivId).className = "closetoggle";
	}
}

function swapLocationBox(div){
	if(div.getElementsByTagName("a")[0]){
		div.innerHTML = document.getElementById("zipForm").innerHTML;
		div.className = "changeform";
	}
}


var prevLocationInputText = '';
function onLocationInputChange(textBox, messageDivId, changeCountryLinkBaseUrl, isUseDojo) {
	var trimmedString = textBox.value.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	var messageDiv = document.getElementById(messageDivId);
	if(((trimmedString != prevLocationInputText) || (messageDiv.innerHTML == '')) && (trimmedString.match(/^\s*\d{5}\s*$/) || trimmedString.match(/^.*[abceghjklmnprstvxyABCEGHJKLMNPRSTVXY]{1}[0-9]{1}[a-zA-Z]{1}\s*[0-9]{1}[a-zA-Z]{1}[0-9]{1}.*$/))) {
		// always use dojo, since, mootools ajax doesnt work when mapquest map is on
		//if(isUseDojo) {
			dojo.xhrGet( { // 
		        // The following URL must match that used to test the server.
		        url: changeCountryLinkBaseUrl + "?time=" + new Date().getTime() + "&locationQuery=" + textBox.value, 
		        handleAs: "text",

		        timeout: 5000, // Time in milliseconds

		        // The LOAD function will be called on a successful response.
		        load: function(response, ioArgs) { // 
		          dojo.byId(messageDivId).innerHTML = response; // 
		          return response; // 
		        },

		        // The ERROR function will be called in an error case.
		        error: function(response, ioArgs) { // 
		          //console.error("HTTP status code: ", ioArgs.xhr.status); // 
		          return response; // 
		          }
		        });
		/*} else {
			new Ajax(changeCountryLinkBaseUrl + "?time=" + new Date().getTime() + "&locationQuery=" + textBox.value, { method: 'get', update: $(messageDivId)}).request();
		}*/
	} else if(trimmedString != prevLocationInputText) {
		messageDiv.innerHTML = "";
	}
	prevLocationInputText = trimmedString;
}


function removeDiv(divId) {
	if(divId != undefined) {
		var divObj = document.getElementById(divId);
		if(divObj != undefined) {
			divObj.parentNode.removeChild(divObj);
		}
	}
}

function removeFavTheaterHeaderShowtimesDivs(removeUrl, theaterId) {
	dojo.xhrGet( { // 
        // The following URL must match that used to test the server.
        url: removeUrl + "&returnResponseStatus=true&time=" + new Date().getTime(), 
        handleAs: "text",

        timeout: 5000, // Time in milliseconds

        // The LOAD function will be called on a successful response.
        load: function(response, ioArgs) { 
			if('success' == trimString(response)) {
				removeDiv('theater-' + theaterId + '-header');
				removeDiv('theater-' + theaterId + '-showtimes');
				
				if(document.getElementById("printlist").getElementsByTagName("div").length==0){
					document.getElementById("noFavLeftMsg").style.display = "block";
					document.getElementById("printlist").style.border= "0";
					document.getElementById("bottomHeadFav").style.display = "none";
					document.getElementById("foot-print").style.display = "none";
				}
				return response;
			}
        },

        // The ERROR function will be called in an error case.
        error: function(response, ioArgs) { // 
          //console.error("HTTP status code: ", ioArgs.xhr.status); // 
          return response; // 
          }
        });
}

function onFavoriteTheaterAdded(anchor, response, msgFly, favUrl, theaterId) {
	var resp = trimString(response);
	if('success' == resp) {
		anchor.className = 'removefav';
		anchor.innerHTML = 'Remove From Favorites';
		msgFly.innerHTML = '<div class="flycaret"></div>'
		msgFly.innerHTML += '<a href="javascript:void();" onclick="hideFavFlyout(\''+msgFly.id+'\');" class="closeButX"><img src="http://www.aolcdn.com/ch_movies/mf_show_xxx_14x14" /></a>';
		msgFly.innerHTML += '<p>You have just added this theater to your list of <span>Favorite Theaters</span>';
		msgFly.innerHTML += '<a href="'+favUrl+'/theaters/favorites">View All Your Favorite Theaters</a></p>';
		showFavFlyout(msgFly.id);
		
		if(document.getElementById("theFavHeartIcon"+theaterId)){
			document.getElementById("theFavHeartIcon"+theaterId).style.display = "inline";
		}else{
			if(document.getElementById("theaterItem"+theaterId)){ 
				var heartIcon = document.createElement("img");
				heartIcon.setAttribute("id", "theFavHeartIcon"+theaterId);
				heartIcon.setAttribute("src","http://o.aolcdn.com/art/ch_movies/ico_pp_heart");
				if(document.getElementById("theaterItem"+theaterId).parentNode.getElementsByTagName("h3")[0]){
					document.getElementById("theaterItem"+theaterId).parentNode.getElementsByTagName("h3")[0].appendChild(heartIcon);
				}
				if(document.getElementById("theaterItem"+theaterId).parentNode.getElementsByTagName("h1")[0]){
					document.getElementById("theaterItem"+theaterId).parentNode.getElementsByTagName("h1")[0].appendChild(heartIcon);
				}
			}
		}
		
	} else if(resp.length > 0) {
		window.document.location = resp;
	}
}

function onFavoriteTheaterRemoved(anchor, response, msgFly, favUrl,theaterId) {
	if('success' == trimString(response)) {
		anchor.className = 'addfav';
		anchor.innerHTML = 'Add to Favorites';
		msgFly.innerHTML = '<div class="flycaret"></div>'
		msgFly.innerHTML += '<a href="javascript:void();" onclick="hideFavFlyout(\''+msgFly.id+'\');" class="closeButX"><img src="http://www.aolcdn.com/ch_movies/mf_show_xxx_14x14" /></a>';
		msgFly.innerHTML += '<p>You have just removed this theater from your list of <span>Favorite Theaters</span>';
		//msgFly.innerHTML += '<a href="'+favUrl+'/theaters/favorites">View All Your Favorite Theaters</a></p>';
		showFavFlyout(msgFly.id);
		if(document.getElementById("theFavHeartIcon"+theaterId)){
			document.getElementById("theFavHeartIcon"+theaterId).style.display = "none";
		}
	}
}

function showFavFlyout(divid){
	document.getElementById(divid).style.display = "block";
}

function hideFavFlyout(divid){
	document.getElementById(divid).style.display = "none";
}

function addRemoveFavoriteTheater(addUrl, removeUrl, anchor, msgFly, favUrl,theaterId) {
	if(anchor) {
		if(anchor.className == 'addfav') {
			//new Ajax(addUrl + "&returnResponseStatus=true&time=" + new Date().getTime(), { method: 'get', onComplete: function(response) { onFavoriteTheaterAdded(anchor, response) }}).request();
			dojo.xhrGet( { // 
		        // The following URL must match that used to test the server.
		        url: addUrl + "&returnResponseStatus=true&time=" + new Date().getTime(), 
		        handleAs: "text",

		        timeout: 5000, // Time in milliseconds

		        // The LOAD function will be called on a successful response.
		        load: function(response, ioArgs) { // 
					onFavoriteTheaterAdded(anchor, response, msgFly, favUrl,theaterId); // 
					return response; // 
		        },

		        // The ERROR function will be called in an error case.
		        error: function(response, ioArgs) { // 
		          //console.error("HTTP status code: ", ioArgs.xhr.status); // 
		          return response; // 
		          }
		        });
		} else if(anchor.className == 'removefav') {
			//new Ajax(removeUrl + "&returnResponseStatus=true&time=" + new Date().getTime(), { method: 'get', onComplete: function(response) { onFavoriteTheaterRemoved(anchor, response) }}).request();
			dojo.xhrGet( { // 
		        // The following URL must match that used to test the server.
		        url: removeUrl + "&returnResponseStatus=true&time=" + new Date().getTime(), 
		        handleAs: "text",

		        timeout: 5000, // Time in milliseconds

		        // The LOAD function will be called on a successful response.
		        load: function(response, ioArgs) { // 
					onFavoriteTheaterRemoved(anchor, response, msgFly, favUrl,theaterId); // 
					return response; // 
		        },

		        // The ERROR function will be called in an error case.
		        error: function(response, ioArgs) { // 
		          //console.error("HTTP status code: ", ioArgs.xhr.status); // 
		          return response; // 
		          }
		        });
		}
	}
}

var flyoutArr = new Array();
function setTheaterFeaturesFlyout(contextPath, isFavoriteTheater, theaterDistanceString, theaterId, theaterName, theaterCity, theaterState, theaterAddress, theaterZip, theaterMapUrl, hasOnlineTicketing, hasStadiumSeating, hasDigitalSound, is3DCapable, hasAccessible, hasAccessibleHearing, hasReservedSeating, flyInd, adultTicketPrice, childTicketPrice, noTicketPriceMessage) {
	flyoutArr[flyInd] = '<div class="theaterflyleft">';
	// show the add to favorites link if this theater is not yet a favorite theater for this user
	if("true" != isFavoriteTheater) {
		flyoutArr[flyInd] += '<div class="theaterinfofav"><a id="fav'+theaterId+'" href="javascript:addRemoveFavoriteTheater(\''+contextPath+'/addFavoriteTheaters?theaterId='+theaterId+'\', \''+contextPath+'/deleteFavoriteTheaters?theaterId='+theaterId+'\', document.getElementById(\'fav'+theaterId+'\'), document.getElementById(\'favflyout'+theaterId+'\'), \''+contextPath+'\',\''+theaterId+'\');" class="addfav">Add to Favorites</a></div>';
	}else{
		flyoutArr[flyInd] += '<div class="theaterinfofav"><a id="fav'+theaterId+'" href="javascript:addRemoveFavoriteTheater(\''+contextPath+'/addFavoriteTheaters?theaterId='+theaterId+'\', \''+contextPath+'/deleteFavoriteTheaters?theaterId='+theaterId+'\', document.getElementById(\'fav'+theaterId+'\'), document.getElementById(\'favflyout'+theaterId+'\'), \''+contextPath+'\',\''+theaterId+'\');" class="removefav">Remove from Favorites</a></div>';
	}
	// Directions link
	flyoutArr[flyInd] += '<div class="theaterinfodirections"><a href="' + theaterMapUrl + '&2z=' + theaterZip + '&2c=' + theaterCity + '&2s=' + theaterState + '&2a=' + theaterAddress + '&CID=lf_moviefone&2pn=' + theaterName + '" target="directions" class="directionslink">Directions</a> (' + theaterDistanceString + ')</div>';
	flyoutArr[flyInd] += '</div>';
	
	flyoutArr[flyInd] += '<div class="theaterflyright">';
	// show the theater key if there are any
	if(('true' == hasOnlineTicketing) || ('true' == hasStadiumSeating) || ('true' == hasDigitalSound) || ('true' == is3DCapable) || ('true' == hasAccessible) || ('true' == hasAccessibleHearing) || ('true' == hasReservedSeating)) {
		flyoutArr[flyInd] += '<div id="theaterKeysInfoBox'+theaterId+'" class="movieshowkeys" style="display:none;"></div><div class="key"><ul>';

		if('true' == hasOnlineTicketing) {
			flyoutArr[flyInd] += '<li class="oticketing" onMouseOver="showTheatKeyTip(\'oticketing\',\'show\',\''+ theaterId+'\',this);" onMouseOut="showTheatKeyTip(\'oticketing\',\'hide\',\''+ theaterId+'\',this);"></li>';
		}
		
		if('true' == hasStadiumSeating) {
			flyoutArr[flyInd] += '<li class="sseating" onMouseOver="showTheatKeyTip(\'sseating\',\'show\',\''+ theaterId+'\',this);" onMouseOut="showTheatKeyTip(\'sseating\',\'hide\',\''+ theaterId+'\',this);"></li>';
		}
		
		if('true' == hasDigitalSound) {
			flyoutArr[flyInd] += '<li class="sound" onMouseOver="showTheatKeyTip(\'sound\',\'show\',\''+ theaterId+'\',this);" onMouseOut="showTheatKeyTip(\'sound\',\'hide\',\''+ theaterId+'\',this);"></li>';
		}
		
		if('true' == hasAccessible) {
			flyoutArr[flyInd] += '<li class="access"  onMouseOver="showTheatKeyTip(\'access\',\'show\',\''+ theaterId+'\',this);" onMouseOut="showTheatKeyTip(\'access\',\'hide\',\''+ theaterId+'\',this);"></li>';
		}
		
		if('true' == hasAccessibleHearing) {
			flyoutArr[flyInd] += '<li class="hearingimpaired" onMouseOver="showTheatKeyTip(\'hearingimpaired\',\'show\',\''+ theaterId+'\',this);" onMouseOut="showTheatKeyTip(\'hearingimpaired\',\'hide\',\''+ theaterId+'\',this);"></li>';
		}
		
		if('true' == hasReservedSeating) {
			flyoutArr[flyInd] += '<li class="rseating" onMouseOver="showTheatKeyTip(\'rseating\',\'show\',\''+ theaterId+'\',this);" onMouseOut="showTheatKeyTip(\'rseating\',\'hide\',\''+ theaterId+'\',this);"></li>';
		}
		
		if('true' == is3DCapable) {
			flyoutArr[flyInd] += '<li class="threedcapable" onMouseOver="showTheatKeyTip(\'threedcapable\',\'show\',\''+ theaterId+'\',this);" onMouseOut="showTheatKeyTip(\'threedcapable\',\'hide\',\''+ theaterId+'\',this);"></li>';
		}
		
		flyoutArr[flyInd] += '</ul></div>';
		
	}
	
	if(adultTicketPrice != "" || childTicketPrice != ""){
		if(adultTicketPrice != ""){
			flyoutArr[flyInd] += '<div class="ticketprices">Regular Adult: $'+adultTicketPrice;
		}
		
		if(childTicketPrice != "") {
			if(adultTicketPrice != "") {
				flyoutArr[flyInd] += '&nbsp;|&nbsp;';
			}
			flyoutArr[flyInd] += 'Regular Child: $'+childTicketPrice+'</div>';
		}
	} else if(noTicketPriceMessage != "") {
		flyoutArr[flyInd] += '<div class="ticketprices">' + noTicketPriceMessage + '</div>';
	}
	flyoutArr[flyInd] += '</div></div>';
}
function toggleTheaterFeaturesFlyout(theaterInfoFlyoutLink, divId, flyInd) {
	if(document.getElementById(divId).innerHTML==""){
		document.getElementById(divId).style.display = "block";
		document.getElementById(divId).innerHTML = flyoutArr[flyInd];
		document.getElementById(theaterInfoFlyoutLink).className = "opentoggle";
		document.getElementById(theaterInfoFlyoutLink).getElementsByTagName("a")[0].innerHTML = 'Theater Info<span></span>';
	}else{
		document.getElementById(divId).style.display = "none";
		document.getElementById(divId).innerHTML = "";
		document.getElementById(theaterInfoFlyoutLink).className = "closetoggle";
		document.getElementById(theaterInfoFlyoutLink).getElementsByTagName("a")[0].innerHTML = 'Theater Info<span></span>';
	}
}
function onSelectSearchQuery(setVal, drpdwn, pulldwn, fld) {
	drpdwn.getElementsByTagName("a")[0].innerHTML = setVal;
	pulldwn.style.display = "none";
	fld.value = setVal;
}
function onShowDateChange(showVal,setVal) {
	
	document.getElementById("showdatesdropdown").getElementsByTagName("a")[0].innerHTML = showVal;
	document.getElementById("showdatespulldown").style.display = "none";
	document.changeShowDate.selectedShowDate.value = setVal;
	document.changeShowDate.submit();
	if(navigator.userAgent.indexOf('MSIE')>=0){
		document.doSubmit = function() {
		    document.getElementById("changeShowDateId").submit();
		}
	setTimeout("document.doSubmit();", 50);}
}
function showtimesDropDown(pulldwn){
	pulldwn.style.display = (pulldwn.style.display!="block") ? "block" : "none";
}


function __TABBLO_TPT_LOAD(){
	Tabblo.embedded.sites.SettingsObject.preprocess.apply({Properties:{template:'movies'},FixedContent:{'logo':'http://www.aolcdn.com/ch_movies2/branding'},Content:{'pagetitle':{ match: 'css', selector:'h1' }, 'text':{ match: 'css', selector:'div#printContainer', outputTagToo: true, recurse: true }} }, []); Tabblo.embedded.printabulous();
}

function MakePDF() { var tpS = document.createElement('script');tpS.setAttribute('type','text/javascript');tpS.setAttribute('charset','utf-8'); tpS.setAttribute('src','http://h30405.www3.hp.com/edit/tptboot/1.0');document.getElementsByTagName('body').item(0).appendChild(tpS);}
function pdfPrint(url){MakePDF();}
function showHpPop(iShow){
    if (iShow == 1) {
        document.getElementById("hpPopCnt").innerHTML = "<p>With HP wireless printers, you could have printed this from any room in the house. Live wirelessly. Print wirelessly.</p>";
        document.getElementById("hpPopCnt").style.display = "block";
    } else {
        document.getElementById("hpPopCnt").style.display = "none";
    }
}
function showHpPop2(iShow){
    if (iShow == 1) {
        document.getElementById("hpPopCnt2").innerHTML = "<p>With HP wireless printers, you could have printed this from any room in the house. Live wirelessly. Print wirelessly.</p>";
        document.getElementById("hpPopCnt2").style.display = "block";
    } else {
        document.getElementById("hpPopCnt2").style.display = "none";
    }
}

//print preview showtimes
var printTitle = "";
var printTheaInd = 0;
var printTheaters = new Array();
var mInd = 0;
var sInd = 0;
var isMoviePage = false;
function setPrintTheater(theatername, theateraddress, theaterphone,theaterid){
	printTheaters[printTheaInd] = new printTheater(theatername, theateraddress, theaterphone,theaterid);
}
function setPrintTheaterMovie(movietitle){
	mInd = printTheaters[printTheaInd].tMovieInd;
	printTheaters[printTheaInd].tMovies[mInd] = new printTheaterMovie(movietitle);
	printTheaters[printTheaInd].tMovieInd++;
}
function setPrintTheaterMovieShowtime(showtime){
	sInd = printTheaters[printTheaInd].tMovies[mInd].mShowtimesInd;
	printTheaters[printTheaInd].tMovies[mInd].mShowtimes[sInd] = showtime;
	printTheaters[printTheaInd].tMovies[mInd].mShowtimesInd++;
}
function printTheater(theatername, theateraddress, theaterphone,theaterid){
	this.tName = theatername;
	this.tAddress = theateraddress;
	this.tPhone = theaterphone;
	this.tId = theaterid;
	this.tMovieInd = 0;
	this.tMovies = new Array();
}
function printTheaterMovie(movietitle){
	this.mTitle = movietitle;
	this.mShowtimesInd = 0;
	this.mShowtimes = new Array();
}
function printPreview(){
	var theaterName = "";
	var theaterAddress = "";
	var theaterPhone = "";
	var theaterId="";
	var movieName = "";
	var movieShowtime = "";
	var showtimeDivider = "";
	var movieContainer = new Array();
	var printPrevTheaters = new Array();
	var printPrevTheaterChecks = new Array();
	var printPrevTheaterNames = new Array();
	var printPrevTheaterAddresses = new Array();
	var printPrevTheaterMovies = new Array();
	var printPrevTheaterMovieChecks = new Array();
	var printPrevTheaterMovieNames = new Array();
	var printPrevTheaterShowtimeContainer = new Array();
	var printPrevTheaterShowtimes = new Array();
	var mixedChecks = new Array();
	var printPrevPane = document.createElement("div");
	printPrevPane.setAttribute("id", "printPrev");
	document.body.appendChild(printPrevPane);
	var paneHdr = document.createElement("h2");
	var closePane = document.createElement("span");
	var closePrintBox = document.createElement("img");
	var checkAllContainer = document.createElement("div");
	checkAllContainer.setAttribute("id", "checkAllContainer");
	var checkAll = document.createElement("input");
	closePrintBox.setAttribute("src", "http://www.aolcdn.com/ch_movies/mf_showtimes_closeprintbtn");
	closePane.setAttribute("id", "closeX");
	checkAll.setAttribute("id", "checkAll");
	checkAll.setAttribute("type", "checkbox");
	var printLogo = document.createElement("img");
	printLogo.setAttribute("id","printLogo");
	printLogo.setAttribute("src", "http://www.aolcdn.com/ch_movies/moviefone_footer_logo_127x40");
	document.getElementById("printPrev").appendChild(printLogo);
	
	var printPrevContainer = document.createElement("div");
	printPrevContainer.setAttribute("id", "printContainer");
	document.getElementById("printPrev").appendChild(paneHdr);
	document.getElementById("printPrev").appendChild(closePane);
	closePane.appendChild(closePrintBox);
	
	
	var dateContainer = document.createElement("div");
	dateContainer.setAttribute("id", "dateContainer");
	var dateDisplay = document.getElementById("showdatesdropdown").getElementsByTagName("a")[0].innerHTML;
	dateContainer.innerHTML = "<span class='red'>" + dateDisplay + "</span> (" + getPrintDate() + ")";
	document.getElementById("printPrev").appendChild(dateContainer);
	
	document.getElementById("printPrev").appendChild(checkAllContainer);
	checkAllContainer.appendChild(checkAll);
	checkAllContainer.innerHTML = checkAllContainer.innerHTML + " Check/Uncheck All";
	document.getElementById("checkAllContainer").getElementsByTagName("input")[0].checked = true;
	
	document.getElementById("printPrev").appendChild(printPrevContainer);
	document.getElementById("printPrev").getElementsByTagName("h2")[0].innerHTML = "<span class='showtimeRed'>Showtimes for</span><span class='red'>Print Setup for</span> <span class='defaultTitle'>"+printTitle + '</span>';
	closePrintBox.onclick=function(){document.body.removeChild(printPrevPane);};
	for(t=0;t<printTheaters.length;t++){
		theaterName = printTheaters[t].tName;
		theaterAddress = printTheaters[t].tAddress;
		theaterPhone = printTheaters[t].tPhone;
		theaterId = printTheaters[t].tId;
		printPrevTheaters[t] = document.createElement("div");
		printPrevTheaters[t].className = "theaterprint";
		printPrevTheaters[t].setAttribute("id", "theaterprint"+t);
		printPrevTheaterChecks[t] = document.createElement("input");
		printPrevTheaterChecks[t].setAttribute("type", "checkbox");
		printPrevTheaterChecks[t].className = "theatercheck";
		printPrevTheaterNames[t] = document.createElement("h4");
		printPrevTheaterAddresses[t] = document.createElement("p");
		mixedChecks[t] = document.createElement("span");
		mixedChecks[t].setAttribute("id", "mixedCheck"+t);
		mixedChecks[t].className = "mixedCheck";;
		
		
		document.getElementById("printContainer").appendChild(printPrevTheaters[t]);
		document.getElementById("theaterprint"+t).appendChild(printPrevTheaterChecks[t]);
		document.getElementById("theaterprint"+t).appendChild(mixedChecks[t]);
		document.getElementById("theaterprint"+t).appendChild(printPrevTheaterNames[t]);
		document.getElementById("theaterprint"+t).appendChild(printPrevTheaterAddresses[t]);
		document.getElementById("theaterprint"+t).getElementsByTagName("h4")[0].innerHTML = theaterName;
		document.getElementById("theaterprint"+t).getElementsByTagName("span")[0].onclick = function(){setPrintable(this);};
		document.getElementById("theaterprint"+t).getElementsByTagName("input")[0].onclick = function(){setPrintable(this);};
		document.getElementById("theaterprint"+t).getElementsByTagName("input")[0].checked = true;
		document.getElementById("theaterprint"+t).getElementsByTagName("p")[0].innerHTML = theaterAddress + "&nbsp;|&nbsp;"+ theaterPhone;
		
		if(document.getElementById("noShow"+theaterId)){
			var noShowMsg = document.createElement("p");
			noShowMsg.setAttribute ("id","noShowMsg"+theaterId);
			document.getElementById("theaterprint"+t).appendChild(noShowMsg);
			document.getElementById("noShowMsg"+theaterId).innerHTML = document.getElementById("noShow"+theaterId).innerHTML;
		}else if(document.getElementById("contactTheatOne"+theaterId)){
			var noShowMsg = document.createElement("p");
			noShowMsg.setAttribute ("id","noShowMsg"+theaterId);
			document.getElementById("theaterprint"+t).appendChild(noShowMsg);
			document.getElementById("noShowMsg"+theaterId).innerHTML = document.getElementById("contactTheatOne"+theaterId).innerHTML;
			
		}else if(document.getElementById("contactTheatTwo"+theaterId)){
			var noShowMsg = document.createElement("p");
			noShowMsg.setAttribute ("id","noShowMsg"+theaterId);
			document.getElementById("theaterprint"+t).appendChild(noShowMsg);
			document.getElementById("noShowMsg"+theaterId).innerHTML = document.getElementById("contactTheatTwo"+theaterId).innerHTML;
		
		}
		
		
		if(document.getElementById("theater-" +theaterId+ "-header")){
			if(document.getElementById("theater-" +theaterId + "-header").getElementsByTagName("li")){
				var keyItems = document.getElementById("theater-" +theaterId + "-header").getElementsByTagName("li");
				if(keyItems.length>0){
					var theaterKeysP = document.createElement("p");
					theaterKeysP.className = "listOfKeys";
					document.getElementById("theaterprint"+t).appendChild(theaterKeysP);
					var theaterKeysImg = new Array();
					for(key=0;key<keyItems.length;key++){
						theaterKeysImg[key] = document.createElement("img");
						theaterKeysP.appendChild(theaterKeysImg[key]);
						if(keyItems[key].className=="access"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/showtimes_amenities_access");}
						if(keyItems[key].className=="sound"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/showtimes_amenities_enhsound");}
						if(keyItems[key].className=="sseating"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/mf_show_stadiumseating_key");}
						if(keyItems[key].className=="rseating"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/mf_show_reservedseating_key");}
						if(keyItems[key].className=="oticketing"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/showtimes_amenities_onlinetix");}
						if(keyItems[key].className=="printtix"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/showtimes_amenities_printtix");}
						if(keyItems[key].className=="hearingimpaired"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/showtimes_amenities_imphearing");}
						if(keyItems[key].className=="threedcapable"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/showtimes_amenities_3d");}
						
					}
				}
			}
		}else if(document.getElementById("theaterKeys" +theaterId)){
			
			if(document.getElementById("theaterKeys" +theaterId).getElementsByTagName("li")){
				
				var keyItems = document.getElementById("theaterKeys" +theaterId).getElementsByTagName("li");
				if(keyItems.length>0){
					var theaterKeysP = document.createElement("p");
					theaterKeysP.className = "listOfKeys";
					document.getElementById("theaterprint"+t).appendChild(theaterKeysP);
					
					var theaterKeysImg = new Array();
					for(key=0;key<keyItems.length;key++){
						theaterKeysImg[key] = document.createElement("img");
						theaterKeysP.appendChild(theaterKeysImg[key]);
						if(keyItems[key].className=="access"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/showtimes_amenities_access");}
						if(keyItems[key].className=="sound"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/showtimes_amenities_enhsound");}
						if(keyItems[key].className=="sseating"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/mf_showtime_key_sseating");}
						if(keyItems[key].className=="rseating"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/mf_showtime_key_rseating");}
						if(keyItems[key].className=="oticketing"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/showtimes_amenities_onlinetix");}
						if(keyItems[key].className=="printtix"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/showtimes_amenities_printtix");}
						if(keyItems[key].className=="hearingimpaired"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/showtimes_amenities_imphearing");}
						if(keyItems[key].className=="threedcapable"){theaterKeysImg[key].setAttribute("src","http://www.aolcdn.com/ch_movies/showtimes_amenities_3d");}
						
					}
				}
			}
		}
		
		printPrevTheaterMovies[t] = new Array();
		printPrevTheaterMovieNames[t] = new Array();
		printPrevTheaterMovieChecks[t] = new Array();
		printPrevTheaterShowtimeContainer[t] = new Array();
		for(m=0;m<printTheaters[t].tMovies.length;m++){
			movieName = printTheaters[t].tMovies[m].mTitle;
			printPrevTheaterMovies[t][m] = document.createElement("div");
			printPrevTheaterMovies[t][m].className = "movieprint";
			printPrevTheaterMovieChecks[t][m] = document.createElement("input");
			printPrevTheaterMovieChecks[t][m].setAttribute("type", "checkbox");
			printPrevTheaterMovieChecks[t][m].checked = "checked";
			printPrevTheaterMovieChecks[t][m].className = "moviecheck";
			printPrevTheaterMovieNames[t][m] = document.createElement("h5");
			document.getElementById("theaterprint"+t).appendChild(printPrevTheaterMovies[t][m]);
			movieContainer[m] = getMovieContainer(document.getElementById("theaterprint"+t), "movieprint", m);
			if(!isMoviePage){
				movieContainer[m].appendChild(printPrevTheaterMovieChecks[t][m]);
				movieContainer[m].appendChild(printPrevTheaterMovieNames[t][m]);
				movieContainer[m].getElementsByTagName("h5")[0].innerHTML = movieName;
				movieContainer[m].getElementsByTagName("input")[0].onclick = function(){setPrintable(this);};
				movieContainer[m].getElementsByTagName("input")[0].checked = true;
			}
			printPrevTheaterShowtimeContainer[t][m] = document.createElement("span");
			printPrevTheaterShowtimeContainer[t][m].className = "movieshowtimes";
			movieContainer[m].appendChild(printPrevTheaterShowtimeContainer[t][m]);
			printPrevTheaterShowtimes[m] = new Array();
			for(s=0;s<printTheaters[t].tMovies[m].mShowtimes.length;s++){
				movieShowtime = printTheaters[t].tMovies[m].mShowtimes[s];
				printPrevTheaterShowtimes[m][s] = document.createElement("span");
				printPrevTheaterShowtimeContainer[t][m].appendChild(printPrevTheaterShowtimes[m][s]);
				if(s<(printTheaters[t].tMovies[m].mShowtimes.length-1)){
					showtimeDivider = "&nbsp;|&nbsp;";
				}else{
					showtimeDivider = "";
				}
				printPrevTheaterShowtimeContainer[t][m].getElementsByTagName("span")[s].innerHTML = movieShowtime + showtimeDivider;
			}
		}	
		
	}
	
	document.getElementById("checkAllContainer").getElementsByTagName("input")[0].onclick = function(){
		var numOfTheatersChecked = document.getElementById("printContainer").getElementsByTagName("input");
		for(var z=0;z<numOfTheatersChecked.length;z++){
			setPrintableAll(numOfTheatersChecked[z]);			
		};
		
		for(var k=0;k<numOfTheatersChecked.length;k++){
			var isTheaterOrMovieChecked = document.getElementById("checkAllContainer").getElementsByTagName("input")[0].checked;
			if(isTheaterOrMovieChecked==true){
				document.getElementById("printContainer").getElementsByTagName("input")[k].checked = true;
				document.getElementById("printContainer").getElementsByTagName("input")[k].disabled=false;
				document.getElementById("printButton").style.display = "block";
			}else{
				document.getElementById("printContainer").getElementsByTagName("input")[k].checked = false;
				document.getElementById("printContainer").getElementsByTagName("input")[k].disabled=false;
				document.getElementById("printButton").style.display = "none";
				
			}
		};
	};
	var printPrevButton = document.createElement("div");
	var printPrevReset = document.createElement("div");
	var printPrevInstructions = document.createElement("span");
	printPrevButton.setAttribute("id", "printButton");
	printPrevReset.setAttribute("id", "printReset");
	printPrevInstructions.setAttribute("id", "printInstructions");
	document.getElementById("printPrev").appendChild(printPrevInstructions);
	document.getElementById("printPrev").appendChild(printPrevButton);
	document.getElementById("printInstructions").innerHTML = "Uncheck a theater or movie to remove it from the print list. Check it to restore it.<br/>When satisfied with your list, click 'Print'.";
	document.getElementById("printButton").onclick = function(){printIt();};
	if (Browser.Version() < 7) {
		scroll(0,0);
	}
	
}
function getMovieContainer(elem, classnm, ind){
	var movContain = elem.getElementsByTagName("div");
	for(c=0;c<movContain.length;c++){
		if((c==ind)&&(movContain[c].className==classnm)){
			return movContain[c];
		}
	}
}
function setPrintable(hdr){
	var div = hdr.parentNode;
	//alert(div.id);
	var movieChkArr;
	var divTheater;
	var mixedValChk;
	var modMovieClass;
	var disableChk = false;
	var theaterClass;
	
	if(div.id){
		movieChkArr = div.getElementsByTagName("input");
		div.getElementsByTagName("span")[0].style.display = "none";
		if(div.className=="greyoutTheater"){
			theaterClass = "theaterprint";
			document.getElementById("printButton").style.display = "block";
			disableChk = true;
			modMovieClass = "movieprint";
		}else{
			theaterClass = "greyoutTheater";
			disableChk = false;
			modMovieClass = "greyoutMovie";
			
		}
		
		for(h=0;h<movieChkArr.length;h++){
			movieChkArr[h].checked = disableChk;
			movieChkArr[h].parentNode.className=modMovieClass;
			div.className = theaterClass;
			
		}
		hdr.disabled = false;
	}else{
		
		if(div.className=="greyoutMovie"){
			div.className = "movieprint";
			document.getElementById("printButton").style.display = "block";
		}else{
			div.className = "greyoutMovie";
		}
		divTheater = hdr.parentNode.parentNode.id;

		mixedValChk = document.getElementById(divTheater).getElementsByTagName("input");
		
		var countTrue = 0;
		var countFalse = 0;
		for(h=0;h<mixedValChk.length;h++){
			
			if(mixedValChk[h].checked != true){ 
				countTrue++; 
			}else{ 
				countFalse++;
			}
		}
		var mixedId = document.getElementById(divTheater).getElementsByTagName("span")[0];
		if((countTrue!=mixedValChk.length)&& (countFalse!=mixedValChk.length)){
			mixedId.style.display = "block";
		}else{
			mixedId.style.display = "none";
		}
	}
	
	var isAllUnchecked = document.getElementsByTagName("input");
	var isAllUncheckedCount = 0;
	for(var b=0;b<isAllUnchecked.length;b++){
		if(isAllUnchecked[b].checked == true){
			isAllUncheckedCount++;
		}
	}
	if(isAllUncheckedCount==0){ document.getElementById("printButton").style.display = "none";}
	else {document.getElementById("printButton").style.display = "block";}
	
}


function setPrintableAll(hdr){
	
	var div = hdr.parentNode;
	//alert(div.id);
	var movieChkArr;
	var divTheater;
	var mixedValChk;
	var modMovieClass;
	var disableChk = false;
	var theaterClass;
	var isTheaterOrMovieChecked = document.getElementById("checkAllContainer").getElementsByTagName("input")[0].checked;
	
	if(div.id){
		div.getElementsByTagName("span")[0].style.display = "none";
		if(isTheaterOrMovieChecked==true){
			div.className = "theaterprint";
			document.getElementById("printButton").style.display = "block";
			disableChk = true;
		}else{
			div.className= "greyoutTheater";
			disableChk = false;	
		}
	}else{
		
		if(isTheaterOrMovieChecked==true){
			div.className = "movieprint";
			document.getElementById("printButton").style.display = "block";
		}else{
			div.className = "greyoutMovie";
		}
	}
}

function getPrintDate (){
	var currentTime = new Date();
	var weekday=new Array(7);
	weekday[0]="Sunday";
	weekday[1]="Monday";
	weekday[2]="Tuesday";
	weekday[3]="Wednesday";
	weekday[4]="Thursday";
	weekday[5]="Friday";
	weekday[6]="Saturday";
	var months=new Array(12);
	months[0]="Jan";
	months[1]="Feb";
	months[2]="Mar";
	months[3]="Apr";
	months[4]="May";
	months[5]="Jun";
	months[6]="Jul";
	months[7]="Aug";
	months[8]="Sep";
	months[9]="Oct";
	months[10]="Nov";
	months[11]="Dec";

	var month = currentTime.getMonth();
	var day = currentTime.getDate();
	var dayName = weekday[currentTime.getDay()];
	var monthName = months[currentTime.getMonth()];
	var year = currentTime.getFullYear();
	var ampm = "";
	var hours = currentTime.getHours();
	var minutes = currentTime.getMinutes();
	if (minutes < 10){minutes = "0" + minutes;}
	if(hours > 11){ampm = "pm";} else {ampm = "am";}
	if(hours > 12){hours = hours-12;}
	
	var result = "as printed on "+ dayName + ", "+monthName+ " " + day + " at " + hours + ":" +minutes + ampm;
	
	return result;
}

function printReset(){
	var delArr = document.getElementById("printContainer").getElementsByTagName("div");
	for(d=0;d<delArr.length;d++){
		
		if(delArr[d].className=="greyoutTheater"){
			var ismixed = delArr[d].getElementsByTagName("span")[0];
			if((ismixed) && (ismixed.style.display!= "block")){
				delArr[d].innerHTML = "";
				delArr[d].style.border = "none";
				delArr[d].style.margin = "0";
				delArr[d].style.padding = "0";
			}
		}
		if(delArr[d].className=="greyoutMovie"){
			delArr[d].innerHTML = "";
			delArr[d].style.border = "none";
			delArr[d].style.margin = "0";
			delArr[d].style.padding = "0";
		}
	}
}
function printIt(){
	printReset();
	printTimer = window.setTimeout(doPrint(), 2000);
}
function doPrint(){
	window.print();
}

function checkVal(fld, msg, defVal){
	if(fld.value==null||fld.value==""||fld.value==defVal){
		alert(msg);
		return false;
	}else{
		return true;
	}
}
function toggleMsgFlyout(div, pos){
	var topAdd = 0;
	var divId = div.id;
	if(divId.match("latenightflyout")!=null){
		topAdd = 60;
	}
	if(pos!=undefined){
		div.style.left=(getLeftPos(pos)-90)+'px';
		div.style.top=(getTopPos(pos)+topAdd)+'px';
	}
	div.style.display = (div.style.display=="block") ? div.style.display="none" : div.style.display="block";
}


//showtime dropdown functions
var show_dd_timeout = 1000;
var closetimer	= 0;
var show_dd_menu = 0;
function mopen(id)
{	
	if(document.getElementById(id).style.display=="block"){
		mclose();
		return;
	}
	mcancelclosetime();
	show_dd_menu = document.getElementById(id);
	show_dd_menu.style.display = 'block';
}
function mclose()
{
	if(show_dd_menu) show_dd_menu.style.display = 'none';
}
function mclosetime()
{
	closetimer = window.setTimeout(mclose, show_dd_timeout);
}
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}


//Tooltip Showtime Amenities
function showTheatKeyTip(key,status,theaterId,pos){
	var feature;
	if(theaterId!=""){
		var infoBox = document.getElementById("theaterKeysInfoBox"+theaterId);
	}else{
		var infoBox = document.getElementById("theaterKeysInfoBox");
	}
	infoBox.innerHTML ="";
	infoBox.style.display = "block";
	
	
	if(status=="show"){
		infoBox.style.left=(getLeftPos(pos)-90)+'px';
		infoBox.style.top=(getTopPos(pos)-62)+'px';
		if(key=="oticketing"){
			feature ="Online Ticketing";	
		}else if(key=="sound"){
			feature ="Enhanced Sound";
		}else if(key=="sseating"){
			feature ="Stadium Seating";
		}else if(key=="access"){
			feature ="Handicap Access";
		}else if(key=="hearingimpaired"){
			feature ="Hearing Impaired Service";
		}else if(key=="rseating"){
			feature ="Reserved Seating";
		}else if(key=="threedcapable"){
			feature ="3D Capability";
		}else{
			infoBox.style.display = "none";
		}
		infoBox.innerHTML = "<div class='keyBoxContent'>This Theater has:<div class='boxRed'>"+ feature +"</div></div>";
		
	}else{
		infoBox.style.display = "none";
	}
	
}




//Toggle Slide
var timerlen = 3;
var slideAniLen = 200;
var timerID = new Array();
var startTime = new Array();
var objTogSld = new Array();
var endHeight = new Array();
var moving = new Array();
var dir = new Array();

function slidedown(objname,flyouturl,divid,togg){
        if(moving[objname])
        return;
        if(document.getElementById(objname).style.display != "none")
        return;
        moving[objname] = true;
        dir[objname] = "down";
        startslide(objname,flyouturl,divid,togg);
        
}

function slideup(objname,flyouturl,divid,togg){
        if(moving[objname])
        return;
        if(document.getElementById(objname).style.display == "none")
		return;
        moving[objname] = true;
        dir[objname] = "up";
        
        startslide(objname,flyouturl,divid,togg);
        
}

function startslide(objname,flyouturl,divid,togg){
        objTogSld[objname] = document.getElementById(objname);
        endHeight[objname] = parseInt(objTogSld[objname].style.height);
        startTime[objname] = (new Date()).getTime();
        if(dir[objname] == "down"){
                objTogSld[objname].style.height = "1px";
        }

        objTogSld[objname].style.display = "block";

        timerID[objname] = setInterval('slidetick(\'' + objname + '\',\'' + flyouturl + '\',\'' + divid + '\',\'' + togg + '\');',timerlen);
}

function slidetick(objname,flyouturl,divid,togg){
        var elapsed = (new Date()).getTime() - startTime[objname];

        if (elapsed > slideAniLen)
                endSlide(objname,flyouturl,divid,togg)
        else {
                var d =Math.round(elapsed / slideAniLen * endHeight[objname]);
                if(dir[objname] == "up")
                d = endHeight[objname] - d;
                objTogSld[objname].style.height = d + "px";
        }
        return;
}

function endSlide(objname,flyouturl,divid,togg){
        clearInterval(timerID[objname]);
        if(dir[objname] == "up")
		objTogSld[objname].style.display = "none";
        objTogSld[objname].style.height = endHeight[objname] + "px";
        delete(moving[objname]);
        delete(timerID[objname]);
        delete(startTime[objname]);
        delete(endHeight[objname]);
        delete(objTogSld[objname]);
        delete(dir[objname]);
        toggleMovieInfoFlyout(flyouturl,divid,togg);
        return;
}

function toggleSlide(objname,flyouturl,divid,togg){
	
	if(document.getElementById(objname).style.display == "none"){
		document.getElementById(togg.id).className="opentoggle";
		document.getElementById(divid).innerHTML="<img class='loadingContent' id='theloaderimg' src='http://www.aolcdn.com/ch_movies/mf_showtimes_ajaxloader' />";
		slidedown(objname,flyouturl,divid,togg);
		
		
	}else{
		document.getElementById(objname).innerHTML="";
		slideup(objname,flyouturl,divid,togg);
		document.getElementById(togg.id).className="closetoggle";
	}
}



//new omniture variable value - added here to keep away from the crawlers
var extLinkFilter = "apple.com,movietickets.com,imdb.com,fandango.com,movies.yahoo.com,Movies.msn.com,film.com,avclub.com,hitfix.com,popsugar.com,thewrap.com,huffingtonpost.com,mapquest.com,amazon.com,netflix.com,snagfilms.com,metacritic.com,myspace.com/trailerpark,rottentomatoes.com,hollywood.com,ugo.com,movietome.com,starz.com,totalfilm.com,spill.com,time.com,askmen.com,joblo.com,movieweb.com,themoviebox.net,comingsoon.net,canmag.com,gawker.com,filmfodder.com,screenrant.com,darkhorizons.com,filmfetish.com,cinemablend.com,chud.com,latinoreview.com,moviejungle.com,iwatchstuff.com,popwatch.ew.com,blogs.usatoday.com/popcandy,ropeofsilicon.com,movie-list.com,slashfilm.com,moviesonline.ca,filmjunk.com,filmwad.com,firstshowing.net,filmexperience.blogspot.com,empiremovies.com,filmschoolrejects.com,altfg.com,filmthreat.com";
