if ( !generalFunctions ) var generalFunctions = {
	
	serverFeedback: {	x:0, 
						y:0, 
						message:"",
						show:function(){
		
									var feedbackContainer = document.getElementById('serverFeedback');
									feedbackContainer.style.left = generalFunctions.serverFeedback.x + "px";
									feedbackContainer.style.top = generalFunctions.serverFeedback.y + "px";
									document.getElementById('serverFeedbackMessage').innerHTML = generalFunctions.serverFeedback.message;
//									feedbackContainer.style.opacity = 1;	
									var feedbackTweenIn = new OpacityTween(feedbackContainer, Tween.regularEaseIn, 0, 100, 1);
								
									feedbackTweenIn.onMotionFinished = window.setTimeout(function(){
										
										var feedbackTweenOut = new OpacityTween(feedbackContainer, Tween.regularEaseOut, 100, 0, 1);
										feedbackTweenOut.onMotionFinished = function(){
											
											feedbackContainer.style.left = "0px";
											feedbackContainer.style.top = "0px";
											generalFunctions.serverFeedback.x = 0;
											generalFunctions.serverFeedback.y = 0;
											generalFunctions.serverFeedback.message = "";
											document.getElementById('serverFeedbackMessage').innerHTML = "";
										}
										feedbackTweenOut.start();
										
										
									},2000);
									
									feedbackTweenIn.start();
						}
	},
	miniCollageRollover: {	x					: 0, 
							y					: 0,
							title				: "",
							uniqueName			: "",
							synopsis			: "",
							watchIt				: "",
							tempImage			: "",
							image				: "",
							link				: "",
							year				: "",
							availabilityString	: "",
							dispalayInterval 	: null,
							show				: function(){
								
													var rollover = document.getElementById('SimilarMovieRODiv');
													
													document.getElementById('sm_divTitle').innerHTML = generalFunctions.miniCollageRollover.title;
													document.getElementById('sm_divTitle').title = generalFunctions.miniCollageRollover.title;
													
													document.getElementById('sm_divYear').innerHTML = "(" + generalFunctions.miniCollageRollover.year + ")";
													document.getElementById('miniRolloverSynopsis').innerHTML = generalFunctions.miniCollageRollover.synopsis + " " + "<label><a href='/movies/"  + generalFunctions.miniCollageRollover.uniqueName + "/' class='smallinks'>overview</a></label>";
													
													document.getElementById('mcRollOverImage').src = generalFunctions.miniCollageRollover.tempImage;
													document.getElementById('mcRollOverImage').src = generalFunctions.miniCollageRollover.image;
												
													document.getElementById('photoLinkToContent').href = "/movies/"  + generalFunctions.miniCollageRollover.uniqueName + "/";
													document.getElementById('linkToOnline').href =  "/movies/"  + generalFunctions.miniCollageRollover.uniqueName + "/watch-it/";
													
													for( x=0; x<6; x++ ){
														var theIcon = document.getElementById('sm_availableIcon' + x);
														if ( generalFunctions.miniCollageRollover.availabilityString.charAt(x) == 1 ){
															theIcon.style.display = 'inline-block';
														}
														else
														{
															theIcon.style.display = 'none'
														}
													}
													
													rollover.style.left = generalFunctions.miniCollageRollover.x + "px";
													rollover.style.top = generalFunctions.miniCollageRollover.y + "px";
													
													
													var feedbackTweenIn = new OpacityTween(rollover, Tween.regularEaseIn, 0, 100, 1);
													
													feedbackTweenIn.onMotionStarted = function(){
														rollover.style.display = "block";
													}
													feedbackTweenIn.start();
								
													}
	},
	contentImageInfo: function(title,year,uniqueName,synopsis,watchIt,image,link,availabilityString){
		
							this.title				= title;
							this.year				= year;
							this.uniqueName			= uniqueName;
							this.synopsis			= synopsis;
							this.watchIt			= watchIt;
							this.image				= image;
							this.link				= link;
							this.availabilityString	= availabilityString;
		
		
	},
	contentImageInfoHash : new utils.Hash()
	
};
if(!sessionConfigCookie) var sessionConfigCookie = 	{
	
							COOKIE_NAME 			: "sconfig",
							LITERAL_VALUE			: -1,
							INVITATION_REQUESTED	: 0,
							CLOUD_DESCRIPTION		: 1,
							GLOBAL_FILTER			: 2, //NOT IN USE AS YET
							HOME_PAGE_MENU			: 3, //NOT IN USE AS YET
							HOME_HEADER				: 4, //NOT IN USE AS YET
							NETFLIX_HOME_MESSAGE	: 5, //NOT IN USE AS YET
							
							setValue : function(field, value){
								
										var val = getCookieValue(sessionConfigCookie.COOKIE_NAME);
										var valArr = val.split("");
										if( field > valArr.length)
										{
											for(i=valArr.length; i < field; i++)
											{
												valArr[i] = 0;
											}
										}
										valArr[field] = value;
										val = valArr.toString().replace(/,/g,'');
										setPersistanteCookie(sessionConfigCookie.COOKIE_NAME, val, 1000*3600*24*30,null);		
								
							},
							getValue : function(field){
								
									if( field == sessionConfigCookie.LITERAL_VALUE)
									{
											return getCookieValue(sessionConfigCookie.COOKIE_NAME);
									}
									else
									{
											var val = getCookieValue(sessionConfigCookie.COOKIE_NAME);
											var valArr = val.split("");
											return valArr[field];
											
									}
								}
							}


if ( !nflxFucntions ) var nflxFucntions = 	{	nflxID				: "",
												integrationStatus	: null,
												nflxMovieParams 	:{ allowScriptAccess: "always", menu: "false" },
												nflxMovieAtts		:{ id: "nflxIntegrationPlayer" },
												nflxMovieList		:	[	
												             		 	 	{movieID: "gXY9TuuwyL8", movieTitle: "Monty Python and the Holy Grail - The Black Knight fight"},
																			{movieID: "xX85Y5Zb7sw", movieTitle: "Fawlty Towers - I speak English, I learnt it from a book"},
																			{movieID: "JgOxqwVd5Z8", movieTitle: "Bananas - Trying to buy a nudie magazine"},
																			{movieID: "m7mIy97_rlo", movieTitle: "A Fish Called Wanda - Apologies"},
																			{movieID: "OaiSHcHM0PA", movieTitle: "Jerry Maguire - Show Me the Money"},
																			{movieID: "RDADTMqDDL8", movieTitle: "When Harry Met Sally - You don't think that I can tell the difference?"}																			
																		],
												nflxMovieCounter	: -1
											};

if ( !globalVariables ) var globalVariables = {
													contentDetailsSlider: null,
													contentDetailsSliderInitialStatus: null,
													sliderRateObject: {rated: false, rate: null,likelyOrNotInterested: null,suggested: null},
													isUserSignIn: false,
													content: {id: null, uniqueName: null, displayTitle: null},
													person: {displayName: null},
													wantedToInvite: false,
													user: {userId: null, userName: ""}
												
												};
											
if ( !banners ) var banners = {};

if( !homeRecentActive ) var homeRecentActive = {users: new Array()};

if( !ajaxSessionRefresher ) var ajaxSessionRefresher = {
	
	disableSessionRefresh: false,
	MAX_REQUESTS : 12,
	inverval: 5*60*1000,
	counter: 0,
	start: 
			function(){window.setInterval(function(){
			
				if( !ajaxSessionRefresher.disableSessionRefresh &&  globalVariables.user.userName != "" &&  ajaxSessionRefresher.counter < ajaxSessionRefresher.MAX_REQUESTS )
				{
					ajaxSessionRefresher.incrementCounter();
					
					ajaxRefresher.refreshSession(
					{
						callback:function(reset){
							
								if(reset){ajaxSessionRefresher.resetCounter();}
								
								}
					});
				}
					},ajaxSessionRefresher.inverval)},
	
	resetCounter: 		function(){ajaxSessionRefresher.counter = 0;},
	incrementCounter: 	function(){ajaxSessionRefresher.counter++ ;}
};

													
/************* Show/Hide collage rollover container *************/
function action(obj) {
	var floatingDiv = obj;
	document.getElementById('collage_ro').style.left = getPosX(floatingDiv) - 10;
    document.getElementById('collage_ro').style.top  = getPosY(floatingDiv) - 10;
	document.getElementById('collage_ro').style.padding = 10 ; 
	document.getElementById('collage_ro').style.display = 'inline';
}

function collageOut() {
	document.getElementById('collage_ro').style.display = 'none';
}

/******** embed menu *********/1

function selectText(){
	document.embedForm.urlText.focus();
	document.embedForm.urlText.select();
}

