share.url = "http://www.AffirmFilms.com";share.title = "Affirm Films - Official Site ";share.description = "Affirm Films presents quality entertainment that encourages, uplifts, challenges and entertains. Family films, thought-provoking documentaries, children's entertainment and timeless stories that will move and inspire viewers and deliver on the promise of wholesome and trusted entertainment.";share.tweet = "Check out what's new at http://www.AffirmFilms.com! @affirmfilms";//carousel videosfeedUrl = "http://www.sonypictures.com/homevideo/affirmfilms/Guides/flashxml/trailers.xml"; //overlayPlayer configautocloseToggle = true; singlevideoToggle = true; useQAplayer = true;displayBuyLink = false;displayShare = false;function shareLinks() {	$('ul#share li a').bind('click',function(){		share.send($(this).attr('rel'));		return false;	});}function regPop() {	$('a#register').bind('click', function() {		//sCode.trackFeaturedContentClick(this.href,'register_button');		displayWindow(this.href,'registration',450,492,'scrollbars=0');				return false;	});}function watchClip() {	$('a.watch-trailer').bind('click', function() {		var clip = $(this).attr('rel')		openOverlay(clip);		return false;	});}function initBannerCarousel() {	$('#home-carousel').jCarouselLite({		'btnPrev': 'a#button-previous',		'btnNext': 'a#button-next',		'hoverPause': 'true', 		'auto'	: 8000,		'visible': 1,		'speed'	: 800    });}function initPosterCarousel() {	$('#poster-carousel').jCarouselLite({		'btnPrev' : 'a#button-previous',		'btnNext' : 'a#button-next',		'circular' : false,		'visible' : 5,		'speed' : 500    });}function initCufon() {	if($('.interstate-LightCondensed').length){		Cufon.replace('.interstate-LightCondensed',{			'fontFamily':'interstate-LightCondensed'		});			}	if($('.interstate-BlackCondensed').length){		Cufon.replace('.interstate-BlackCondensed',{			'fontFamily':'interstate-BlackCondensed'		});			}	if($('.interstate-RegularCompressed').length){		Cufon.replace('.interstate-RegularCompressed',{			'fontFamily':'interstate-RegularCompressed'		});			}}function hoverSubnav() {	$('ul#navigation li').hover(        function(){ 			$('ul.subnav', this).fadeIn('fast'); 					},         function(){ 			$('ul.subnav', this).fadeOut('fast'); 					}    );	if (document.all) {			$('ul#navigation li').hoverClass('sfHover');	}		//disable topnav clicking	$('ul#navigation li a.topnav-disable').click(function(){		return false;	});}jQuery.fn.extend({	hoverClass : function(c) {		$(this).hover(			function(){ $(this).addClass(c) },			function(){ $(this).removeClass(c) }		);		return this;	}});function parallelList(){	/* 			Makes styling two column lists easier to style.		On (ol/ul) lists, add class="parallel-list".		Set background color with li.everytwo in the CSS for each row.		Set spacing between columns with li.odd in the CSS.	*/		/*	//completes list if there is an odd number of list items. WORKS!	var listCount = $(".parallel-list li").size();	if(listCount%2){		$('.parallel-list').append('<li><a href="#" style="visibility: hidden;">&nbsp;</a></li>');	}	*/		$('.parallel-list > li:nth-child(4n)').addClass('everytwo');	$('.parallel-list > li:nth-child(4n-1)').addClass('everytwo');	$('.parallel-list > li:nth-child(odd)').addClass('odd');		}function enableTooltip(){	$('.enable-tooltip').tooltip({ 		effect: 'slide',	//IE png fix in 'slide-effect'		direction: 'left',		predelay: 300,		slideOffset: 0,		position: 'center right'	}).dynamic({ 	//dynamic positioning for small screen sizes			left: { 				direction: 'left', 				bounce: true 				}		});	}function initBonusScreen(){	$('a[rel="activate-screen"]').click(function(){		$(this).addClass('selected');		$('.bonus-screen').fadeIn('slow');		return false;	});		$('a[rel="close-screen"]').click(function(){		$(this).removeClass('selected');		$('.bonus-screen').fadeOut('slow');		return false;	});}function initSwitchaRoo(){	$('a.switcharoo').click(function(){		var switcharooContent = $(this).attr('href');		/* alert(switcharooContent); */				//fades out children specifically for IE		if(jQuery.browser.msie){			$('.switcharoo-default').fadeOut('slow');			$('.switcharoo-default').children().fadeOut('slow');			$('.switcharoo-content').fadeOut('slow');			$('.switcharoo-content').children().fadeOut('slow');		}else{			$('.switcharoo-default').fadeOut('slow');			$('.switcharoo-content').fadeOut('slow');		}				//fades in children specifically for IE		if(jQuery.browser.msie){			$(switcharooContent).fadeIn('slow');			$(switcharooContent).children().fadeIn('slow');		}else{			$(switcharooContent).fadeIn('slow');		}		$('.bonus-screen').hide();		return false;	});	}function undoBind() {	$('#static-links a').unbind();		$('#static-links a').bind('click', function(e) {		e.stopPropagation();	});}function initLeaveNotice(){	$('a[rel=leave-notice]').leaveNotice({		timeOut:0,		overlayAlpha:0.8,		exitMessage:'<h3 class="sprite">Affirm Films | Exit Notice</h3><p class="sprite">You are now leaving Affirm Films on sonypictures.com</p><p class="sprite">Click on link if you are sure you want to leave, otherwise click cancel.</p>',		preLinkMessage:'<p id="ln-leaveMessage">{URL}</p>'	});		$('p#ln-leaveMessage a').attr('target', '_blank');}//begin repurpose	function initOverlay(){		$('a[rel="overlay"]').click(function(){			var url = $(this).attr('href');			getTracking(url);			//overlayFacebookGenerator(url);			constructOverlay(url);			return false;		});				$('a[rel="close_overlay"],.overlay').click(function(){			destroyOverlay();			return false;		});	}	function getTracking(url){		var result = url.split('catalog/');				s.pageName = "us:homevideo:affirmfilms:catalog:" + result[1];		s.channel = s.eVar3 = "us:homevideo";		s.prop3 = "us:homevideo:affirmfilms";		s.prop4 = s.eVar4 = "us:affirmfilms";		s.prop5 = s.eVar5 = "us:homevideo:affirmfilms:catalog";		s.prop11 = "us";		/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/		var s_code = s.t();		if (s_code) {			document.write(s_code);		}	};	function overlayFacebookGenerator(url){		var windowLocation = window.location.href;	//gets URL in browser window		var lastSlash = windowLocation.lastIndexOf('/'); 	//find index of last slash		var currentURL = windowLocation.slice(0,lastSlash);	//strips out everything after last slash in browser URL (not including trailing slash)		var parentURL = currentURL.slice(0,(currentURL.lastIndexOf('/')+1));	//up one directory from currentURL (including trailing slash)		var catalogPage = url.split('../')[1]; //removes the "../" from the clicked url path to the catalog page		var absoluteCatalogPage = parentURL + catalogPage; //absolute path to the catalogpage				var recommendButton = '<div class="facebook-recommend"><iframe src="http://www.facebook.com/plugins/like.php?href='+encodeURIComponent(absoluteCatalogPage)+'&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;font&amp;colorscheme=dark&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="true"></iframe></div>';			return recommendButton;	}		function constructOverlay(url){			//create overlay elements		$('.overlay').show();				//set overlay property		var windowwidth = $(window).width();		var windowheight = $(document).height();		$('.overlay').css({			'width': windowwidth + 'px',			'height': windowheight + 'px'		});				//generate overlay content		$('#overlaycontent').load(url +' #catalogitem', function(response, status, xhr){			if(status == 'error'){				alert('An error has occurred. Catalog page may not exist. \nPlease check console for details.');				destroyOverlay();				return false;			}						//getTracking(url);						//fades in overlay container			$('.overlaycontainer').fadeIn('slow');			$('#overlaycontent .catalog-content').prepend(overlayFacebookGenerator(url));			generateUniveralPlayer();			scrapeURL();			//why?			var syn = $('#overlaycontent .synopsis').height();			$('#overlaycontent .cast').css('top', syn + 355);			syn += $('#overlaycontent .cast').height();			var containerHeight = $(window).height();			$('.overlaycontainer').css({				'right': windowwidth / 2 - $('.overlaycontainer').width() / 2 + 'px',				'bottom': containerHeight / 2 - $('.overlaycontainer').height() / 2 + 'px'			});			$('.overlay #bottomlinks').css({				'right': windowwidth / 2 - $('.overlaycontainer').width() / 2 + 'px',				'bottom': ((containerHeight / 2 - $('.overlaycontainer').height() / 2) - 33) + 'px'			});			setBuyLink();		});				function checkImage(URL) {			var tester=new Image();			tester.onLoad=isGood;			tester.onError=isBad;			tester.src=URL;		}		function isGood() {			alert('That image exists!');		}		function isBad() {			alert('That image does no exist!');		}		function setBuyLink(){			$('#overlaycontent .metalinks a[rel=leave-notice]').attr('target', '_blank');			$('#overlaycontent .metalinks a.order').click(getOrderOmnitureVars);		}						// FUTURE UPDATES FOR OPTIMIZATION -- talk to CMS team and see if we can generate content ie:		// "buy it now", "preorder now", "videofeed", "visitthesite", "discussionguide" locally 		// so we don't have to scrape the catalogpage in order to generate the overlay for efficiency.		function scrapeURL(){					//scrapes metailnks from catalog pages			var buyitnow = $('#overlaycontent .metalinks a#buyitnow').attr('href');			var preordernow = $('#overlaycontent .metalinks a#preordernow').attr('href');			var videofeed = $('#overlaycontent .metalinks a#videofeed').attr('href');			var visitthesite = $('#overlaycontent .metalinks a#visitthesite').attr('href');			var disscussionguide = $('#overlaycontent .metalinks a#disscussionguide').attr('href');						//scrapes boxart from catalog pages			var boxartIMG = $('img#side-boxart').attr('src');			$('img#side-boxart').attr('src', boxartIMG);						if(visitthesite !== undefined && disscussionguide === undefined){				$('.overlay').html(					'<div id="bottomlinks">' + 						'<ul id="static-links">' +							'<li><a class="" target="_blank" id="overlay-visitthesite" href="'+visitthesite+'"><img src="../images/button-overlay-visitthesite.jpg" alt="Visit Movie Site" /></a> ' +						'</ul>' +					'</div>'				);				undoBind();			}else if(disscussionguide !== undefined && visitthesite === undefined ){				$('.overlay').html(					'<div id="bottomlinks">' + 						'<ul id="static-links">' +							'<li><a class="" target="_blank" id="overlay-disscussionguide" href="'+disscussionguide+'"><img src="../images/button-overlay-disscussionguide.jpg" alt="Download Free Discussion Guide" /></a> ' +						'</ul>' +					'</div>'				);				undoBind();			}else if(visitthesite !== undefined && disscussionguide !== undefined){				$('.overlay').html(					'<div id="bottomlinks">' + 						'<ul id="static-links">' +							'<li><a class="" target="_blank" id="overlay-disscussionguide" href="'+disscussionguide+'"><img src="../images/button-overlay-disscussionguide.jpg" alt="Download Free Discussion Guide" /></a> ' +							'<li><a rel="leave-notice" target="_blank" id="overlay-visitthesite" href="'+visitthesite+'"><img src="../images/button-overlay-visitthesite.jpg" alt="Visit Movie Site" /></a> ' +						'</ul>' +					'</div>'				);				undoBind();			}else{				$('.overlay').html('');			}						//adding download tracking ot the generated overlay pdf			$('a#overlay-disscussionguide').bind('click', function(){				sCode.trackDownload('disscussion_guide');			});					}				function generateUniveralPlayer(){			//generate universal player in overlay			var universalPlayerOverlay = $('#universalPlayerOverlay').html();	//loads universalPlayerOverlay div into string			var videofeedURL = $('#overlaycontent #videofeed').attr('href');	//scraps videofeed from overlay catalog page						if(videofeedURL !== undefined){				var embedUniversalPlayer = universalPlayerOverlay.replace('#scrape-videoFeedURL', videofeedURL); //loads videofeedURL from overlay catalog page into universalPlayerOverlay				$('#overlaycontent #videoplayerwrapper').prepend(embedUniversalPlayer);			}else {				alert('An error has occurred. Please check that videofeed xml is available on the catalog page.')			}		}			};	function destroyOverlay(){				$('#overlaycontent #videoplayer').replaceWith( '' );		$('.overlay').html( '' );		var PARENT_PAGE = '';		$('.overlay').hide();		$('.overlaycontainer').hide();				$('#flashContainer').html(' ');			};//end repurpose$(document).ready(function(){		initBannerCarousel();	initCufon();	hoverSubnav();	regPop();	initSwitchaRoo();	parallelList();	initBonusScreen()	enableTooltip();	initOverlay();	shareLinks();	watchClip();	initLeaveNotice();});
