//Preload tooltip
if (document.images)
{
 pic1= new Image(223,149); 
 pic1.src="../_img/tooltip-web.png"; 
}

// Executes on DOM Ready
$(document).ready(function() {
	/*--------------------------------
	| Variable Declarations & Resets |
	--------------------------------*/

	//Close bottom accordions programatically to preserve nagivation for non-js browsers
	$('#releases-header a').css("background-position","0px -75px");
	$('#coming-content').css("display","none");
	$('#updates-content').css("display","none");
	// Hide trailer links on trailer page programatically to preserve nagivation for non-js browsers
	$('#inset-trailer-list ul li ul').attr("style", "");
	$('#inset-trailer-list ul li:has(ul)').addClass('cursor');
	//Protects multiple events queueing on subnav
	window.finished=0;	
	//First accordion down by default
	window.accdown=1;
	
	/*--------------------------------
	|         Event Tracking          |
	--------------------------------*/
	$("#movie-search-box").focus(function () {
		$("#movie-search").css("background-position","0px -71px");
		liveSearch._trackEvent('Search-Activated');
	});
	
	$("#movie-search-box").blur(function () {
		$("#movie-search").css("background-position","0px 0px");
		var searchterm =$(this).val();
		if(searchterm.length > 3) {
			liveSearch._trackEvent('Searched-For:', searchterm);
			liveSearch._trackEvent('Searched-Completed');
		}
		else if (searchterm.length > 0)
			liveSearch._trackEvent('Search-Completed');
	});
	
	/*--------------------------------
	|       Page Initialization      |
	--------------------------------*/
	
	//Subnavigation menu (current section)
	var space = navOffset(window.section);
	var offset = '0px '+ space * -58 +'px';
	$('#navigation').css("background-position",offset);
	var currentNav = '#subnav-' + window.section;
	$(currentNav).show();
		
	// Subnavigation Rounding (First & Last)
	$("#subnav ul li:first-child a").css("background-image","url(_img/nav-sub-left.gif)");
	$("#subnav ul li:last-child").css("background-image","url(_img/nav-sub-right.gif)");
	$("#subnav ul li:last-child a").css("background","url(_img/nav-sub-right2.gif) no-repeat top right");
	
	//SIFR Font Replacement
	if(typeof sIFR == "function"){
		sIFR.replaceElement(named({sSelector:"h2", sFlashSrc:"_inc/eurostile.swf", sColor:"#FFFFFF", sLinkColor:"#FFFFFF", sWmode: "transparent", sHoverColor:"#FFFFFF", nPaddingTop:0, nPaddingBottom:0,sCase:"upper"}));
		sIFR.replaceElement(named({sSelector:".player-title, .review-panel h5", sFlashSrc:"_inc/helvetica_neue.swf", sColor:"#FFFFFF", sLinkColor:"#FFFFFF", sWmode: "transparent", sHoverColor:"#FFFFFF", nPaddingTop:0, nPaddingBottom:0}));
		if(location.href.search("view=all") == -1 && location.href.search("/all") == -1) {
			sIFR.replaceElement(named({sSelector:"#inset-movie-list h3, #inset-player-list h3, #inset-offers h3",  sFlashSrc:"_inc/helvetica_neue.swf", sColor:"#FFFFFF", sLinkColor:"#FFFFFF", sWmode: "transparent", sHoverColor:"#FFFFFF", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left"}));
		}
		sIFR.replaceElement(named({sSelector:"#offers-perfect h3, #updates-left h3",  sFlashSrc:"_inc/helvetica_neue.swf", sColor:"#FFFFFF", sLinkColor:"#FFFFFF", sWmode: "transparent", sHoverColor:"#FFFFFF", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=center"}));
		sIFR.replaceElement(named({sSelector:"#inset-players h3", sFlashSrc:"_inc/helvetica_neue.swf", sColor:"#DBD9DC", sLinkColor:"#DBD9DC", sWmode: "transparent", sHoverColor:"#DBD9DC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left"}));
		sIFR.replaceElement(named({sSelector:"#player-detail-right h3", sFlashSrc:"_inc/eurostile.swf", sColor:"#EEEEEE", sLinkColor:"#EEEEEE", sWmode: "transparent", sHoverColor:"#EEEEEE", nPaddingTop:0, nPaddingBottom:0, sCase:"upper", sFlashVars:"textalign=left"}));
		//sIFR.replaceElement(named({sSelector:"#inset-overview h3", sFlashSrc:"_inc/helvetica_neue.swf", sColor:"#FFFFFF", sWmode: "transparent"}));
	};
	
	//Accordion
	if($(".accordion").html() != null) {
		var height= false;
		/* Sets selected accordions to autoheight 
		if( $('.accordion').attr("id") == "techspecs-accordion")
			height= true;
		*/
		$(".accordion").each(function () {
			jQuery(this).accordion( {
				header: '.accordion-header',
				autoheight: height,
				animated: 'easeslide',
				navigation: false
			});							   
		});
	}
	
	//Marquee
	if($(".marquee").html() != null) {
		initMarquee();
		//Autoscroll marquee on movie lander page	
		if($("#movie-featured-marquee ul li").size() > 3) {
			autoMarquee();
		}
	}

	//AJAX Autocomplete 
	if($("#movie-search").html() != null) {
		$("#movie-search-box").autocomplete( "dummy.php", {
			delay:300,
			cacheLength: 1,
			width: 249,
			minChars:1,
			matchSubset:1,
			matchContains:1,
			onItemSelect:selectItem,
			formatItem:formatItem,
			maxItemsToShow:10
		});	
	}
	
	//Tooltip - Movie Catalog
	if($('.web-enabled-info').attr("title") == 'info') {
		$('.web-enabled-info').Tooltip({
			track: true,
			top: 16,
			left: 10,
			delay: 200,
			bodyHandler: function() {
				var message = 'Web-enabled features are those downloadable special features brought to you by your HD DVD player\'s network connection&mdash;from ringtones to exclusive content to fully interactive experiences and more depending upon the title.';
				return message; 
			},
			showURL: false,
			fixPNG: true
		});
	}
	
	//Tooltip - Movie Details
	if($('#movie-enabled').attr("title") == 'info') {
		$('#movie-enabled').Tooltip({
			track: true,
			top: 16,
			left: 10,
			delay: 200,
			bodyHandler: function() {
				var message = 'Web-enabled features are those downloadable special features brought to you by your HD DVD player\'s network connection&mdash;from ringtones to exclusive content to fully interactive experiences and more depending upon the title.';
				return message; 
			},
			showURL: false,
			fixPNG: true
		});
	}
	
	// Calendar 
	if($('.calendar').size() > 0) {
		$('.calendar-left .ui-left').css("display","block");
		$('.calendar-left .ui-left-off').css("display","none");	
		$('.calendar-right .ui-right').css("display","block");	
		$('.calendar-right .ui-right-off').css("display","none");
		$.ajax({
  			url: "calendar.php",
  			cache: false,
  			success: function(html){
				$('.calendar-busy').hide();
				$('.calendar-loading-text').html('');
				setTimeout('$.getScript("_inc/calendar.js");', 5);
    			$(".calendar .current").html(html);
				$(".message").hide();
				var message = findMonth($('li.current .thismonth').html(),'') + ' ' + $('li.current .thisyear').html();
				$('.message').html(message);
				$(".message").fadeIn('250');
  			}
		}); 
	}
    
	/* Selects first available tab in movie details page *--NOW DONE THROUGH PHP--*
	if(window.firstTab != '') {
		changeTab(window.firstTab)
	} */
		

	/*--------------------------------
	|          Event Binding         |
	--------------------------------*/
	
	/* DART Tracking
	------------------*/
	$("a[href='http://www.thelookandsoundofperfect.com/_pdf/perfect_hd_dvd_offer_redemption_form.pdf']").click(function() {
		urchinTracker("Perfect_Offer_PDF");
		var axel = Math.random()+"";
		var a = axel * 10000000000000;
		var html= '<img src="http://ad.doubleclick.net/activity;src=1350347;type=gener722;cat=rebat588;ord='+ a + '?" width="1" height="1" border="0">';
		$('body').append(html);
	});
	$("a[href='http://www.thelookandsoundofperfect.com/_pdf/perfect_hd_dvd_offer_redemption_form_netflix.pdf']").click(function() {
		urchinTracker("Netflix_Perfect_Offer_PDF");
		var axel = Math.random()+"";
		var a = axel * 10000000000000;
		var html= '<img src="http://ad.doubleclick.net/activity;src=1350347;type=gener722;cat=rebat588;ord='+ a + '?" width="1" height="1" border="0">';
		$('body').append(html);
	});
	
	$("form[action='http://hddvd.cmail1.com/s/96992/']").submit(function() {
		var axel = Math.random()+"";
		var a = axel * 10000000000000;
		var html= '<img src="http://ad.doubleclick.net/activity;src=1350347;type=gener722;cat=offer785;ord='+ a + '?" width="1" height="1" border="0">';
		$('body').append(html);
    });	
	// add tracking to any link with a .track class, snag the REL value for the tracking snippet
	$(".analytics").click(function() {
		var trackTag = $(this).attr("rel");
		urchinTracker(trackTag);
	});
	
	/* GLOBAL STYLES 
	------------------*/
		
	// Resets subNav on exiting nav menu, delay to avoid sloppy mousework resetting nav
	$('#navigation').hover(function() {
		clearTimeout(window.navTimer);
	}, function() {
		var clear= 'clearNav(window.section);'
		window.navTimer = setTimeout(clear, 600);
	});
	
	$('#header-right input').focus(function() {
		$('#search-title').css("background-position","0px -19px");
	});
	$('#header-right input').blur(function() {
		$('#search-title').css("background-position","");
	});
	$('#header-updates').hover(function() {
		$(this).css("background-position","0px -19px");
	}, function() {
		$(this).css("background-position","");
	});
	
	// Global Hover State
	$('#gnav-home, #gnav-home-down').hover(function() {
		navigateTo('home');
	}, function() {
		navigateAway('home');
	});
	$('#gnav-about, #gnav-about-down').hover(function() {
		navigateTo('about');
	}, function() {
		navigateAway('about');
	});
	$('#gnav-movies, #gnav-movies-down').hover(function() {
		navigateTo('movies');
	}, function() {
		navigateAway('movies');
	});
	$('#gnav-players, #gnav-players-down').hover(function() {
		navigateTo('players')
	}, function() {
		navigateAway('players');
	});
	$('#gnav-news, #gnav-news-down').hover(function() {
		navigateTo('news');
	}, function() {
		navigateAway('news');
	});
	$('#gnav-offers, #gnav-offers-down').hover(function() {
		navigateTo('offers');
	}, function() {
		navigateAway('offers');
	});
	
	$('.ui-left, .ui-right').hover(function() {
			$(this).css("cursor","pointer").css("background-position","0px -19px");
	}, function() {
			$(this).css("background-position","0px 0px");
	});
	
	// Global Accordion 
	$('.accordion dt.accordion-header').hover(function() {
			$(this).addClass('hover');
	}, function() {
			$(this).removeClass('hover');
			$(this).removeClass('down');
	});
	$('.accordion dt.accordion-header').mousedown(function() {
		$(this).addClass('down');
	});
	
	//Accordion mouseDown FX
	$('ul#home-accordion #releases').mousedown(function() {
		if(accdown != 1) {
			$('#releases-header a').css("background-position","0px -50px");
		}
	});
	$('ul#home-accordion #coming').mousedown(function() {
		if(accdown != 2) {
			$('#coming-header a').css("background-position","0px -50px");
		}
	});
	$('ul#home-accordion #updates').mousedown(function() {
		if(accdown != 3) {
			$('#updates-header a').css("background-position","0px -50px");
		}
	});
	
	//Accordian mouseover  accdown is global variable set by homeAccordion to track downstate
	$('ul#home-accordion #releases').hover(function() {
		if(accdown != 1) {
		$('#releases-header a').css("background-position","0px -25px");
		}
	}, function() {
		if(accdown != 1) {
			$('#releases-header a').css("background-position","0px 0px");
		}
	});
	$('ul#home-accordion #coming').hover(function() {
		if(accdown != 2) {
		$('#coming-header a').css("background-position","0px -25px");
		}
	}, function() {
		if(accdown != 2) {
			$('#coming-header a').css("background-position","0px 0px");
		}
	});
	$('ul#home-accordion #updates').hover(function() {
		if(accdown != 3) {
		$('#updates-header a').css("background-position","0px -25px");
		}
	}, function() {
		if(accdown != 3) {
			$('#updates-header a').css("background-position","0px 0px");
		}
	});
	
	// Accordion click behavior
	$('ul#home-accordion #releases').click(function() {
		homeAccordian('1');
		return false;
	});
	$('ul#home-accordion #coming').click(function() {
		homeAccordian('2');
		return false;
	});
	$('ul#home-accordion #updates, .signup-link').click(function() {
		homeAccordian('3');
		return false;
	});
	
	$('#content-form button').hover(function() {
		$(this).css("background-position","0px -21px");
	}, function() {
		$(this).css("background-position","0px 0px");
	});
	
	// Movie search behavior 
	$("#movie-search form").submit(function() {
      	return false;
    });
	
	//Calendar Behaviors 

	$('.calendar-left .ui-left').click(function() {
		$('.calendar-busy').show();
		// Load date from metadata
		var month = $('.current .prevmonth').html();
		var year = $('.current .prevyear').html()
		var qs = 'month='+month+'&year='+year;
		$.ajax({
  			url: "calendar.php",
			data: qs,
  			cache: false,
  			success: function(html){
    			$(".calendar li.last").html(html);
				if(window.animating != 1) {
					window.animating= 1;
					$(".message").hide();
					var currentMonth = $(".text").html();
					var message = findMonth($('li.current .prevmonth').html(),'') + ' ' + $('li.current .prevyear').html();
					$('.message').html(message);					
					$('.calendar-busy').hide();
					$(".message").fadeIn('250');
					$('.calendar ul').animate({ marginLeft: "+=239px"}, 300,"easeInOutQuad",function() {
						window.animating=0;
						$(".calendar li.current").html(html);
						setTimeout('$(".calendar ul").css("marginLeft","-239px");',15);
						setTimeout('$.getScript("_inc/calendar.js");', 5);
					});
				}
  			}
		}); 
		return false;
	});
	
	$('.calendar-right .ui-right').click(function() {
		$('.calendar-busy').show();
		// Load date from metadata
		var month = $('.current .nextmonth').html();
		var year = $('.current .nextyear').html()
		var qs = 'month='+month+'&year='+year;
		$.ajax({
  			url: "calendar.php",
			data: qs,
  			cache: false,
  			success: function(html){	
    			$(".calendar li.next").html(html);
				if(window.animating != 1) {
					window.animating= 1;
					$(".message").hide();
					var message = findMonth($('li.current .nextmonth').html(),'') + ' ' + $('li.current .nextyear').html();
					$('.message').html(message);
					$('.calendar-busy').hide();
					$(".message").fadeIn('250');
					$('.calendar ul').animate({ marginLeft: "-=239px"}, 300,"easeInOutQuad",function() {
						window.animating=0;
						$(".calendar li.current").html(html);
						setTimeout('$(".calendar ul").css("marginLeft","-239px");',15);
						setTimeout('$.getScript("_inc/calendar.js");', 5);
					});
				}
  			}
		}); 
		return false; 
	});
	
	$('#calendar-hide').click(function() {
		if(window.animating != 1) {
			window.animating=1;
			$(this).find('a').css("background-position","0px -60px");
			// BOO IE (erm, IE doesnt like position absolute or relative in any animated item, wont animate)
			$('.calendar-header').css("position","static");
			$('.calendar').css("position","static");
			$('.calendar-zoom').hide();
			$('.calendar-zoom-header').css("position","static");
			// End IE suckiness
			$('.calendar-tray').slideToggle({
					duration: 700, 
					easing: "easeOutQuint", 
					complete: function() {
						window.animating=0;
						// start IE fix
						$('#calendar-hide a').attr("style","");			
						$('.calendar-header').css("position","relative");
						$('.calendar').css("position","relative");
						$('.calendar-zoom').show();
						$('.calendar-zoom-header').css("position","absolute");
						// end IE fix, cookie store for state of calendar
						if($('.calendar-tray:visible').size() > 0) {
							createCookie('calendar', 'show');
						}
						else {
							createCookie('calendar', 'hide');
						}
					}
				});
			
		}
		return false;
	});
	$('#genre-hide').click(function() {
		if(window.animating != 1) {
			window.animating=1;
			$(this).find('a').css("background-position","0px -60px");
			$('#genre-sort').slideToggle({
					duration: 700, 
					easing: "easeOutQuint", 
					complete: function() {
						window.animating=0;
						$('#genre-hide a').attr("style","");
						// Stores position
						if($('#genre-sort:visible').size() > 0) {
							createCookie('genresort', 'show');
						}
						else {
							createCookie('genresort', 'hide');
						}
					}
				});
		}
		return false;
	});
	
	//Current active sort doesn't link
	$('.sort-list li.active a').click(function() {
		return false;
	});
	
	$('.sort-list li:not(.active)').click(function() {
		$('li.active').removeClass('active');
		$(this).addClass('active');
	});
	
	$('#genre-hide').click(function() {
		/*if(window.animating != 1) {
			window.animating=1;
			$('.calendar-tray').slideToggle({duration: 700, easing: "easeOutQuint", complete: function() {window.animating=0;}});
		}*/
		return false;
	});
	
	/* Dropdown Select Behavior 
	$('###').click(function() {
		var qs = $('#qs').html();
		var href= qsReplace(qsReplace(qs,'sort','a-z'),'page','1');
		window.location= basehref+href;
		return false;
	 });
	*/
	
	//About Marquee Selector
	$('#overview-marquee ul li').hover(function() {
		if($(this).attr('class') != 'selected-movie') {
			$(this).css("background-position","0px -99px");
			$(this).find('a').css("color","#FFF");
		}
	}, function() {
		if($(this).attr('class') != 'selected-movie') {
			$(this).css("background-position","");
			$(this).find('a').css("color","");
		}
	});
	
	// About Marquee
	$('#overview-marquee ul li').click(function() {
		if($(this).attr('class') != 'selected-movie') {
			//Grabs non-zero indexed position and sends to flash function to parse
			flashMovie = document.getElementById("player");
			var id = $('#overview-marquee ul li').index(this);
			//switch from zero offset to 1
			id=id+1;
			$('.selected-movie').css("background-position","");
			$('.selected-movie').find('a').css("color","");
			$('.selected-movie').removeClass('selected-movie');
			//IE not inheriting bg position from selected-movie class, this is quickfix
			$(this).css("background-position","0px -99px");
			$(this).addClass('selected-movie');
			flashMovie.flashMovieChange(id);
		}
		return false;
	});
	
	$('#overview-right .ui-left').click(function() {
			moveMarquee('left',$(this));
			return false;
	});
	$('#overview-right .ui-right').click(function() {
			moveMarquee('right',$(this));
			return false;
	});	
	
	// Tech Specs 
	$('#inset-techspecs-left table td').hover(function() {
		$(this).parent().find('td').css("background-position","0px -98px");
	}, function() {
		$(this).parent().find('td').css("background-position","");
	});
	//Onload page fixes for table cells and IE accordion bug
	$('#inset-techspecs-left table tr td:first-child').css("width","110px").css("background","url(_img/techspecs-table-left-bg.jpg) repeat-x");
	$('#inset-techspecs-left table tr td:last-child').css("color","#FFFFFF").css("background","url(_img/techspecs-table-right-bg.jpg) repeat-x");
	$('techspecs-accordion dd:first-child').css("height","300px");
	
	// Movie Lander Mouseovers
	$('#movie-featured-marquee li').hover(function() {
		$(this).css("background-position","0px -302px");
		var text= $(this).find('img').attr("alt");
		$('#featured-fill').html(text).fadeIn(300);
	}, function() {
		$(this).css("background-position","");
		$('#featured-fill').css("display", "none");
	});
	$('#movie-featured-marquee ul').hover(function() {										   
		//Clears autoscroll
		if($(this).find('li').size() > 3) {
			window.clearTimeout(window.scroller);
		}
	}, function() {
		//Resets autoscroll
		if($(this).find('li').size() > 3) {
			window.scroller=window.setTimeout(function() {autoMarquee();}, 8000);
		}
		$('#featured-fill').html('');
	});
	
	$('#movie-featured-marquee ul li, #inset-movie-lander .accordion ul li').click(function() {
		//gets id from numeric part of href
		var slug= $(this).find('a').attr("rel");
		window.location=basehref+slug;
		return false;
	});
	
    // Trailers Page

    $('#inset-trailer-list ul li:has(ul)').hover(function() {
		$(this).addClass("hover");
	}, function() {
		$(this).removeClass("hover");
	});
    
    $('#inset-trailer-list ul li:has(ul)').click(function() {
			var alink = $(this).find('p a').attr('href');
            window.location = basehref+alink;
            void(0);
	});
	$('#inset-trailer-list ul li ul li').click(function() {
            window.open($(this).find('a').attr('href'));
            void(0);
			return false;
	});
    
	// Special Features Page
	
	// Movie Lander Marquee 
	$('.sfeature-header .ui-left').click(function() {
			moveMarquee('left',$(this));
			return false;
	});
	$('.sfeature-header .ui-right').click(function() {
			moveMarquee('right',$(this));
			return false;
	});	


	$('#inset-sfeature-list .video').hover(function() {
		$(this).find('p').css("color","#FFFFFF");
	}, function() {
		$(this).find('p').css("color","");
	});
	
	// Movie Lander Marquee 
	$('.lander-header .ui-left').click(function() {
			moveMarquee('left',$(this));
			return false;
	});
	$('.lander-header .ui-right').click(function() {
			moveMarquee('right',$(this));
			return false;
	});	
	
	$('#inset-movie-lander .accordion ul li').hover(function() {
		$(this).css("background-position","0px -169px");
		var text= $(this).find('img').attr("alt");
			$(this).parent().parent().parent().find('.lander-fill').html(text).fadeIn(300);
	}, function() {
		$(this).css("background-position","");
		$(this).parent().parent().parent().find('.lander-fill').css("display", "none");
	});
	$('#inset-movie-lander .accordion ul').hover(function() {
	}, function() {
		if($(this).parent().parent().parent().find('.lander-fill')) {
			$(this).parent().parent().parent().find('.lander-fill').html('');
		}
	});
	
	// Movies Release mouseover 
	$('div.content-left ul li').hover(function() {
		$(this).css("background-position","0px -124px");
	}, function() {
		$(this).css("background-position","");
	});
	
	//Movie List Sort
	$('.inset-menu-selection').hover(function() {
		$(this).css("cursor","pointer").css("background-position","0px -44px");
		$('.inset-menu-dropdown').css("display","block");
		// Hides new tag when sort by menu is up, IE displays over menu breaking design
		if($('.trailer-anchor .new').size() > 0) {
			$('.new:first').css("display","none");	
		}
	}, function() {
		$('.inset-menu-dropdown').css("display","none");
		$(this).css("background-position","0px 0px");
		if($('.trailer-anchor .new').size() > 0) {
			$('.new:first').css("display","block");	
		}
	});
	
	//Movie List Item
	$('.no-web').hover(function() {
		$(this).css("cursor","pointer").css("background-position","0px -156px");
		$(this).children('.movie-list-image, .movie-list-image-combo, .movie-list-image-black, .movie-list-image-grey, .movie-list-image-none, .movie-list-image-custom').css("background-position","0px -124px");
		$(this).find('a').css("color","white");
		$(this).css("color","#CFCDD3");
	}, function() {
		$(this).css("background-position","0px 0px");
		$(this).find('a').css("color","");
		$(this).children('.movie-list-image, .movie-list-image-combo, .movie-list-image-black, .movie-list-image-grey, .movie-list-image-none, .movie-list-image-custom').css("background-position","");
		$(this).css("color","");
	});
	$('.web-enabled').hover(function() {
		$(this).css("cursor","pointer");
		$(this).css("background-position","-664px -156px");
		$(this).find('a').css("color","white");
		$(this).css("color","#CFCDD3");
		$(this).children('.movie-list-image, .movie-list-image-combo, .movie-list-image-black, .movie-list-image-grey, .movie-list-image-none, .movie-list-image-custom').css("background-position","0px -124px");
	}, function() {
		$(this).children('.movie-list-image, .movie-list-image-combo, .movie-list-image-black, .movie-list-image-grey, movie-list-image-none, .movie-list-image-custom').css("background-position","");
		$(this).find('a').css("color","");
		$(this).css("background-position","-664px 0px");
		$(this).css("color","");
	});
	$('#inset-movie-list ul li.trailers').click(function() {
		$('#inset-movie-list ul li').unbind();
		var slug = $(this).parent().parent().attr('lang');	
		window.location=basehref+'hddvd/movies/'+slug+'/trailer/';
		
	});
	
	$('#inset-movie-list ul li').click(function() {
		var slug=$(this).attr('lang');
		var name=$(this).attr('class');
		if(typeof(slug) =='undefined') {
			slug = $(this).parent().parent().attr('lang');	
		}
		window.location.href=basehref+'hddvd/movies/'+slug+'/';
		return false;
	});
	
	/* 
	$('.accordion dt').hover(function() {
		var spot = $('.accordion dt').index(this);
		if(window.lastAccordion != spot) {
			$(this).css("cursor","pointer");
			$(this).css("background-position","0px -25px");
			$(this).children('a').css("color","#FFF");
		}

	}, function() {
		var spot = $('.accordion dt').index(this);
		if(window.lastAccordion != spot) {
			$(this).css("background-position","0px 0px");
			$(this).children('a').css("color","#666");
		}
	});
	
	$('.accordion dt').click(function() {
		var spot = $('.accordion dt').index(this);
		movieAccordion(spot);
		return false;
	}); */
	
	// Genre Subcategories
	$('#genre-body ul li').hover(function() {
			$(this).css("cursor","pointer");
			$(this).css("background-position","-299px -23px");
			$(this).find('a').css("color","#EEE");
		if($(this).attr("class") != 'checked') {
			$(this).css("background-position","-299px 0px");
		}
	}, function() {
			$(this).css("background-color","transparent");
			$(this).css("background-position","0px -23px");
		if($(this).attr("class") != 'checked') {
			$(this).css("background-position","0px 0px");
			$(this).find('a').css("color","#716E73");
		}
	});
	
	$('#genre-body ul li').click(function() {
		$(this).toggleClass("checked");
		if($(this).attr("class") == 'checked') {
			$(this).css("background-position","-299px -23px");
			$(this).find('a').css("color", "white");
		}
		else {
			$(this).css("background-position","-299px 0px");
		}
		return false;
	});
	
	// Movie Detail Mouseover
	$('#trailer-close').click(function() {
		$(this).parent().slideUp(400,"easeInOutQuad");
		return false;
	});
	
	// Movie Detail OS X only button
	if(BrowserDetect.OS == "Mac" ) {
		$('.video-flip4mac').css('display','block');
		$('#trailerflip4mac').css('display','block');
		$('.col-two').css('display','block');
        $('#trailers-mac').css('display','block');
	}
	
	$('.buttons .trailers').click(function() {
		if(window.animating != 1) {
			window.animating=1;
			$('#movie-trailers').slideToggle({duration: 400, easing: "easeOutQuad", complete: function() {window.animating=0;}});
		}
		return false;
	});
    
    $('.buttons .studiologo').hover(function() {
    	$('#blackout').css("display","none");
	}, function() {
    	$('#blackout').css("display","block");
	});
	
	$('#movie-box, #combo-box, #black-box, #grey-box, #no-box, #custom-box').hover(function() {
		$(this).css("cursor","pointer");
		$(this).css("background-position","0 -302px");
	}, function() {
		$(this).css("background-position","0px 0px");
	});
	
	// Movie Detail Tabs	
	$('#tab-features, #tab-content, #tab-synopsis').hover(function() {
		$(this).css("background-position","center -30px");
	}, function() {
		$(this).css("background-position","");
	});
	
	$('ul#tabs li').click(function() {
		var spot = $('ul#tabs li').index(this)+1;
		changeTab(spot);
		return false;
	});
	
	//Movie accordion features
	$('.video').hover(function() {
		$(this).css("background-position","0px -110px");
	}, function() {
		$(this).css("background-position","0px 0px");
	});	
	$('.accordion .photo').hover(function() {
		$(this).css("background-position","-151px -110px");
	}, function() {
		$(this).css("background-position","-151px 0px");
	});	
	
	// Manufacturer Subcategories 
	$('#manufacturer-body ul li').hover(function() {
		$(this).css("cursor","pointer");
		$(this).css("background-position","-299px -23px");
		$(this).find('a').css("color","#EEE");
		if($(this).attr("class") != 'checked') {
			$(this).css("background-position","-299px 0px");
		}
	}, function() {
		$(this).css("background-color","transparent");
		$(this).css("background-position","0px -23px");
		if($(this).attr("class") != 'checked') {
			$(this).css("background-position","0px 0px");
			$(this).find('a').css("color","#716E73");
		}
	});
	
	$('#manufacturer-body ul li').click(function() {
		$(this).toggleClass("checked");
		if($(this).attr("class") == 'checked') {
			$(this).css("background-position","-299px -23px");
			$(this).find('a').css("color", "white");
		}
		else {
			$(this).css("background-position","-299px 0px");
		}
		return false;
	});
	
	//Players Overview mouseover
	$('#inset-players ul li.player-type').hover(function() {
		$(this).css("cursor","pointer");
		$(this).css("background-position","0px -501px");
	}, function() {
		$(this).css("background-position","0px 0px");
	});
	
	$('#inset-players ul li#standalone').click(function() {
		window.location=basehref+'hddvd/players/stand-alone/';
	});
	$('#inset-players ul li#laptop').click(function() {
		window.location=basehref+'hddvd/players/laptops/';
		return false;
	});
	$('#inset-players ul li#xbox360').click(function() {
		window.location=basehref+'hddvd/players/xbox-360/';
		return false;
	});
	$('#inset-player-list ul li ul li.viewdetails').click(function() {
		$('#inset-player-list ul li').unbind("click");
		var link= $(this).find('a').attr("href")
		window.location= basehref+link;
		return false;
	});
	// Player List mouseover
	$('#inset-player-list ul li:has(ul)').hover(function() {
		$(this).css("cursor","pointer");
		$(this).css("background-position","0px -156px");
		$(this).find('a').css("color","white");
		$(this).css("color","#CFCDD3");
	}, function() {
		$(this).css("background-position","");
		$(this).find('a').css("color","");
		$(this).css("color","");
	});

	$('#inset-player-list > ul#standalone li').click(function() {
		var slug= $(this).attr("lang");
		window.location=basehref+'hddvd/players/stand-alone/'+slug+'/';
		return false;
	});
	$('#inset-player-list > ul#laptop li').click(function() {
		var slug= $(this).attr("lang");
		window.location=basehref+'hddvd/players/laptops/'+slug+'/';
		return false;
	});
	
	$('#inset-player-list .retailers').click(function() {
		window.open($(this).find('a').attr("href"));
		//window.location=basehref+$(this).find('a').attr("href")
		void(0);
        return false;
	});
	// Player Detail mouseover

	//Review Panel 
	$('.review-panel ul li:not(.review-panel ul li:last-child)').hover(function() {
		$(this).css("cursor","pointer");
		$(this).css("background-position","0px -100px");
		$(this).css("color","#FFFFFF");
	}, function() {
		$(this).css("background-position","");
		$(this).css("color","");
	});
	
	$('.review-panel ul li:last-child').hover(function() {
		$(this).css("cursor","pointer");
		$(this).css("background-position","-234px -100px");
		$(this).css("color","#FFFFFF");
	}, function() {
		$(this).css("background-position","");
		$(this).css("color","");
	});
	
	
	$('.review-panel ul li').click(function() {
		var href= $(this).find('a').attr('href');
		var trackTag = $(this).find('a').attr('rel');
		// track that link before opening in new window!
		urchinTracker(trackTag);
		window.open(href);
		return false;
	});	
	
	$('#player-pic').hover(function() {
		$(this).css("background-position","0px -226px");
	}, function() {
		$(this).css("background-position","0px 0px");
	});
	
	//Player enlarge 
	$('#player-pic, #player').hover(function() {
		$('#player').css("cursor","pointer");
		$('#player').css("background-position","right -35px");
	}, function() {
		$('#player').css("background-position","right 0px");
	});
	
	// News events
	$('#news-left li').hover(function() {
		$(this).css("cursor","pointer");
		$(this).find("a").css("color","#FFFFFF");
		$(this).find("em").css("color","#EEF4FD");
		$(this).css("background-position","0px -141px");
	}, function() {
		$(this).find("a").css("color","");
		$(this).find("em").css("color","");
		$(this).css("background-position","");
	});
	
	$('#news-left li').click(function() {
		var href = $(this).find('a').attr('href');
		//check for external links
		if(href.search('http') == -1)
			window.open(basehref+href);
        else
			window.open(href);
		// void prevents link following
        void(0);
	});

	$('#news-right #mailtout').hover(function() {
		$(this).find("a").css("color","#FFFFFF");
	}, function() {
		$(this).find("a").css("color","");
	});	
	
	$('#news-right #mailtout').click(function() {
		var href = $(this).find('a').attr('href');
		window.location=basehref+href;
	});
	
	$('#news-right #news-rss').hover(function() {
		$(this).find("a").css("color","#FFFFFF");
	}, function() {
		$(this).find("a").css("color","");
	});	

	$('#news-right #news-rss').click(function() {
		var href = $(this).find('a').attr('href');
		window.location=href;
	});
	
	$('#list-right #rss').hover(function() {
		$(this).find("a").css("color","#FFFFFF");
	}, function() {
		$(this).find("a").css("color","");
	});	
	$('#list-right #rss').click(function() {
		var href = $(this).find('a').attr('href');
		window.location=href;
	});
		
	$('#news-right ul li').hover(function() {
		$(this).find('.video').css("background-position","0px -110px");
		$(this).find("p").css("color","#FFFFFF");
	}, function() {
		$(this).find('.video').css("background-position","");
		$(this).find("p").css("color","");
	});	
	
	// Partners / Browser Detect Page
	$('#inset-partners ul li, #inset-safari ul li').hover(function() {
		$(this).css("background-position","0 -140px");
	}, function() {
		$(this).css("background-position","");
	});
	
	$('#offers-perfect-link').click(function() {
		$('#offers-perfect').unbind();
	});
	
	$('#offers-perfect').click(function() {
		var axel = Math.random()+"";
		var a = axel * 10000000000000;
		var html= '<img src="http://ad.doubleclick.net/activity;src=1350347;type=gener722;cat=rebat588;ord='+ a + '?" width="1" height="1" border="0">';
		$('body').append(html);
		window.location='http://www.thelookandsoundofperfect.com/_pdf/perfect_hd_dvd_offer_redemption_form.pdf';
	});
	$('.netflix-promo').click(function() {
		var axel = Math.random()+"";
		var a = axel * 10000000000000;
		var html= '<img src="http://ad.doubleclick.net/activity;src=1350347;type=gener722;cat=rebat588;ord='+ a + '?" width="1" height="1" border="0">';
		$('body').append(html);
		window.location='http://www.thelookandsoundofperfect.com/_pdf/perfect_hd_dvd_offer_redemption_form_netflix.pdf';
	});
	
	
		
});

/*--------------------------------
|        Calendar Functions      |
--------------------------------*/

function findMonth(month,dir) {
	var months=new Array();
		months[1]="January";
		months[2]="February";
		months[3]="March";
		months[4]="April";
		months[5]="May";
		months[6]="June";
		months[7]="July";
		months[8]="August";
		months[9]="September";
		months[10]="October";
		months[11]="November";
		months[12]="December";
	if(isNumeric(month)) {
		if(dir == '') {
			return months[month];	
		}
		if(dir == 'prev') {
			if(month==1)
				return months[11];
			else
				return months[month-1];
		}
		if(dir == 'next') {
			if(month==12)
				return months[1];
			else
				return months[month+1];
		}
		
	}
	
	if(dir == 'prev') {
		for (i=1;i<=12;i++) {
			if(months[i] == month) {
				if(i==1) {
					return months[12];	
				}
				else {
					return months[i-1];	
				}
			}
		}
	}
	if(dir == 'next') {
		for (i=1;i<=12;i++) {
			if(months[i] == month) {
				if(i==12) {
					return months[0];	
				}
				else {
					return months[i+1];	
				}
			}
		}
	}
	return false;
}

function formatDay (day) {
	if (day == 1 || day == 21 || day ==31)
	   return day + "st";
	else if (day == 2 || day == 22)
	  return day + "nd";
	else if (day == 3 || day == 23)
	   return day + "rd";
	else
	   return day + "th";
	return false;
}


/*--------------------------------
|       Utility  Functions       |
--------------------------------*/

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function qsReplace(a,k,v) {
   var re = new RegExp("([?|&])" + k + "=.*?(&|$)","i");
   if (a.match(re))
       return a.replace(re,'$1' + k + "=" + v + '$2');
   else {
	   	if(a.indexOf('?') == -1) {
       		return a + '?' + k + "=" + v;
		}
		else {
			return a + '&' + k + "=" + v;
		}
   }
}

function fixheight(section,offset) {
	/*$('#movie-detail-left').css('height','');
	var height = $(section).height() + offset;
	$('#movie-detail-left').css('height',height);
	return false; */
}

function isNumeric(sText) {
   var validChars = "0123456789.";
   var isNumber=true;
   var char; 
   for (i = 0; i < sText.length && isNumber == true; i++) 
      { 
      char = sText.charAt(i); 
      if (validChars.indexOf(char) == -1) 
         {
         isNumber = false;
         }
      }
   return isNumber;
}

/*--------------------------------
|      Navigation Functions      |
--------------------------------*/

//Subnavigation 
function navigateTo(selection, fromsection) {
	//Reset any other mousehover effects
	var globalNav = '#gnav-' + window.selection;
	var globalSpace = globalOffset(window.selection)
	var gOffset = globalSpace * -160 +'px 0px';
	$(globalNav).css("background-position",gOffset);

	window.selection = selection
	var globalNav = '#gnav-' + selection;
	var globalSpace = globalOffset(selection)
	var gOffset = globalSpace * -160 +'px -30px';
	$(globalNav).css("background-position",gOffset);
	if(window.finished == 0) {
		window.finished = 1;
		//Hover is in JS and CSS, to keep hover down on subNav AND Global, CSS users will still get hovers
		//Calculate background offset for bg gradient
		var space = navOffset(selection);
		var offset = '0px '+ space * -58 +'px';
		// Create subnav ID selector
		var subNav = '#subnav-' + selection;
		// Hide everything that's not current subNav
		var selector = '#navigation #subnav ul:not(\'' + subNav + '\')';
		$(selector).hide();
		//Fade in new nav and background
		$('#navigation').css("background-position",offset);
		$(subNav).fadeIn('fast');
		setTimeout('window.finished=0;',25);
	}
}

function navigateAway(selection) {
	/* Have to redo hover on mouseaway to compensate for css
	var globalNav = '#gnav-' + window.selection;
	var globalSpace = globalOffset(selection)
	var gOffset = globalSpace * -160 +'px -30px';
	$(globalNav).css("background-position",gOffset); */
}

function clearNav(currentSection) {
	//Create subNav ID selector
	var subNav = '#subnav-' + currentSection;
	//Reset global hover state 
	var globalNav = '#gnav-' + window.selection;
	var globalSpace = globalOffset(window.selection)
	var gOffset = globalSpace * -160 +'px 0px';
	$(globalNav).css("background-position",gOffset);
	//Reset background position (section dependent) 
	var space = navOffset(currentSection);
	var offset = '0px '+ space * -58 +'px';
	$('#navigation').css("background-position",offset);
	
	//Hide all sections except current section only if current section isnt hovered
	var lastSection = '#'+$('#navigation #subnav ul:visible').attr('id');
	if(lastSection != subNav) {
		var $visible= $('#navigation #subnav ul:visible');
		if(navOffset(window.section) == 0) {
			$('#subnav ul').fadeOut("fast");
		}
		else {
			$visible.hide('');
		}
		//Fade in original navigation
		$(subNav).fadeIn();
	}
}

function navOffset(selection)
{
	// 0 means no background switch and no submenu
	switch(selection) {
	case "home":
	var space = 0;
	break;
	case "about":
	var space = 2;
	break;
	case "movies":
	var space = 3;
	break;
	case "players":
	var space = 4;
	break;
	case "news":
	var space = 5;
	break;
	case "offers":
	var space = 0;
	break;
	}	
	return space;
}

function globalOffset(selection)
{
	switch(selection) {
	case "home":
	var space = 0;
	break;
	case "about":
	var space = 1;
	break;
	case "movies":
	var space = 2;
	break;
	case "players":
	var space = 3;
	break;
	case "news":
	var space = 4;
	break;
	case "offers":
	var space = 5;
	break;
	}	
	return space;
}

	/*--------------------------------
	|      Accordion Functions       |
	--------------------------------*/

function homeAccordian(position) {
	switch(position) {
	case '1':
	//Fix mousedowns
	window.accdown=1;
	$('#releases-header a').css("background-position","0px -75px");
	$('#coming-header a').css("background-position","0px 0px");
	$('#updates-header a').css("background-position","0px 0px");
	//Transitions
	$('#releases-content').slideDown();
	$('#coming-content').slideUp();
	$('#updates-content').slideUp();
	break;
	case '2':
	window.accdown=2;
	$('#releases-header a').css("background-position","0px 0px");
	$('#coming-header a').css("background-position","0px -75px");
	$('#updates-header a').css("background-position","0px 0px");
	$('#releases-content').slideUp();
	$('#coming-content').slideDown();
	$('#updates-content').slideUp();
	break;
	case '3':
	window.accdown=3;
	$('#releases-header a').css("background-position","0px 0px");
	$('#coming-header a').css("background-position","0px 0px");
	$('#updates-header a').css("background-position","0px -75px");
	$('#releases-content').slideUp();
	$('#coming-content').slideUp();
	$('#updates-content').slideDown();
	break;
	}
	return false;
}


/* function movieAccordion(spot) {
	//Selects content and title from current index
	var selector = '.accordion dd:eq('+spot+')';
	var titleSelector = '.accordion dt:eq('+spot+')';
	var thisTitle = $(titleSelector);
	var showThis = $(selector);
	//Hides all items visible that aren't currently being opened
	var hideThis = $(".accordion dd:visible").not($(selector));
	//Mouse down background change for title
	thisTitle.css("background-position","0px -50px");
	//Resets FX on lastAccordion
	if(spot != window.lastAccordion) {
		var lastTitleSelector = '.accordion dt:eq('+window.lastAccordion+')';
		$(lastTitleSelector).css("background-position","0px 0px");
		$(lastTitleSelector).find('a').css("color","#666");
	}
	//Sets this index as lastAccordion to reset animations next go-around
	window.lastAccordion = spot;
	//FX are processed last to ensure CPU usage lowest
	hideThis.slideUp();
	showThis.slideDown();
} 

Alternate function for Accordion, more verbose
function movieAccordion(position, totalNumber) {
	var counter = 0;
	var openSelector = '.accordion dd:eq('+position+')';
	var openTitleSelector = '.accordion dt:eq('+position+')';
	while(counter < totalNumber) {
		var titleSelector = '.accordion dt:eq('+counter+')';
		var selector = '.accordion dd:eq('+counter+')';
		var visibleSelector = '.accordion dd:eq('+counter+'):visible';
		if($(visibleSelector).size() != 0) {
				var closeSelector = selector;
				var closeTitleSelector = titleSelector;
			}
		counter++;
	}
	$(closeSelector).slideUp();
	$(closeTitleSelector).css("background-position","0px 0px");
	$(openSelector).slideDown();
	$(openTitleSelector).css("background-position","0px -50px");
}  */

	/*--------------------------------
	|       Page Tab Functions       |
	--------------------------------*/

function changeTab(choice){
	// Hides content of previously selected tab, 'i' in anon function is index of this
	$("ul#tabs li").each(function (i) {
		if($(this).is('.selected')) {
			var lastTab =	'#tab'+(i+1);
			$(lastTab).hide();
		}
	});
	var $last = $('ul#tabs li.selected');
	var lastChoice = $('ul#tabs li').index($last)+1;
	var lastSelector ='#tab'+lastChoice;
	$(lastSelector).hide();
	// Hides previously selected tabs
	$('ul#tabs li').removeClass("selected");
	//Sets down-state on choice tab
	var selector= 'ul#tabs li:nth-child('+choice+')'
	$(selector).addClass("selected");
	// Shows new content 
	var currentSelector = '#tab'+choice;
	$(currentSelector).show();
	/*if($('#movie-detail-right').height() > $('#movie-detail-left').height()) {
		$('#movie-detail-left').css('height',$('#movie-detail-right').height());
	}*/
}

	/*--------------------------------
	|        Marquee Functions       |
	--------------------------------*/


function initMarquee() {
	//Cycles through each element (starts with UI to reuse DOM traversal from moveMarquee) and adjusts UL to be width of all elements, then activates controls for JS browsers.
	$('.ui-right').each(function() {
		if($(this).parent().attr("class") != 'inset-menu-arrows') {
			var pixelsPerScreen = $(this).parent().parent().next().width();
			var itemsPerScreen = $(this).parent().parent().next('.marquee').attr("lang");
			var id = $(this).parent().parent().next('.marquee').attr("id");
			var ulid= '#'+id+ ' ul';
			var liid= '#'+id+ ' ul li';
			var numItems = $(liid).size();
			var pages = Math.ceil(numItems / itemsPerScreen);
			if(pages > 1) { 
				$(this).next().css("display","none");
				$(this).css("display","block");
			}
			else {
				$(this).next().css("display","block");
				$(this).css("display","none");
			}
		 }
	});
}

function autoMarquee(i) {
	if(i==1) {
		moveMarquee('right',$('#movie-featured-header .ui-right'),1);	
	}
	window.scroller=window.setTimeout(function() {autoMarquee(1);}, 8000);
}

function moveMarquee(direction,$this,endScroll) {
	if(window.animating != 1) {
		if(endScroll != 1) {
			window.clearTimeout(window.scroller);	
		}
		//Grabs relevent information from $this
		var pixelsPerScreen = $this.parent().parent().next('.marquee').width();
		var itemsPerScreen = $this.parent().parent().next('.marquee').attr("lang");
		// IMPORTANT * CSS '.MARQUEE' TITLE ATTRIBUTE is # of items to show 
		var id = $this.parent().parent().next('.marquee').attr("id");
		var ulid= '#'+id+ ' ul';
		var liid= '#'+id+ ' ul li';
		//Calculates number of items and pages
		var numItems = $(liid).size();
		var pages = Math.ceil(numItems / itemsPerScreen);
		//finds pixels from left, absolute value because neg pixels used to push
		var margin = Math.abs(parseInt($(ulid).css("marginLeft")));
		//calculate total pixels of Marquee
		var pixelAmount = pages * pixelsPerScreen;
		//Moves marquee, prev/next is used to select arrows by DOM location in this order: left,left-off,right,right-off 
		if(direction == 'left' && margin != 0) {
			var pixelCount = '+='+pixelsPerScreen;
			if(margin - pixelsPerScreen == 0) {
				$this.css("display","none");
				$this.next().css("display","block");
			}
			$this.next().next().css("display","block");
			$this.next().next().next().css("display","none");		
		}
		
		if(direction == 'right') {
			if(margin != (pixelAmount - pixelsPerScreen)) {
				//new position is current + pixels per screen
				var pixelCount = -(pixelsPerScreen);
				if(	margin + (2 * pixelsPerScreen) == pixelAmount) {
					$this.css("display","none");
					$this.next().css("display","block");
				}
				var pixelCount = '-='+pixelsPerScreen
				$this.prev().prev().css("display","block");
				$this.prev().css("display","none");
			}
			//Only autoscroller will trigger this, resets position to zero
			else {
				$this.css("display","block");
				$this.next().css("display","none");
				$this.prev().prev().css("display","none");
				$this.prev().css("display","block");
				window.animating=1;
				$(ulid).animate({ marginLeft: 0}, 700,"easeOutQuad",function() {window.animating=0;} );
				return;
			}
		}
		window.animating=1;
		$(ulid).animate({ marginLeft: pixelCount}, 700,"easeOutQuad",function() {window.animating=0;} );
	}
}

//Function called by flash movie to advance overview marquee
function nextMarquee(spot) {
		//Stupid IE6 problems with classname DOM manip 
		$('.selected-movie').css("background-position","");
		$('.selected-movie').find('a').css("color","");
		$('.selected-movie').removeClass('selected-movie');
		var selector = '#overview-marquee ul li:nth-child('+spot+')';
		$(selector).css("background-position","0px -99px");
		$(selector).addClass('selected-movie');
		if(spot % 5 == 1 && spot != 1) {
			moveMarquee('right',$('#overview-right .ui-right'));
		}
		if(spot == 1) {
			$this=$('#overview-right .ui-right');
			if($this.prev().prev().css("display") == 'block') {
				$this.css("display","block");
				$this.next().css("display","none");
				$this.prev().prev().css("display","none");
				$this.prev().css("display","block");
				window.animating=1;
				$('#overview-marquee ul').animate({ marginLeft: 0}, 700,"easeOutQuad",function() {window.animating=0;} );
			}
		}
		
}

	/*--------------------------------
	|     Movie Search Functions     |
	--------------------------------*/
	
function findValue(li) {
}

function selectItem(li){
	var slug = $(li).find('.id').text();
	if(slug != '') {
		// Event tracking
			var length = slug.length;
			var title = slug.substr(0, length-1).substr(13);
			liveSearch._trackEvent('Search-Clickthrough', title);
		window.location=basehref+slug;
	}
}

function formatItem(row) {
	if(row[2] == 'Web') {
		var format = '<div class="id">'+row[3]+'</div>\n<img src="_img/hddvd/catalog/'+row[4]+'-xsmall.jpg" alt="'+row[0]+'" /> '+row[0] +'<br><b>'+row[1]+', </b><em>Web Enabled</em>';
	}
	else {
		var format = '<div class="id">'+row[3]+'</div>\n<img src="_img/hddvd/catalog/'+row[4]+'-xsmall.jpg" alt="'+row[0]+'" /> '+row[0] +'<br><b>'+row[1]+'</b>';
	}
	/* Special case for no results */
	if(row[3] == '1337') {
		var searchterm = $("#movie-search-box").val();
		liveSearch._trackEvent('Search-Returned-No-Results', searchterm);
		var format = '<img width="25" height="30" src="_img/hddvd/catalog/placeholder-xsmall.jpg" alt="No Results" /> '+row[0]+'<br><b>'+row[1]+'</b>';		   
  	}
	return format;
}