function toggleNotSeenItPopup()
{
	var popup = document.getElementById('notSeenItPopup');
	
	if( popup.style.display == 'block')
	{
		popup.style.display = 'none';
		return;
	}
	
	var slider = document.getElementById('ratingSlider');

	popup.style.left = ( getPosX( slider ) -24 ) + "px";
	popup.style.top = ( getPosY( slider ) - 15 ) + "px";
	
	popup.style.display = 'block';

}

function showLikelyToSee()
{
	document.getElementById('rolloverNotSeenIt').style.display = 'none';
	document.getElementById('rolloverNotForMe').style.display = 'none';
	document.getElementById('notSeenItPopup').style.display = 'none';
	document.getElementById('rolloverLikelyToSee').style.display = 'block';
	document.getElementById('sliderTitle').innerHTML = 'Rate this title';
	if ( document.getElementById( 'sliderTableDR' ) )
	{
		document.getElementById( 'sliderTableDR' ).style.visibility = "visible";
	}	
}

function setLikelyToSee( fromRatingStripSlider )
{
	
	if( document.location.href.indexOf('ratings') > -1)
	{
		AjaxUserRatingBean.setLikelyOrNotInterested( discoveryCurrentContentId, true, {
		
			callback: function(){
				
				top.listRollOverSliderObject.setValue( 0 );
				recommendationFuncs.setRolloverSliderRateText( -1 );
				top.listRollOverSliderObject.setPointerToValue();
				top.listRollOverSliderObject.setOverlayToValue();
				document.getElementById('notSeenItPopup').style.display = 'none';
				myRatingsFuncs.updateRatingStrip("Likely...");
				showLikelyToSee();				
			},
			errorHandler: generalFunctions.handleAjaxServerErrors 
		}
		
		 );
	}
	else if( document.location.href.indexOf('discovery') < 0 )
	{
		AjaxUserRatingBean.setLikelyOrNotInterested( discoveryCurrentContentId, true, {
			
			callback: generalFunctions.setSliderToLikelyOrNotSeen(true),
			errorHandler: generalFunctions.handleAjaxServerErrors  
			
				}
			
			);
		
	}
	else if( document.location.href.indexOf('discovery') > -1 )
	{
		AjaxUserRatingBean.setLikelyOrNotInterested( discoveryCurrentContentId, true, {
			
			callback: generalFunctions.initSliderByAjax,
			errorHandler: generalFunctions.handleAjaxServerErrors  
			
				}
			
			);
	}
	
}

function showNotForMe()
{
	document.getElementById('rolloverNotSeenIt').style.display = 'none';
	document.getElementById('rolloverNotForMe').style.display = 'block';
	document.getElementById('notSeenItPopup').style.display = 'none';
	document.getElementById('rolloverLikelyToSee').style.display = 'none';
	document.getElementById('sliderTitle').innerHTML = 'Rate this title';
	if ( document.getElementById( 'sliderTableDR' ) )
	{
		document.getElementById( 'sliderTableDR' ).style.visibility = "visible";
	}
}

function setNotForMe( fromRatingStripSlider )
{
	if( document.location.href.indexOf('ratings') > -1)
	{
		AjaxUserRatingBean.setLikelyOrNotInterested( discoveryCurrentContentId, false, function(){
			
			top.listRollOverSliderObject.setValue( 0 );
			recommendationFuncs.setRolloverSliderRateText( -1 );
			top.listRollOverSliderObject.setPointerToValue();
			top.listRollOverSliderObject.setOverlayToValue();
			showNotForMe();
			myRatingsFuncs.updateRatingStrip("Not for me...");
		});
	}
	
	else if( document.location.href.indexOf('discovery') < 0 )
	{
		AjaxUserRatingBean.setLikelyOrNotInterested( discoveryCurrentContentId, false, {
			
			callback: generalFunctions.setSliderToLikelyOrNotSeen( false ),
			errorHandler: generalFunctions.handleAjaxServerErrors  
			
				}
			
			);
		
	}
	else if( document.location.href.indexOf('discovery') > -1 )
	{
		AjaxUserRatingBean.setLikelyOrNotInterested( discoveryCurrentContentId, false, {
			
				callback: generalFunctions.initSliderByAjax,
				errorHandler: generalFunctions.handleAjaxServerErrors
			} 
		);
	}
}



function setNotSeenIt()
{
	document.getElementById('rolloverNotSeenIt').style.display = 'block';
	document.getElementById('rolloverNotForMe').style.display = 'none';
	document.getElementById('notSeenItPopup').style.display = 'none';
	document.getElementById('rolloverLikelyToSee').style.display = 'none';
}


/****** showing filters menu function ******/
function searchFilters(filterName) {
	switch (filterName) {
		case "movies":
			document.getElementById('filter_where').style.display = 'inline';
			document.getElementById('filter_style').style.display = 'none';
			document.getElementById('filter_type').style.display = 'inline';
			break;
		case "tv":
			document.getElementById('filter_where').style.display = 'inline';
			document.getElementById('filter_style').style.display = 'inline';
			document.getElementById('filter_type').style.display = 'inline';
			break;
		case "shorts": 
			document.getElementById('filter_where').style.display = 'none';
			document.getElementById('filter_style').style.display = 'none';
			document.getElementById('filter_type').style.display = 'inline';
			break;
		case "online":
			document.getElementById('filter_where').style.display = 'none';
			document.getElementById('filter_style').style.display = 'none';
			document.getElementById('filter_type').style.display = 'inline';
			break;
		case "all":
			document.getElementById('filter_where').style.display = 'none';
			document.getElementById('filter_style').style.display = 'none';
			document.getElementById('filter_type').style.display = 'none';
			break;
		default:
			document.getElementById('filter_where').style.display = 'none';
			document.getElementById('filter_style').style.display = 'none';
			document.getElementById('filter_type').style.display = 'none';
			break;
	}
	
}

/****** onclick text clear inside the where filter menu *****/
function clearText(box)  {
	var val = box.value; 
	if ( val == 'Zip code' ) {
		box.value = '';		
	}
}

/* show more recent searches */
function showMoreSearches() {
	
	var finished = false;	
	for ( counter = 1; !finished; counter++) {
		var ListId = 'bs' + counter;
		var ListObj = document.getElementById(ListId);
			
		if ( ListObj != null ) {
			ListObj.style.display = 'block';
		}
		else
		{
			finished = true;	
		}	
	}
}
function hideMoreSearches() {
	
	var show = false;	
	for ( counter = 1; !show; counter++) {
		var ListId = 'bs' + counter;
		var ListObj = document.getElementById(ListId);
			
		if ( ListObj != null ) {
			ListObj.style.display = 'none';
		}
		else
		{
			show = true;	
		}	
	}
}
/***** hide back div and more recente searches ******/
function hideBack(obj) {      
	obj.style.display = 'none';
	document.getElementById('historySearches').className = "menuList";
	document.getElementById('history_ml').innerHTML = "More";
}
function mostRecentSearches(){
	alert(document.getElementById('historyMore').childNodes);
}
function expandHistory(){
	if ( document.getElementById('history_ml').innerHTML == "More" ){
		document.getElementById('historySearches').className = "menuListLong";
		document.getElementById('history_ml').innerHTML = "Less";
		return;	
	}
	else
	{
		document.getElementById('historySearches').className = "menuList";
		document.getElementById('history_ml').innerHTML = "More";
		document.getElementById('history_ml').style.color = "#cd3301";
		return;
	}
}


function showMenuFade(obj) {
	obj.style.opacity = '0';
	//obj.filters.alpha.opacity = '0';
	var menuFade = setInterval("showAddMovie(obj)", 50); 
}
function goAddMovieFade() {
	var fadeIn = setInterval("showAddMovie(document.getElementById('favoritesSuggest'))", 50);
}

function showAddMovie(obj) {	
	if (navigator.appName=='Netscape') {
	obj.style.display = 'inline';
	var theOpacity = parseFloat(obj.style.opacity)
	if ( theOpacity <= 1 ) {
		theOpacity+=0.1;
		obj.style.opacity = theOpacity; 
	}
	else 
	{
		clearInterval();
	}
}
	else if (navigator.appName=='Microsoft Internet Explorer') {
	obj.style.display = 'inline';
	var theOpacity = parseInt(obj.filters.alpha.opacity);
	if ( theOpacity < 100 ) {
		theOpacity+=10;
		obj.filters.alpha.opacity = theOpacity; 
	} 
	else 
	{
		clearInterval();
	}
}
}
function hideAddMovie(obj) {	
	if (navigator.appName=='Netscape') {
	obj.style.display = 'inline';
	var theOpacity = parseFloat(obj.style.opacity)
	if ( theOpacity >= 0.1 ) {
		theOpacity-=0.1;
		obj.style.opacity = theOpacity; 
	}
	else 
	{
		clearInterval();
	}
}
	else if (navigator.appName=='Microsoft Internet Explorer') {
	obj.style.display = 'inline';
	var theOpacity = parseInt(obj.filters.alpha.opacity);
	if ( theOpacity >= 10 ) {
		theOpacity-=10;
		obj.filters.alpha.opacity = theOpacity; 
	} 
	else 
	{
		clearInterval();
	}
}
}
/*
function showReview() {
		document.getElementById('expand_review').style.display = 'block';
}
function hideReview() {
	document.getElementById('expand_review').style.display = 'none';	
}*/



//////// vote gene float menu ////////////

function showVoteMenu(yesNotVote, gene) {
	
	currVoteTag = gene.innerHTML;
	var url = gene.href;
	var link = document.getElementById('genesRelatedLink');
	link.href = url;
	
	yesNotVote.style.left = getPosX(gene) + 'px';
    yesNotVote.style.top  = getPosY(gene) + 19 + 'px';
    yesNotVote.style.display = 'block'; 
  
}

function showUserVote(yesNotVote, voteOrSearchMenu) {
	
	yesNotVote.style.left = getPosX(voteOrSearchMenu) + 'px';
    yesNotVote.style.top  = getPosY(voteOrSearchMenu) + 'px';
    yesNotVote.style.display = 'block'; 
    voteOrSearchMenu.style.display = 'none';
}

function showVotedUsers() {
	if ( document.getElementById('votedUsers').style.display == 'none' ) {
		document.getElementById('votedUsers').style.display = 'inline';
	}
	else {
		document.getElementById('votedUsers').style.display = 'none';
	}
}

function bm_newWindow() {
	window.open('http://www.addthis.com/bookmark.php','bookmarks', 'left=20, top=20, height=715, width=599, status=0, scrollbars=0, toolbar=0, menubar=0, resizable=no')	
}

/* home input box - remove default text on  click */

function clearDefText(obj) {
	if (obj.value == 'Enter a favorite title') {
		obj.value = '';
	}
}

/*  */
function showSort(){
	document.getElementById('sortLine').innerHTML = collageSort;
	discoveryShow = false;
}	

function topHightlight() {
	if (document.getElementById('genome')){
		try{
		document.getElementById('topfirstLnk').style.fontWeight = "bold";
		document.getElementById('topfirstLnk').style.color = "#cd3301";
		document.getElementById('toprecLnk').style.fontWeight = "normal";
		document.getElementById('toprecLnk').style.color = "#676767";
		}catch(e){}
	}
	if (document.getElementById('your_tasks')) {
		try{
//		document.getElementById('toprecLnk').style.fontWeight = "bold";
//		document.getElementById('toprecLnk').style.color = "#cd3301";
//		document.getElementById('topfirstLnk').style.fontWeight = "normal";
//		document.getElementById('topfirstLnk').style.color = "#676767";
		}catch(e){}
	}	
}

function statusSpace() {
	if (document.getElementById('whatis'))
	{
		document.getElementById('resultsSummaryBar').style.display = 'none';
//		document.getElementById('shpitz').style.height = 0;		
	}
	
}

/**** feedback page functions ****/

function checkFeedback(mail,myname,feedback) { 
	
	
	
	var et = mail.indexOf('@');
	var dot = mail.lastIndexOf('.');
	var a = 0;
	var b = 0;
	var goodStuff = true;
	
	if (et > 0 && dot > 0 && dot > et && dot < (mail.length-2)) {
		a+=1;
	}	
	if ( myname != '' && feedback != '' ){
			b+=1;	
	}
	
//	if ( a == 1 && b == 1 ){
//			document.getElementById('feedbackNotice').style.display = 'block';
//			document.getElementById('feedbackAlert').style.display = 'block';
//	}
	else if ( a == 1 && b == 0 ){
				alert( 'Details are missing' )
				goodStuff = false;
	}  if ( a == 0 && b == 1 ){
				alert( 'E-mail is invalid' )
				goodStuff = false;
	}  if ( a == 0 && b == 0 ){
				alert( 'E-mail is invalid\nDetails are missing' )
				goodStuff = false;
			}

	if(goodStuff)
	{
		return true;
		
	}
	else
		return false;
	
}

function hideFeedbackNotice(){
	//document.getElementById('feedbackNotice').style.display = 'none';
	//document.getElementById('feedbackAlert').style.display = 'none';	
	document.getElementById('submitFeedback').onclick = window.location = "/"
}

/**** new layout buttons ****/

function mouseOver(obj){
	if ( obj.onmouseover ){
		obj.style.cursor = "pointer";
	}
}
function mouseOut(obj){
	if ( obj.onmouseout ) {
		obj.style.cursor = "default";
	}
}
function mouseClickWhat(obj){
	obj.style.color = "#ffffff";
	
	document.getElementById('whatShpitz').style.display = 'block';
	document.getElementById('whyShpitz').style.display = 'none';
	document.getElementById('whyButton').style.color = "#676767";
	
	document.getElementById('middleText').innerHTML = "Jinni is a whole new way to discover movies and TV shows. In the mood for fast or feel-good? Mind games or manhunts? <br /> Search for just that - while we learn your unique taste to recommend more titles. Read about the <a href='/movie-genome.html'>Movie Genome</a> behind our novel technology.";
}
function mouseClickWhy(obj){
	obj.style.color = "#ffffff";
	
	document.getElementById('whyShpitz').style.display = 'block';
	document.getElementById('whatShpitz').style.display = 'none';
	document.getElementById('whatButton').style.color = "#676767";
	
	document.getElementById('middleText').innerHTML = "Each of us has unique taste in movies and shows. Jinni is designed to help you choose what fits you. Use our intelligent tools to search for what you really want, in the multiplex and beyond. And get linked to wherever you like to watch.";
}

function mouseClickHow(obj){
	obj.style.color = "#ffffff";
	obj.style.backgroundColor = "#bbd043";
	document.getElementById('howShpitz').style.display = 'block';
	document.getElementById('whatShpitz').style.display = 'none';
	document.getElementById('whyShpitz').style.display = 'none';
	
	document.getElementById('whatButton').style.color = "#676767";
	document.getElementById('whyButton').style.color = "#676767";
	
	document.getElementById('middleText').innerHTML = "<strong>In the mood for love?</strong> We'll suggest more than Romantic Commedies. <strong>Just got a parking ticket?</strong> Look for Clever Law Enforcement Scams. <strong>Stuck for ideas?</strong> <a href='#'>Go to My Recommendations</a>";
}

function demoVideoShow()
{
	if ( document.title.indexOf('Registration') != -1 )
	{
		document.getElementById('theIframe').innerHTML = "<iframe id='demoTransFrame' src='demoMovie.html' width='100%' height='585px' frameborder='0'></iframe>";
		document.getElementById('demoTransFrame').style.display = "block";
		document.getElementById('demoVideoContainer').style.display = "block";
		document.getElementById('demoVideoContainer').innerHTML = "<img src='http://media.jinni.com/images/close_trans.gif' style='float:right;margin:3px;cursor:pointer;' onclick='window.parent.hideDemo()' alt='jinni' />" + 
			"<div id=\"flashPlayer\"></div>" +
			"<a href='javascript: window.parent.hideDemo();' class='demoBottomButton'>Get Started Now!</a>";
	}
	else
	{
	document.getElementById('demoTransDiv').style.display = "block";
	document.getElementById('demoVideoContainer').style.display = "block";
	document.getElementById('demoVideoContainer').innerHTML = "<img src='http://media.jinni.com/images/close_trans.gif' style='float:right;margin:3px;cursor:pointer;' onclick='demoVideoHide()' alt='jinni' />" +  
			'<div id=\"flashPlayer\"></div>' +
			'<span onclick="demoVideoHide()" class="demoBottomButton">Get Started Now!</span><br /><br />' +
			'<div class="embed_wrap">' +
				'<img class="movie_embed_icon" src="http://media.jinni.com/images/embed.png" alt="embed" onclick="displayEmbedCode()" />' +
				'<img class="movie_twitter_icon" src="http://media.jinni.com/images/icons/twitter_small_icon.png" alt="share this movie on twitter" onclick="shareModule.twitter(\'movie\');" />' +
				'<img class="facebook_movie_demo" onclick="shareModule.facebook(\'movie\'); return false;" src="http://media.jinni.com/images/icons/facebook_share_button.png" alt="facebook share button" />' +
				'<div id="embed" style="display:none">' +
				   '<img src="http://media.jinni.com/images/close_trans.gif" style="float:right;margin:3px;cursor:pointer;" onclick="closeEmbedCode()" alt="jinni" />' +
				   '<span class="movie_embed_text">Embed from YouTube:</span>' +
				   '<textarea class="movie_embed_textarea" onFocus="this.select()">&lt;object width="640" height="385"&gt;&lt;param name="movie" value="http://www.youtube.com/v/q1Wbw9sZIus&rel=0&color1=0xb1b1b1&color2=0xd0d0d0&hl=en_US&feature=player_embedded&fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowScriptAccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/q1Wbw9sZIus&rel=0&color1=0xb1b1b1&color2=0xd0d0d0&hl=en_US&feature=player_embedded&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;</textarea>' +
				   '<div class="clear"></div>' +
				'</div>' +
			'</div>';
	}
	
	var so = new SWFObject('/player/player.swf','mpl','323','260','9');
	so.addParam('allowscriptaccess','always');
	so.addParam('allowfullscreen','true');
	so.addParam('flashvars','&author=Jinni&file=http://media.jinni.com/demos/video.flv&bufferlength=10&autostart=true&skin=/player/jinniskin.swf&controlbar=over');
	so.write('flashPlayer');	
}
function displayEmbedCode(){
	document.getElementById('embed').style.display = "block";
}
function closeEmbedCode(){
	document.getElementById('embed').style.display = "none";
}
function playContentMovie(url,playerVendor,containerID,w,h)
{
	var playerCode = null;
	
	switch( playerVendor )
	{
		case 'internal':
			var so = new SWFObject('/player/player.swf','mpl',w,h,'9');
			so.addParam('allowscriptaccess','always');
			so.addParam('allowfullscreen','true');
			so.addParam('flashvars','&author=Jinni&file=' + url + '&bufferlength=10&autostart=true&skin=/player/jinniskin.swf&controlbar=over');
			so.write(containerID);
		break;
		
		case 'Jaman':
			
			playerCode = 	'<object height="'+ h +'" width="'+ w +'">';
			playerCode +=	'<param value="' + url + '" name="movie"/>'; 
			playerCode +=	'<param value="transparent" name="wmode"/>';
			playerCode +=	'<param value="true" name="allowFullScreen"/>';
			playerCode +=	'<embed height="327" width="500" allowfullscreen="true" wmode="transparent" type="application/x-shockwave-flash" src="' + url + '"/>';
			playerCode +=	'</object>';
			
			document.getElementById(containerID).innerHTML = playerCode;
			
		break;
		
		case 'Hulu':
			document.write( '<object height="'+ h +'" width="'+ w +'" data="' + url + '" type="application/x-shockwave-flash">');
			document.write( '<param value="' + url + '" name="movie"/>');
			document.write( '<param value="transparent" name="wmode"/>');
			document.write( '<span class="normal">Your browser is not able to display embedded Flash video.</span>');
			document.write( '</object>');
						
		break;
	}	
}
function demoVideoHide(){
	document.getElementById('demoTransDiv').style.display = "none";
	document.getElementById('demoVideoContainer').style.display = "none"; 	

	document.getElementById('demoVideoContainer').innerHTML = "";
}

function hideDemo(){
	 var iframe = document.getElementById('demoTransFrame');
 	     iframe.parentNode.removeChild(iframe);
 	     
 	     document.getElementById('demoVideoContainer').style.display = "none";
 	     document.getElementById('demoVideoContainer').innerHTML = "";
}

/**** invite friend ****/

// show invitaion //

function showFloat( objLink, obj ) 
{
	superman = 0;
	var menuLink = obj;
	objLink.style.left = getPosX(menuLink) + 'px';
	objLink.style.top  = getPosY(menuLink) + 16 + 'px';
	if (objLink.style.display != 'block')
	{
		addInvitaion();
	}
	objLink.style.display = 'block'; 
}

function addInvitaion()
{
	var theInput = document.getElementById("invitaionInput");
	if ( document.getElementById('invitaionPreview').style.display != "block" )
	{
		theInput.value = "Enter emails separated by commas";
		theInput.style.color = "#787b6a";
	}
	else
	{
		theInput.value = document.getElementById('theInvitees').value;
		document.getElementById('invitaionPreview').style.display = "none";
		if ( theInput.value == "Enter emails separated by commas" )
		{
			theInput.style.color = "#787b6a";
		}
		else
		{
			theInput.style.color = "#000000";
		}
	}
}

function sendInvitations( srcEmails, srcMsg )
{
	var btn = document.getElementById('invitationPreviewSendBtn');
	btn.onclick = null;
	btn.style.backgroundColor = 'gray';
	btn.style.cursor = 'default';
	btn.innerHTML = 'Sending';
	document.getElementById('invitationLoading').style.display = 'block';
	
	UserInvitationBean.sendInvitations( srcEmails, srcMsg, sendInvitationsCallback, null );
}

function sendInvitationsCallback( response )
{
	UserInvitationBean.getNumInvitations( function(response){ document.getElementById( "numInvites" ).innerHTML = response; } );
	var sentSuccess = [];
	var noMore = [];
	var genErr = [];
	var invalidAddress = [];
	
	for ( var i = 0; i < response.length; i++ )
	{
		if( response[i].match(/^Sent:/) )
		{
			sentSuccess.push( response[i].substring( 5, response[i].length ) );
		}
		else if ( response[i].match(/^Invalid:/) )
		{
			invalidAddress.push( response[i].substring( 8, response[i].length ) );
		}
		else if ( response[i].match(/^No more:/) )
		{
			noMore.push( response[i].substring( 8, response[i].length ) );
		}
		else if ( response[i].match(/^General Err:/) )
		{
			genErr.push( response[i].substring( 12, response[i].length ) );
		}
	}
	var resultsContainer = document.getElementById( "invitaionPreview" );
	resultsContainer.innerHTML = '<div class="details"></div>' +
			'<button id="invResultsBtn" onclick="this.parentNode.style.display=\'none\';">Close</button>';
	var details = resultsContainer.getElementsByTagName( "div" )[0];
	details.style.width = "300px";
	var str = "";
	if ( sentSuccess.length > 0 )
	{
		str += "Your invites were sent!<br/><br/>";
	}
	if ( noMore.length > 0 )
	{
		str += "These invites could not be sent because you have no more invitations left:<br/>";
		for ( var i = 0; i < noMore.length; i++ )
		{
			str += noMore[i] + "<br/>";
		}
		str += "<br/>";
	}
	if ( invalidAddress.length > 0 )
	{
		str += "These invites could not be sent because their address is invalid:<br/>";
		for ( var i = 0; i < invalidAddress.length; i++ )
		{
			str += invalidAddress[i] + "<br/>";
		}
		str += "<br/>";
	}
	if ( genErr.length > 0 )
	{
		str += "These invites could not be sent because of an unknown error:<br/>";
		for ( var i = 0; i < genErr.length; i++ )
		{
			str += genErr[i] + "<br/>";
		}
		str += "<br/>";
	}
	details.innerHTML = str;
	resultsContainer.style.display = "block";
}

function onInvitationFocus( event, target )
{
	if ( target.value == "Enter emails separated by commas" )
	{
		target.value = "";
		target.style.color = "#000000";
	}
}

function onInvitationBlur( event, target )
{
	if ( target.value == "" )
	{
		target.value = "Enter emails separated by commas";
		target.style.color = "#787b6a";
	}
}

// remove input //

function invRemove(){	
	document.getElementById('invitaionInput').value = '';
}
// close invitation container //
function closeic(){
	noteShow = false;
	document.getElementById('theInvitaion').style.display = 'none';
	document.getElementById('invitaionPreview').style.display = 'none';
}
function showInvitationPreview() 
{
	var invPrev = document.getElementById('invitaionPreview');
	invPrev.innerHTML = '<div id="invCloseImgPreview">' +
						'<img src="' + imagePath + 'close_trans.png" id="closeInvitationDiv" onclick="closePreview()" alt="jinni"  />' +
						'</div>' +
						'<h2 class="discover">Share Jinni with your friends!</h2>' +
						'<div id="invitees">To</div>' +
						'<input type="text" id="theInvitees" value="Enter emails separated by commas" style="color:#787b6a;" onfocus="onInvitationFocus(event, this);" onblur="onInvitationBlur(event, this);"/>' +
						'<div id="addInvitationNote">If you want, add a personal message</div>' +
						'<textarea id="invitaionComment" rows="3" cols="1">' + document.getElementById('theInvitaion').innerHTML + '</textarea>' +
						'<div>' +
						'<button id="invitationPreviewSendBtn" onclick="sendInvitations( document.getElementById(\'theInvitees\').value, document.getElementById(\'invitaionComment\').value );">Invite</button>' +
						'<div id="invitationLoading" class="invitationLoading"></div>' +
						'</div>';
									
	
	document.getElementById('invitaionPreview').style.display = "block";
	document.getElementById( "theInvitaion" ).style.display = "none";
}
function closePreview(){
		document.getElementById('invitaionPreview').style.display='none';
}
function checkInvitationMail(mail){
	var invitaionSentNotification = '<div id="invCloseImg"><img src="http://media.jinni.com/images/close_trans.png" id="closeInvitationDiv" onclick="closeic();" alt="jinni"  /></div>'+
    								 "<div id='successInvitation' class='successInvite'>Invitation successfully sent</div>"+
									 "<div class='addFromSuccess' onclick='addInvitaion()'>Add another</div>";
	var et = mail.indexOf('@');
	var dot = mail.lastIndexOf('.');
	if (et > 0 && dot > 0 && dot > et && dot < (mail.length-2)) { 
		noteShow = true;
		document.getElementById('invitationContent').innerHTML = invitaionSentNotification; 
		if ( noteShow == true ){
			superman = 1;
			invTimer = setTimeout("document.getElementById('theInvitaion').style.display='none'", 4000);	
		}	
	}
	
	else if ( mail == '' ){
		alert('Please enter Email address');
	}
	else
	{
		alert('Email is invalid');
		document.getElementById('invitaionInput').value = '';
	}
}



function goHome()
{
	setSessionCookie('homeLink','allCategoriesMenuItem');
	setSessionCookie('gfilter',"all");
	window.location = "/";
}


// the ie 6 notice //

function linkSyntaxChange(){
	if ( BrowserDetect.browser == "Explorer" && BrowserDetect.version < 7 ) {
		document.getElementById('starter_links').innerHTML = "<a style='cursor: pointer'>Create your profile</a>"+
		  												   " or "+ 		
														   "<a style='cursor: pointer'>Start searching now.</a>";
	}	
}
function badBrowserNotice(){
	if ( BrowserDetect.browser == "Explorer" && BrowserDetect.version < 7 )
	{
		document.getElementById('demoTransDiv').style.display = 'block';
		document.getElementById('ie6_notice_container').style.display = 'block';	
		return false;
	}
}


function isChildOf(theChild, theParent)
{
	while( theChild.parentNode )
	{
		if( theChild == theParent || theChild.parentNode == theParent )
		{
			return true;
		}
		else
		{
			return isChildOf( theChild.parentNode, theParent);
		}
	}
	return false;
}

function prizeTerms()
{
	document.getElementById('prize_terms_text').innerHTML = "<div id='prize_terms'>" +
			"<div id='mycustomscroll2' class='flex_custom flexcroll'>" +
				"<p><b>PRIZE TERMS AND CONDITIONS</b></p>" +
				  "<div class='lipsum'>"+
					"<ol class='prize_terms_list'>"+
						"<li><b>Prize Period:</b> The prize drawing is held weekly and continues " +
							" until such time as the end of the prize drawing is announced on the " +
							" Prize Page . Jinni may end the prize drawing at any time.</li>" +
						"<li><b>How to Enter:</b> <br /> <u>Rules:</u> You may enter to win the prize by " +
							" inviting 5 or more friends to Jinni who sign up for the Jinni service " +
							" (by completing the registration process and receiving a username and " +
							" password). Friends can be invited by clicking on the 'Invite friends' " +
							" link in the upper right corner of any page on Jinni.com or from the " +
							"<br /><u>Prize</u> Page. If 5 of your friends sign up, you will be notified by " +
							" email and automatically entered for the next prize drawing and for " +
							" all subsequent ones. Of course, the earlier you qualify, the less " +
							" competition you will have for the prize! You may contact us at " +
							"<a href='mailTo:info@Jinni.com'>info@Jinni.com</a> if you do not wish to be entered for the prize " +
							" drawing. The rules of the prize drawing may change at any time, and " +
							" will be announced on the Prize Page.<br /><u>Eligibility:</u> You must comply " +
							" with the Jinni Terms of Use in order to be eligible for the prize " +
							" drawing. Your friends must also comply at time of registration. Jinni " +
							" will determine compliance at our own discretion. Prize: The prize is " +
							" announced on the Prize Page. The weekly prize may be changed at any " +
							" time, and the new prize will be announced on the Prize Page in " +
							" advance of the weekly prize drawing. The winner of the week will be " +
							" notified by Friday, 9am ET of the same week by email and will be " + 
							" asked to supply a mailing address for the prize. The prize cannot be " +
							" delivered if a mailing address is not supplied. The winner may also " +
							" be asked for a quotation to use on the Jinni site; however this is " +
							" not a requirement to receive the prize. The weekly winner will alsov " +
							" be posted on the Prize Page." +
						"</li>" +
						"<li><b>Release:</b> Participating in the prize drawing constitutes " +
							" permission for Jinni to use participants' names, biographical " +
							" information, quotations, avatars/pictures, and likenesses for " +
							" purposes of advertising and trade without further compensation, " +
							" unless prohibited by law. BY ACCEPTING A PRIZE, THE WINNERS AGREE " +
							" THAT JINNI WILL HAVE NO LIABILITY WHATSOEVER FOR, AND WILL BE HELD " +
							" HARMLESS BY WINNER FOR ANY LIABILITY FOR ANY INJURY, LOSS OR DAMAGES " +
							" OF ANY KIND TO PERSONS, INCLUDING DEATH, AND PROPERTY, DUE IN WHOLE " +
							" OR IN PART, DIRECTLY OR INDIRECTLY, FROM THE ACCEPTANCE, POSSESSION, " +
							" USE OR MISUSE OF ANY PRIZE OR PARTICIPATION IN THIS PRIZE-DRAWING OR " +
							" PARTICIPATION IN ANY PRIZE-RELATED ACTIVITY. You hereby represent and " +
							" warrant that you have read these rules and are fully familiar with " + 
							" its contents." +
						"</li>" +
					"</ol>" +

					"</div>" +
				 	"<p style='color: white;''>Bottom</p>" +
		
					"</div>" +		
					"</div>" +
					"<br />"+
					"<a href='#' onclick='removePrizeTerms();return false;'>Close</a>"
					
					document.getElementById('showPrizeTerms').style.display = "none";
					document.getElementById('hidePrizeTerms').style.display = "block";	
}
function removePrizeTerms(){
	document.getElementById('prize_terms_text').innerHTML = "";
	document.getElementById('hidePrizeTerms').style.display = "none";
	document.getElementById('showPrizeTerms').style.display = "block";	
}

function prizeTerms()
{
	document.getElementById('prize_terms_text').innerHTML = "<div id='prize_terms'>" +
			"<div id='mycustomscroll2' class='flex_custom flexcroll'>" +
				"<p><b>PRIZE TERMS AND CONDITIONS</b></p>" +
				  "<div class='lipsum'>"+
					"<ol class='prize_terms_list'>"+
						"<li><b>Prize Period:</b> The prize drawing is held weekly and continues " +
							" until such time as the end of the prize drawing is announced on the " +
							" Prize Page . Jinni may end the prize drawing at any time.</li>" +
						"<li><b>How to Enter:</b> <br /> <u>Rules:</u> You may enter to win the prize by " +
							" inviting 5 or more friends to Jinni who sign up for the Jinni service " +
							" (by completing the registration process and receiving a username and " +
							" password). Friends can be invited by clicking on the 'Invite friends' " +
							" link in the upper right corner of any page on Jinni.com or from the " +
							"Prize Page. If 5 of your friends sign up, you will be notified by " +
							" email and automatically entered for the next prize drawing and for " +
							" all subsequent ones. Of course, the earlier you qualify, the less " +
							" competition you will have for the prize! You may contact us at " +
							"<a href='mailTo:info@Jinni.com'>info@Jinni.com</a> if you do not wish to be entered for the prize " +
							" drawing. The rules of the prize drawing may change at any time, and " +
							" will be announced on the Prize Page.<br /><u>Eligibility:</u> You must comply " +
							" with the Jinni <a href='/terms.html'>Terms of Use</a> in order to be eligible for the prize " +
							" drawing. Your friends must also comply at time of registration. Jinni " +
							" will determine compliance at our own discretion. Prize: The prize is " +
							" announced on the Prize Page. The weekly prize may be changed at any " +
							" time, and the new prize will be announced on the Prize Page in " +
							" advance of the weekly prize drawing. The winner of the week will be " +
							" notified by Friday, 9am ET of the same week by email and will be " + 
							" asked to supply a mailing address for the prize. The prize cannot be " +
							" delivered if a mailing address is not supplied. The winner may also " +
							" be asked for a quotation to use on the Jinni site; however this is " +
							" not a requirement to receive the prize. The weekly winner will alsov " +
							" be posted on the Prize Page." +
						"</li>" +
						"<li><b>Release:</b> Participating in the prize drawing constitutes " +
							" permission for Jinni to use participants' names, biographical " +
							" information, quotations, avatars/pictures, and likenesses for " +
							" purposes of advertising and trade without further compensation, " +
							" unless prohibited by law. BY ACCEPTING A PRIZE, THE WINNERS AGREE " +
							" THAT JINNI WILL HAVE NO LIABILITY WHATSOEVER FOR, AND WILL BE HELD " +
							" HARMLESS BY WINNER FOR ANY LIABILITY FOR ANY INJURY, LOSS OR DAMAGES " +
							" OF ANY KIND TO PERSONS, INCLUDING DEATH, AND PROPERTY, DUE IN WHOLE " +
							" OR IN PART, DIRECTLY OR INDIRECTLY, FROM THE ACCEPTANCE, POSSESSION, " +
							" USE OR MISUSE OF ANY PRIZE OR PARTICIPATION IN THIS PRIZE-DRAWING OR " +
							" PARTICIPATION IN ANY PRIZE-RELATED ACTIVITY. You hereby represent and " +
							" warrant that you have read these rules and are fully familiar with " + 
							" its contents." +
						"</li>" +
					"</ol>" +

					"</div>" +
				 	"<p style='color: white;''>Bottom</p>" +
		
					"</div>" +		
					"</div>" +
					"<br />"+
					"<a href='#' onclick='removePrizeTerms();return false;'>Close</a>"
					
					document.getElementById('showPrizeTerms').style.display = "none";
					document.getElementById('hidePrizeTerms').style.display = "block";	
}
function removePrizeTerms(){
	document.getElementById('prize_terms_text').innerHTML = "";
	document.getElementById('hidePrizeTerms').style.display = "none";
	document.getElementById('showPrizeTerms').style.display = "block";	
}	
function prefrencesClick( checkbox, checkBoxLabel )
{
	var otherCheckboxID = null;
	var otherCheckBox = null;
	if(checkbox.id.substr( checkbox.id.lastIndexOf(':')+1, checkbox.id.length) == '0')
		otherCheckboxID = checkbox.id.substr( 0, checkbox.id.lastIndexOf(':')+1) + '1';
	else 
		otherCheckboxID = checkbox.id.substr( 0, checkbox.id.lastIndexOf(':')+1) + '0';
	
	otherCheckBox = document.getElementById( otherCheckboxID );
	
	if( checkbox.checked )
	{
		otherCheckBox.checked = false;
		
		if(checkbox.value == 'dislike')
			document.getElementById(checkBoxLabel).className = 'theGenre dislikeColor';
		else if(checkbox.value == 'like')
			document.getElementById(checkBoxLabel).className = 'theGenre likeColor';
	}
	else
	{
		if( otherCheckBox.checked == false )
			document.getElementById(checkBoxLabel).className = 'theGenre';
	}
		
}
nflxFucntions.addToInstantRollover = function( anchorOBJ, clientID )
{
	var instantButtonID = "";
	
	try{
		
		instantButtonID = anchorOBJ.id.split("_")[0];
	
	}catch(e){}
	
	
	document.getElementById( instantButtonID + '_nflxInstanceButton').style.visibility = "visible";
}

nflxFucntions.nflxPlayButtonRollout = function(e, playButton )
{
	var instantButtonID = "";
	
	try{
		
		instantButtonID = playButton.id.split("_")[0];
	
	}catch(ex){}
	
	
	var goingToObj = null;
	
	if( e.relatedTarget) goingToObj = e.relatedTarget;
	else goingToObj = e.toElement;
	
	if( !isChildOf( goingToObj, document.getElementById( instantButtonID + '_nflxInstanceButton') )) 
		document.getElementById(instantButtonID + '_nflxInstanceButton').style.visibility = "hidden";
	
	
}
nflxFucntions.openPlayer = function( clientID )
{
	var x= "200";
	var y= "200";
	var referenceObj = "referencePopupObject";
	var movieURL = "http://api.netflix.com/catalog/movie/" + nflxFucntions.nflxID;
	
	nflx.openPlayer(movieURL,x, y, clientID, undefined, referenceObj); 
	
	return false;
	
}
nflxFucntions.addToDVDQueue = function( clientID, buttonClicked )
{
	var coordinate = nflxFucntions.getNflxIFramePos( buttonClicked );
//	var buttonClicked = document.getElementById( utils.whichElement( event ) );
	
	if( isChildOf( buttonClicked , document.getElementById('collage_ro')))
		hide(document.getElementById('collage_ro'));
	if(  isChildOf( buttonClicked , document.getElementById('listRollover')) )
	{
		document.getElementById('listRollover').style.display = 'none';
	}
	
	var x= coordinate.x;
	var y= coordinate.y;
	var referenceObj = "referencePopupObject";
	var movieURL = "http://api.netflix.com/catalog/movie/" + nflxFucntions.nflxID;
	
	nflx.addToQueue(movieURL,x, y, clientID, nflx.DVD_Q, referenceObj); 
	
	return false;
}
nflxFucntions.addToInstantQueue = function( clientID, buttonClicked )
{
	var coordinate = nflxFucntions.getNflxIFramePos( buttonClicked );
	
	if( isChildOf( buttonClicked , document.getElementById('collage_ro')))
		hide(document.getElementById('collage_ro'));
	if(  isChildOf( buttonClicked , document.getElementById('listRollover')) )
	{
		document.getElementById('listRollover').style.display = 'none';
	}
	
	var x= coordinate.x;
	var y= coordinate.y;
	var referenceObj = "referencePopupObject";
	var movieURL = "http://api.netflix.com/catalog/movie/" + nflxFucntions.nflxID;
	
	nflx.addToQueue(movieURL,x, y, clientID, nflx.INSTANT_Q, referenceObj); 
	
	return false;
	
}
nflxFucntions.getNflxIFramePos = function( buttonClicked )
{
	var coordinate = {x : "", y : ""};
	var referenceObjectCoordinate = {x : "", y : ""};
	
	var buttonClicked = buttonClicked;
	
	if( isChildOf( buttonClicked , document.getElementById('collage_ro')) )
	{
		referenceObjectCoordinate.x = document.getElementById('collage_ro').style.left;
		referenceObjectCoordinate.y = document.getElementById('collage_ro').style.top;
		
		coordinate.x = ( referenceObjectCoordinate.x + 9 ) + "px"; 
		coordinate.y = ( referenceObjectCoordinate.y + 55 ) + "px";
	}
	else if(  isChildOf( buttonClicked , document.getElementById('listRollover')) )
	{
		referenceObjectCoordinate.x = getPosX( buttonClicked );
		referenceObjectCoordinate.y = getPosY( buttonClicked );
		 
		coordinate.x = ( referenceObjectCoordinate.x - 450 ) + "px"; 
		coordinate.y = ( referenceObjectCoordinate.y - 133 ) + "px";
		
	}
	else /* not discovery rollover */
	{
		referenceObjectCoordinate.x = getPosX( buttonClicked );
		referenceObjectCoordinate.y = getPosY( buttonClicked );
		 
		coordinate.x = ( referenceObjectCoordinate.x - 30 ) + "px"; 
		coordinate.y = ( referenceObjectCoordinate.y ) + "px";
	}
	
	
	return coordinate;
}
nflxFucntions.hideNflxButtons = function()
{
	document.getElementById('_nflxPlayButton').style.visibility = "hidden";
	document.getElementById('_nflxAddButton').style.visibility = "hidden";
	document.getElementById('_nflxInstanceButton').style.visibility = "hidden";
}
//nflxFucntions.removeFromHomePage = function()
//{
//	document.getElementById('headerInvitaionLinkContainer')
//	
//	
//	
//}

		 
function onYouTubePlayerReady(playerID)
{
	
	if(playerID == 'integrationMovie')
	{
		
		
		var nflxIntegrationMovie = document.getElementById("nflxIntegrationPlayer");
		if ( nflxIntegrationMovie ) {
		
			nflxIntegrationMovie.addEventListener("onStateChange", "onIntegrationMovieStateChange");
			
			playNextMovie();
		}
	}
	
}

function playNextMovie()
{
	document.getElementById('movieContainer').style.visibility = "visible";
	
	var nflxIntegrationMovie = document.getElementById("nflxIntegrationPlayer");
	
	nflxFucntions.nflxMovieCounter = ++nflxFucntions.nflxMovieCounter % nflxFucntions.nflxMovieList.length;
	
	nflxIntegrationMovie.loadVideoById(nflxFucntions.nflxMovieList[nflxFucntions.nflxMovieCounter].movieID);
	
	document.getElementById('titleCotainer').style.visibility = "visible";
	document.getElementById('movieTitle').innerHTML = nflxFucntions.nflxMovieList[nflxFucntions.nflxMovieCounter].movieTitle;	
}	

function onIntegrationMovieStateChange( playerState )
{
	
	if( playerState == 0) 
	{	
		if( nflxFucntions.integrationStatus != 2 )
		{
				playNextMovie();
		}
		else
		{
			recommendationFuncs.switchToIntegrationResults();
		}
	}
		

}
generalFunctions.hideNetflixFromHomePage = function()
{
	utils.fadeOut('usersInvitation');
	
	setPersistanteCookie('nflxinvite','0',1000*3600*24*30,'');	
}	
	
generalFunctions.switchToPasswordBox = function( toPassword )
{
	if( toPassword )
	{
		
		document.getElementById('landingPasswordDummy').style.display = 'none';
		
		document.getElementById('landingPassword').style.display = 'block';
		document.getElementById('landingPassword').focus();
	}
	else if( trim(document.getElementById('landingPassword').value)  == '')
	{
		
		document.getElementById('landingPasswordDummy').style.display = 'block';
		document.getElementById('landingPassword').style.display = 'none';
	}
}
generalFunctions.signInUsername = function ( isFocused )
{
	if( isFocused && trim(document.getElementById('user').value) == 'Username or Email')
	{
		document.getElementById('user').className = 'landingTxtBox signInUserText';
		
		document.getElementById('user').value = '';
		
	}	
	else if(!isFocused && trim(document.getElementById('user').value) == '' )
	{
		document.getElementById('user').className = 'landingTxtBox signInPreText';
		document.getElementById('user').value = 'Username or Email';
	}
	
}
generalFunctions.handleAjaxServerErrors = function( errorString, exception )
{
	var serverMessage = "";
	if( exception.javaClassName.indexOf('SearchException') > -1 )
	{
		serverMessage = exception.errCode;
	}
	else if( exception.javaClassName.indexOf('FacesException') > -1 )
	{
		serverMessage = exception.cause.cause.message
	}
	else if( exception.javaClassName.indexOf('FaceletException') > -1 )
	{
		serverMessage = exception.message;
	}
	
	
	serverMessage = parseInt( serverMessage );
	
	switch ( serverMessage )
	{
		case 30: 
			utils.dimThePage();
			document.getElementById('alertTitle').innerHTML = "Whoops! Your session timed out."
			if( document.URL.indexOf("discovery") > -1 )
			{
				document.getElementById('actionLable').innerHTML = "Sign In"
				document.getElementById('alertActionButton').href = "javascript:document.location.href='/signin.html';"
			}
			else
			{
				document.getElementById('actionLable').innerHTML = "Sign In"
				document.getElementById('alertActionButton').href = "javascript:generalFunctions.showLoginBox();"
			}
			document.getElementById('jinniAlert').style.display = "block";		
			break;
			
		case 10:
			utils.dimThePage();
			alert('rate exc');
			break;
		
		case 20: 
			utils.dimThePage();
			alert('search exc');
			break;
			
		
		
		default:
	}
	
}

generalFunctions.setContentRatingSlider = function(contentID)
{
	var rate = globalVariables.sliderRateObject.rate;
	globalVariables.contentDetailsSlider = new sliderfuncs.SimpleSlider( "globalVariables.contentDetailsSlider" );
	globalVariables.contentDetailsSlider.setContainer( document.getElementById('ratingSlider') );
	globalVariables.contentDetailsSlider.setMaxVal( 10 );
	globalVariables.contentDetailsSlider.setStepSize ( 1.0 );
	globalVariables.contentDetailsSlider.setValue( rate );

	document.getElementById('sliderRateText').innerHTML = globalVariables.contentDetailsSlider.valToName( rate );
	
	globalVariables.contentDetailsSlider.addEventListener( function( event ){
		
		if( event.type == 'DragEnd' )
		{
			if( document.location.href.indexOf('discovery') > -1)
				saveRateForContent( event.slider.getValue(), 'ratingSlider'  );
			else {
				if (contentID) {
					saveUserRating( event.slider.getValue(), 'ratingSlider', contentID);
				} else {
					saveUserRating( event.slider.getValue(), 'ratingSlider');
				}
			}
			
			generalFunctions.saveSliderInitialStatus(event.value, true, false, false);	
				
			generalFunctions.setSliderInitialStatus("rated");
			generalFunctions.colorUserRatedSlider();
				
			setNotSeenIt();
		}
		if( event.type == 'Drag' )
		{
			generalFunctions.colorUserRatedSlider();
			document.getElementById('sliderTitle').innerHTML = 'Your Rating:'
			document.getElementById('sliderRateText').innerHTML = globalVariables.contentDetailsSlider.valToName( event.slider.getValue() );
			document.getElementById('sliderRateText').style.visibility = 'visible';
			document.getElementById('sliderRateText').style.display = 'inline';
			
		}
		if( event.type == 'LayoutDrag' )
		{
			document.getElementById('sliderTitle').innerHTML = 'Your Rating:'
			document.getElementById('sliderRateText').innerHTML = globalVariables.contentDetailsSlider.valToName( event.slider.getValue() );
			document.getElementById('sliderRateText').style.visibility = 'visible';
			document.getElementById('sliderRateText').style.display = 'inline';
			
		}
		if( event.type == 'layoutDragAbort' )
		{
			//document.getElementById('sliderRateText').innerHTML = globalVariables.contentDetailsSlider.valToName( event.slider.getValue() );
			document.getElementById('sliderRateText').innerHTML = globalVariables.contentDetailsSlider.valToName(globalVariables.sliderRateObject.rate);
			
			
			if( globalVariables.sliderRateObject.rated )
			{
				document.getElementById('sliderTitle').innerHTML = "Your Rating:";
			}
			else if( globalVariables.sliderRateObject.likelyOrNotInterested != null)
			{
				document.getElementById('sliderTitle').innerHTML = "Rate this title";
				document.getElementById('sliderRateText').innerHTML = "";
			}
			else if( globalVariables.sliderRateObject.suggested )
			{
				document.getElementById('sliderTitle').innerHTML = "Your Match:";
			}
			
			else
			{
				document.getElementById('sliderTitle').innerHTML = "Rate this title";
				document.getElementById('sliderRateText').innerHTML = "";
			}
			
		}
		
	});
	
	
	globalVariables.contentDetailsSlider.init();
}
generalFunctions.saveSliderInitialStatus = function( rate, rated, likelyOrNotInterested, suggested )
{
	globalVariables.sliderRateObject.rate = rate;
	globalVariables.sliderRateObject.likelyOrNotInterested = likelyOrNotInterested;
	globalVariables.sliderRateObject.suggested = suggested;
	globalVariables.sliderRateObject.rated = rated;	
}
generalFunctions.colorJinniRatedSlider = function()
{
	document.getElementById('sliderContainer').className = 'sliderContainter suggestedRating';
	document.getElementById('sliderTitle').innerHTML = 'Your Match:'
	document.getElementById('sliderRateText').style.visibility = 'visible';
	
}

generalFunctions.colorUserRatedSlider = function()
{
	document.getElementById('sliderContainer').className = 'sliderContainter';
}

generalFunctions.setSliderToLikelyOrNotSeen = function( likelyOrNotInterested )
{
	generalFunctions.saveSliderInitialStatus( 0 , false,likelyOrNotInterested,false );
	generalFunctions.setContentRatingSlider(  );
	if( likelyOrNotInterested != null)
	{
		generalFunctions.colorUserRatedSlider();
		document.getElementById('sliderTitle').innerHTML = 'Rate this title'
		document.getElementById('sliderRateText').style.visibility = 'hidden';
		
					
		if( likelyOrNotInterested == true )
		{
			showLikelyToSee();
		}
		if( likelyOrNotInterested == false )
		{
			showNotForMe();
		}
	}
	generalFunctions.colorUserRatedSlider();
	
	
}
generalFunctions.setSliderInitialStatus = function( sliderStatus )
{
	globalVariables.contentDetailsSliderInitialStatus = sliderStatus;
}

generalFunctions.initSliderByAjax = function()
{
	
	generalFunctions.setContentRatingSlider( 0 );
	
	
	AjaxUserRatingBean.getContentRating(discoveryCurrentContentId , {
	
			errorHandler: generalFunctions.handleAjaxServerErrors,
			
			callback: function(rate) {
				
				
				if( rate.likelyOrNotInterested != null)
				{
					generalFunctions.setSliderInitialStatus('likelyOrNotInterested');
					
					generalFunctions.colorUserRatedSlider();
					document.getElementById('sliderTitle').innerHTML = 'Rate this title'
					document.getElementById('sliderRateText').style.visibility = 'hidden';
					
					if( rate.likelyOrNotInterested == true )
					{
						showLikelyToSee();
					}
					if( rate.likelyOrNotInterested == false )
					{
						showNotForMe();
					}
				}
				else
				{
					setNotSeenIt();
					generalFunctions.setSliderInitialStatus('NotSeenIt');
					
					if( rate.rated)
					{
						generalFunctions.setSliderInitialStatus('rated');
						generalFunctions.colorUserRatedSlider();
						
						document.getElementById('sliderTitle').innerHTML = 'Your Rating:'
						document.getElementById('sliderRateText').style.visibility = 'visible';
						document.getElementById('sliderRateText').style.display = 'inline';
						document.getElementById('sliderRateText').innerHTML =  globalVariables.contentDetailsSlider.valToName( rate.rate )
						
					}
					if( rate.suggested)
					{
						generalFunctions.setSliderInitialStatus('suggested');
						generalFunctions.colorJinniRatedSlider();
						
						document.getElementById('sliderTitle').innerHTML = 'Your Match:'
						document.getElementById('sliderRateText').style.visibility = 'visible';
						document.getElementById('sliderRateText').style.display = 'inline';
						document.getElementById('sliderRateText').innerHTML =  globalVariables.contentDetailsSlider.valToName( rate.rate )
					}
					if( !rate.suggested && !rate.rated)
					{
						document.getElementById('sliderRateText').style.visibility = 'hidden';
						generalFunctions.colorUserRatedSlider();
						document.getElementById('sliderTitle').innerHTML = 'Rate this title';
						
					}
					
				}
				
				generalFunctions.saveSliderInitialStatus( rate.rate, rate.rated,rate.likelyOrNotInterested, rate.suggested );
				generalFunctions.setContentRatingSlider(  );
				globalVariables.contentDetailsSlider.setPointerToValue = function()
				{
					var sliderObj = document.getElementById( "simpleSlider::" + this.id );
					var pointerObj = document.getElementById( "simpleSliderPointer::" + this.id );
					//var xPosition = 8;
					var yPosition = sliderObj.offsetTop;
					if ( document.all )
					{
						yPosition = sliderObj.parentNode.parentNode.offsetTop + sliderObj.parentNode.parentNode.parentNode.offsetTop + 6;
					}
					pointerObj.style.left = 25 + ((this.size / (this.maxVal - this.minVal))*(this.value - this.minVal)) + "px";
					if(document.all)
						pointerObj.style.top = (yPosition + 6) + "px";
					else
						pointerObj.style.top = (yPosition + 10) + "px";
				}	
				globalVariables.contentDetailsSlider.setPointerToValue();
					
			}
			
		}
	)
}

generalFunctions.showMiniCollageRollover = function ( imageObj )
{
	
	var content = generalFunctions.contentImageInfoHash.get( imageObj.id.split("-")[1] );
	generalFunctions.miniCollageRollover.x = getPosX( imageObj )- 325;
	generalFunctions.miniCollageRollover.y = getPosY( imageObj ) - 127;
	generalFunctions.miniCollageRollover.title = content.title;
	generalFunctions.miniCollageRollover.synopsis = content.synopsis;
	generalFunctions.miniCollageRollover.year = content.year;
	generalFunctions.miniCollageRollover.uniqueName = content.uniqueName;
	generalFunctions.miniCollageRollover.tempImage = content.image;
	generalFunctions.miniCollageRollover.image = content.image.replace(/-\d\.jpeg/,"-3.jpeg");
	generalFunctions.miniCollageRollover.link = content.link;
	generalFunctions.miniCollageRollover.availabilityString = content.availabilityString;
	generalFunctions.miniCollageRollover.displayInterval = window.setTimeout("generalFunctions.miniCollageRollover.show();",500);
}

generalFunctions.toggleUserMenu = function()
{
	var menu = document.getElementById("userNavigationMenu");
	var  reference =  document.getElementById("loginBoxUsername");
	
	if( menu.style.display == "block")
	{
		menu.style.left = "0px";
		menu.style.top = "0px";
		menu.style.display = "none";
	}
	else
	{
		menu.style.left = (getPosX( reference ) - 64) + "px";
		menu.style.top = (getPosY( reference ) + 22) + "px";
		menu.style.display = "block";
	}
	
}
generalFunctions.showLoginBox = function( privatePageURL )
{
	utils.dimThePage();
	document.getElementById('jinniAlert').style.display = "none";	
	document.getElementById("loginOverlay").style.display = "block";
	if( privatePageURL != true )
	{
		privatePageURL = privatePageURL == null ? '' : privatePageURL;
		document.getElementById('loginTitle').innerHTML = "Please log in first";
		document.getElementById('privatePage').value = privatePageURL;
		document.getElementById('whySignIn').style.display = 'block';
	}
	else if(privatePageURL == true)
	{
		document.getElementById('loginTitle').innerHTML = "Log in to Jinni";
		document.getElementById('privatePage').value = "";
	}
	document.getElementById('user').focus();
}
generalFunctions.hideLoginBox = function()
{
	utils.unDimThePage();
	globalVariables.wantedToInvite = false;
	document.getElementById("loginOverlay").style.display = "none";
}
generalFunctions.logIn = function()
{
	if( globalVariables.wantedToInvite )
	{
		sessionConfigCookie.setValue(sessionConfigCookie.INVITATION_REQUESTED,1);
	}
	document.getElementById('loginForm').submit();
}
generalFunctions.isSignedIn = function()
{
	var isLoggedIn = true;
	
	userStatusAjaxUtil.isLoggedIn(
		{
			callback: function( serverData ){ isLoggedIn = serverData;},
			async: false
		}
	
	);
	
	return isLoggedIn;
}
generalFunctions.goToPrivatePage = function( url )
{
	if( globalVariables.isUserSignIn )
	{
		if( !generalFunctions.isSignedIn() )
		{
			generalFunctions.showLoginBox( url );
		}
		else
		{
			//document.location.href = url;
			return true;
		}
		
	}
	else
	{
		generalFunctions.showLoginBox( url );
	}
	return false;
}
generalFunctions.toggleSliderLoginToolTip = function( show )
{
	var img = document.getElementById('anonymousSliderImg');
	var toolTip = document.getElementById('serverFeedback');
	
	if( show ){
		toolTip.style.left = (getPosX(img) + 50) + "px";
		toolTip.style.top = (getPosY(img) - 23) + "px";
		
		document.getElementById('serverFeedbackMessage').innerHTML = "Our estimate how well this title matches your taste based on your ratings."
		toolTip.style.opacity = 1;
		toolTip.style.display = "block";
	}
	else
	{
		toolTip.style.left = "0px";
		toolTip.style.top = "0px";
		toolTip.style.opacity = 0;
		toolTip.style.display = "none";
		
		
	}
}
generalFunctions.setStoryTunersAccordingToSearch = function( storyTuners )
{
	var pace = storyTuners.pace;
	var obscure = storyTuners.obscure;
	var realistic = storyTuners.realistic;
	var serious = storyTuners.serious;
	
	sliderOB = thinSliderArray[0];
	sliderSE = thinSliderArray[1];
	sliderFN = thinSliderArray[2];
	sliderSP = thinSliderArray[3];
	
	showTasteScales(document.getElementById('taste_menu'),document.getElementById('taste_link'));
	initThinSliders(document.getElementById('taste_menu'));
	discoveryShow = true;
	
	if( obscure != -1 )
	{	
		sliderOB.sliderEnabled = true;
		sliderOB.initialValue = obscure;
		sliderOB.setState();
	}
	if( realistic != -1 )
	{
		sliderFN.sliderEnabled = true;
		sliderFN.initialValue = realistic;
		sliderFN.setState();
	}
	if( serious != -1 )
	{
		sliderSE.sliderEnabled = true;
		sliderSE.initialValue = serious;
		sliderSE.setState();
	}
	if( pace != -1 )
	{
		sliderSP.sliderEnabled = true;
		sliderSP.initialValue = pace;
		sliderSP.setState();
	}
}
generalFunctions.toggleCloudDescription = function( button )
{
	if( button.className.indexOf('rua') > -1 )
	{
		document.getElementById('tasteDescription').style.display = 'none';
		button.className = button.className.replace(/rua/, 'rda');
		sessionConfigCookie.setValue(sessionConfigCookie.CLOUD_DESCRIPTION,1);
	}
	else if( button.className.indexOf('rda') > -1 )
	{
		document.getElementById('tasteDescription').style.display = 'block';
		button.className = button.className.replace(/rda/, 'rua');
		sessionConfigCookie.setValue(sessionConfigCookie.CLOUD_DESCRIPTION,0);
	}
}

banners.invite = function(){
	
	invite.openInvitation();
}
banners.search = function(){
	
	document.location.href = "/";
}
banners.recommendations = function(){
	
	if( generalFunctions.goToPrivatePage("/user/"+ globalVariables.user.userName + "/recommendations/") )
	{
		document.location.href = "/user/"+ globalVariables.user.userName + "/recommendations/";
	}
}
banners.tastetest = function(){
	
	if( generalFunctions.goToPrivatePage("/user/"+ globalVariables.user.userName + "/taste-test/") )
	{
		document.location.href = "/user/"+ globalVariables.user.userName + "/taste-test/";
	}
	
}
banners.signup = function(){
	
	document.location.href = "/join.html";
}
