if( !recommendationFuncs) 	var recommendationFuncs = {	nflxInterval: 							null, 
														integrationResultObj:					null, 
														isReimport: 							false,
														integrateWhenFaultRatingImport:			false,
														isReadyForSubmit: 						true,
														rollOverLock:							false
														
														};
														
if( !myRatingsFuncs) 		var myRatingsFuncs = {selectedContentId: null,selectedStripIndex:null };



recommendationFuncs.recRolloverOpacityTween;
recommendationFuncs.rolInt;
recommendationFuncs.HIGHLIGHT = true;
recommendationFuncs.REMOVE_HIGHLIGHT = false;
recommendationFuncs.currentlyHighlighted = null;





recommendationFuncs.switchToRemovalMode = function()
{
	
	if( document.URL.indexOf('favorites') > 0 )
	{
		document.getElementById('favoriteForm').submit();
	}
	else if( document.URL.indexOf('wish-list') > 0 )
	{
		alert('wish-list');
	}
	else //recommendation page
	{
		document.getElementById('normalMode').style.display = 'none';
		document.getElementById('recommendationForm:removalSelection:0').checked = true;
		document.getElementById('removalMode').style.display = 'block';
	}
	return false;
}
recommendationFuncs.switchToNormalMode = function(recommendationID)
{
	document.getElementById('normalMode').style.display = 'block';
	document.getElementById('loaderImage').className = 'invisible loaderImage';
	document.getElementById('removalMode').style.display = 'none';
	
	return false;
}
function deleteContentFromList()
{
	//used by user pages to remove whishlists, favorite & recommendation
	if( document.all == undefined )
		document.getElementById('loaderImage').className = 'visible loaderImage';
	
	return true;
}




recommendationFuncs.resetUserForm = function()
{
	try{
		
		document.getElementById('hiddenContentToDelete').value = -1;
		document.getElementById('hiddenNewUserRating').value = -1;
		document.getElementById('hiddenContentToAddToFavorite').value = -1;
		document.getElementById('hiddenContentId').value = -1;
	}
	catch(e){}
}
//recommendationFuncs.showListRolloverToolTip = function(message, divId)
//{
//	var favoritesDiv = document.getElementById( divId );
//	var popup = document.getElementById('addToWishlistToolTip');
//	var span = document.getElementById('addToWishlistReply');
//	span.innerHTML = message ;
//	popup.style.top  = getPosY(favoritesDiv) - 30 + "px";
//	popup.style.left  = getPosX(favoritesDiv) - 30 + "px";
//	popup.style.display = 'block' ;
//	
//	
//	var toolTipTweenIn = new OpacityTween(popup,Tween.regularEaseIn,0,100,1);
//	
//	toolTipTweenIn.onMotionFinished = function(){
//		
//		var toolTipTweenOut = new OpacityTween(popup,Tween.regularEaseOut, 100, 0, 1 );
//		toolTipTweenOut.onMotionFinished = function(){}
//		toolTipTweenOut.start();
//	}
//	
//	toolTipTweenIn.start();
//	
//	
//}


recommendationFuncs.addRecommendationToFavorites = function()
{
	AjaxUserRecommendationsBean.addToFavoriteByAjax( myRatingsFuncs.selectedContentId );
	
	recommendationFuncs.showTooltip( 'favorite', 'Thanks! This recommendation will be removed', true);
	
}

recommendationFuncs.removeRecommendation = function()
{
	var removalReason = "";
	
	if( document.getElementById('recommendationForm:removalSelection:0').checked ) removalReason = 'UserLiked';
	else if( document.getElementById('recommendationForm:removalSelection:1').checked ) removalReason = 'UserDisLiked';
	else if ( document.getElementById('recommendationForm:removalSelection:2').checked ) removalReason = 'UserNotInterested';
	
	
	AjaxUserRecommendationsBean.removeRecommendationByAjax ( myRatingsFuncs.selectedContentId, removalReason);
	
	
	recommendationFuncs.showTooltip( 'removeRecommendationBtn', 'This recommendation will be removed',true);
	
	
	return false;
	
}

recommendationFuncs.showTooltip = function ( locationObjID, message, fadeOut )
{
	
	var favoritesDiv = document.getElementById( locationObjID );
	var popup = document.getElementById('addToWishlistToolTip');
	var span = document.getElementById('addToWishlistReply');
	span.innerHTML = message ;
	popup.style.top  = getPosY(favoritesDiv) - 30 + "px";
	popup.style.left  = getPosX(favoritesDiv) - 30 + "px";
	popup.style.display = 'block' ;
	
	recommendationFuncs.rollOverLock = true;
	
	var toolTipTweenIn = new OpacityTween(popup, Tween.regularEaseIn, 0, 100, 1);
	
	toolTipTweenIn.onMotionFinished =  window.setTimeout( function(){
		
		
		var toolTipTweenOut = new OpacityTween(popup, Tween.regularEaseOut, 100, 0, 1 );
		
		toolTipTweenOut.onMotionFinished = function(){
			
			popup.style.display = 'none' ;
			
			
			if( fadeOut == true )
			{
				document.getElementById('listRollover').style.display = 'none';
				recommendationFuncs.fadeOutRecommendations( myRatingsFuncs.selectedContentId );
			}
			else
			{
				recommendationFuncs.rollOverLock = false;
			}
		}
		toolTipTweenOut.start();
		
	}, 2000);
	
	
	
	
	toolTipTweenIn.start();
	
}


recommendationFuncs.fadeOutRecommendations = function( recommendationID )
{
	var container = document.getElementById('recommendationsContainer' );	
	
	container.style.visibility = 'hidden';
	
	try{
			document.getElementById('recommendationsList').removeChild( document.getElementById( 'container-' + recommendationID ) );
			document.getElementById('listRollover').style.display = 'none';
		}catch(e){/*sometimes the rollover is still there */}
	
	container.style.visibility = 'visible';
	
	recommendationFuncs.rollOverLock = false;
	
//	var containerFadeoutTween = new OpacityTween(container,Tween.regularEaseOut,100,0,1);
//	
//	containerFadeoutTween.onMotionFinished = function(){
//		
//		document.getElementById( 'container-' + recommendationID ).style.display = 'none';
//		
//		try{
//			document.getElementById('recommendationsList').removeChild( document.getElementById( 'container-' + recommendationID ) );
//			document.getElementById('listRollover').style.display = 'none';
//		}catch(e){/*sometimes the rollover is still there */}
//		
//		if( recommendationFuncs.isLastRecommendation() )
//		{
//			
//			document.getElementById('loadingMessage').className = 'recommendationsContainer';
//			startDots();
//			
//			recommendationFuncs.getRecommendations();
//		}
//		else
//		{
//			var containerFadeinTween = new OpacityTween(container,Tween.regularEaseOut,0,100,1);
//			
//			containerFadeinTween.onMotionFinished = function(){
//				
//					recommendationFuncs.rollOverLock = false;	
//					 	
//				}
//				
//			containerFadeinTween.start();
//		}
//	}
//	
//	containerFadeoutTween.start();
//				
}
recommendationFuncs.isLastRecommendation = function()
{
	var recs = document.getElementById('recommendationsList').innerHTML;
	
	if(recs.indexOf("div") < 0 && recs.indexOf("DIV") < 0)
		return true;
	
	return false;
}


recommendationFuncs.removeFromWishlist = function()
{
	document.getElementById('hiddenContentToDelete').value = myRatingsFuncs.selectedContentId;
	
	
	return true;
}

recommendationFuncs.removeFromFavorite = function()
{ 
	document.getElementById('hiddenContentToDelete').value = myRatingsFuncs.selectedContentId;
	
	return true;
}

recommendationFuncs.paintContainer = function(container, action)
{
	if( action == recommendationFuncs.HIGHLIGHT )
	{
		container.style.backgroundColor = '#F0F6D2';
		recommendationFuncs.currentlyHighlighted = container;
	}
	else container.style.backgroundColor = 'white';
}

recommendationFuncs.recommendationRollout = function( e, container, forced )
{
	var goingToObj = null;
	
	if( e.relatedTarget) goingToObj = e.relatedTarget;
	else goingToObj = e.toElement;
	
	if( container && !isChildOf( goingToObj, document.getElementById('listRollover'))) 
		recommendationFuncs.paintContainer(container, recommendationFuncs.REMOVE_HIGHLIGHT);
	
	
	
	if(goingToObj.tagName.toLowerCase() == 'body' || goingToObj.tagName.toLowerCase() == 'body' || !isChildOf( goingToObj, document.getElementById('listRollover')) )
	{
		document.getElementById('listRollover').style.display = 'none';
		
		if( document.getElementById('addToWishlistToolTip') )
			document.getElementById('addToWishlistToolTip').style.display = 'none'; //delete the tooltip if exists
		
		recommendationFuncs.paintContainer(recommendationFuncs.currentlyHighlighted , recommendationFuncs.REMOVE_HIGHLIGHT);
		recommendationFuncs.currentlyHighlighted = null;
		window.clearTimeout( recommendationFuncs.rolInt );
	}
}



recommendationFuncs.recommendationRollover = function(obj,e)
{
	window.clearTimeout( recommendationFuncs.rolInt );

	
	/* don't show rollover if:*/
	var nflxIframe = document.getElementById('NFLX_IFRAME_LAYER');
	if(nflxIframe && nflxIframe.style.display == 'block') return;
	if(recommendationFuncs.rollOverLock) return;
	
	
	var thubmnail = document.getElementById('container-' + obj.id);
	var rollover = document.getElementById('listRollover');
	
	
	var containerImgWrapper = document.getElementById('imgcontainer-' + obj.id);
	var containerImageSrc = containerImgWrapper.getElementsByTagName('img')[0].src;
	
	
	document.getElementById('rollOverImage').src = containerImageSrc;
	//document.getElementById('rollOverImage').src = mediaServer + "/" + (obj.type == 'ShortFilm' ? 'short-film' : obj.type == 'TvSeries' ? 'tv' : 'movie') + "/" + obj.uname + "/" + obj.uname + "-1.jpeg";
	document.getElementById('rollOverImage').src = document.getElementById('rollOverImage').src.replace(/-\d\.jpeg/,'-1.jpeg');
	
	
	recommendationFuncs.paintContainer(thubmnail, recommendationFuncs.HIGHLIGHT);
	
	recommendationFuncs.rolInt = window.setTimeout(function(){
		
		try{
			if( document.getElementById('recommendationForm:_nflxContainer') || document.getElementById('wishListForm:_nflxContainer') || document.getElementById('favoriteForm:_nflxContainer'))
			{
				var theNflxContainter = document.getElementById('recommendationForm:_nflxContainer') ? document.getElementById('recommendationForm:_nflxContainer') : document.getElementById('wishListForm:_nflxContainer') ? document.getElementById('wishListForm:_nflxContainer') : document.getElementById('favoriteForm:_nflxContainer') ? document.getElementById('favoriteForm:_nflxContainer') : '';
				theNflxContainter.style.visibility = "hidden";
				if( obj.nflx.id == "" )
				{
					theNflxContainter.style.visibility = "hidden";
				}
				else
				{
					theNflxContainter.style.visibility = "visible";
					
					if(obj.type == 'TvSeries')
					{
						nflxFucntions.showSearchLink( obj.title );
					}
					else if( obj.nflx.consumption.indexOf('Ship') > -1 && obj.nflx.consumption.indexOf('Online') > -1 )
					{
						nflxFucntions.showAddPlayBtn();
					}
					else if ( obj.nflx.consumption.indexOf('Online') > -1 )
					{
						nflxFucntions.showPlayBtn();
					}
					else if ( obj.nflx.consumption.indexOf('Ship') > -1 )
					{
						nflxFucntions.showAddBtn();
					}
					nflxFucntions.setNflxID( obj.nflx.id );
				}
				
			}
			
			myRatingsFuncs.selectedContentId = obj.id;
			
			document.getElementById('rollOverImageLink').style.cursor = 'default';
			//document.getElementById('rollOverImageLink').href = "/" + (obj.type == 'ShortFilm' ? 'shorts' : obj.type == 'TvSeries' ? 'tv' : 'movies') + "/" + obj.uname+ "/" ;
				
			
			
			rollover.style.left = getPosX(thubmnail) + "px";
			rollover.style.top = getPosY(thubmnail) + "px";
			
			
			
			
			if( obj.year > 0)
				document.getElementById('rolloverTitle').innerHTML = "<span class='movieTitle'>" + obj.title + "</span><span class='year'>" + obj.year + "</span><span class='contentType'>" + (obj.type == 'ShortFilm' ? 'Short' : obj.type == 'TvSeries' ? 'TV' : 'Movie') + "</span>"
			else
				document.getElementById('rolloverTitle').innerHTML = "<span class='movieTitle'>" + obj.title + "</span><span class='contentType'>" + (obj.type == 'ShortFilm' ? 'Short' : obj.type == 'TvSeries' ? 'TV' : 'Movie') + "</span>"
			
			
			document.getElementById('rolloverSynopsis').innerHTML = obj.shortSyn.decode() + "<a href='/" + (obj.type == "ShortFilm" ? "shorts" : obj.type == 'TvSeries' ? "tv" : "movies") + "/" + obj.uname + "/'>overview</a>";
			
			if( obj.jinniRated == true)
			{
				obj.jinniRated = false;
				obj.rate = 0.0;
				
			}
			if( document.getElementById('ratingSlider'))
			{
				recommendationFuncs.initListRolloverSlider(obj);
				recommendationFuncs.paintSlider( obj );
				recommendationFuncs.switchToNormalMode();
			}
			moreLikeItTitle = obj.title;
			discoveryCode = obj.id;
			discoveryCurrentContentId = obj.id;
			
			if( obj.availability.charAt(0) == '1' ) {
			
				document.getElementById('availableImg0').style.backgroundImage = "url("+imagePath+"16_cinema_white.png)";
				document.getElementById('availableImg0').style.display = 'inline';
			} 
			else document.getElementById('availableImg0').style.display = 'none';
			
			if( obj.availability.charAt(1) == '1' ) {
			
				document.getElementById('availableImg1').style.backgroundImage = "url("+imagePath+"16_dvd_white.png)"; 
				document.getElementById('availableImg1').style.display = 'inline';	
			}
			else document.getElementById('availableImg1').style.display = 'none';
			if( obj.availability.charAt(2) == '1' ) {
			
				document.getElementById('availableImg2').style.backgroundImage = "url("+imagePath+"16_tv_white.png)";
				document.getElementById('availableImg2').style.display = 'inline';
			}
			else document.getElementById('availableImg2').style.display = 'none';
			if( obj.availability.charAt(3) == '1' ){
			
				 document.getElementById('availableImg3').style.backgroundImage = "url("+imagePath+"16_download_white.png)";
				 document.getElementById('availableImg3').style.display = 'inline';
			}
			else document.getElementById('availableImg3').style.display = 'none';
			if( obj.availability.charAt(4) == '1' ){
			
				 document.getElementById('availableImg4').style.backgroundImage = "url("+imagePath+"16_mobile_white.png)";
				document.getElementById('availableImg4').style.display = 'inline';
			}
			else document.getElementById('availableImg4').style.display = 'none';
			if( obj.availability.charAt(5) == '1' ){
			
				 document.getElementById('availableImg5').style.backgroundImage = "url("+imagePath+"16_online_white.png)";
				document.getElementById('availableImg5').style.display = 'inline';
			}
			else document.getElementById('availableImg5').style.display = 'none';
			
			
//			if( obj.availability.charAt(6) == '1' ){
//			
//				 document.getElementById('rollOverImage').src = mediaServer + "/" + (obj.type == 'ShortFilm' ? 'short-film' : obj.type == 'TvSeries' ? 'tv' : 'movie') + "/" + obj.uname + "/" + obj.uname + "-1.jpeg";
//			
//			}
//			else document.getElementById('rollOverImage').src = mediaServer + "/no-image/content-no-image/no-image-2.jpeg";
			
			document.getElementById('linkToWatchit').href = "/" + (obj.type == 'ShortFilm' ? 'shorts' : obj.type == 'TvSeries' ? 'tv' : 'movies') + "/" + obj.uname+ "/watch-it/" ;
	
	
			try{
				rollover.style.opacity = 0;
				rollover.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
			}catch(e){}
			
			rollover.style.display = 'block';
			
			recommendationFuncs.rolInt = window.setTimeout(function(){
				
				recommendationFuncs.recRolloverOpacityTween = new OpacityTween(document.getElementById('listRollover'),Tween.regularEaseOut, 0, 100, 0.2);
				recommendationFuncs.recRolloverOpacityTween.start();
				
				recommendationFuncs.recRolloverOpacityTween.onMotionFinished = function(){
					
				document.getElementById('rollOverImageLink').href = "/" + (obj.type == 'ShortFilm' ? 'shorts' : obj.type == 'TvSeries' ? 'tv' : 'movies') + "/" + obj.uname+ "/" ;
				document.getElementById('rollOverImageLink').style.cursor = 'pointer';
				
				top.listRollOverSliderObject.setPointerToValue();
				
				recommendationFuncs.paintContainer(thubmnail, recommendationFuncs.REMOVE_HIGHLIGHT);
				
				}
				
				
			},100);
			
		}
		catch(ex){
			
			var x=ex;
		}
	
	},1000);
}

recommendationFuncs.paintSlider = function(obj)
{
	
	//temorary rate hack
	if( obj.jinniRated == true)
	{
		obj.jinniRated = false;
		obj.rate = 0.0;
		
	}
	//end of temporary rate hack
	
	if( obj.rate > 0 )
	{
			recommendationFuncs.setRolloverSliderRateText( obj.rate );
			top.sliderInitialText = document.getElementById('rateText').innerHTML;
	}
	if( obj.jinniRated == true)
	{
		recommendationFuncs.colorJinniRatedSlider();
	}
	else
	{
		recommendationFuncs.colorUserRatedSlider();
		
	}
}
recommendationFuncs.colorJinniRatedSlider = function()
{
	document.getElementById('simpleSlider::top.listRollOverSliderObject').style.borderColor = "#579482";
	document.getElementById('rubishImage').src = imagePath + "24_rubish_turquois.gif";
	document.getElementById('oscarImage').src = imagePath + "24_Oscar_turquois.gif";
	document.getElementById('sliderTitle').innerHTML = "Your Match:"
	document.getElementById('simpleSliderOverlay::top.listRollOverSliderObject').style.background = "url(" + imagePath + "sliderleft_turq.gif)";
	document.getElementById('simpleSlider::top.listRollOverSliderObject').style.background = "url(" + imagePath + "sliderright_turq.gif)";
	document.getElementById('simpleSliderPointer::top.listRollOverSliderObject').style.background = "";
	document.getElementById('simpleSliderPointer::top.listRollOverSliderObject').style.background = "transparent url(" + imagePath + "knob_turquois.gif) no-repeat scroll center center"
}
recommendationFuncs.colorUserRatedSlider = function()
{
	document.getElementById('simpleSlider::top.listRollOverSliderObject').style.borderColor = "#CD3301";
	document.getElementById('rubishImage').src = imagePath + "24_rubish_red.gif";
	document.getElementById('oscarImage').src = imagePath + "24_Oscar_red.gif";
	document.getElementById('sliderTitle').innerHTML = "Your rating:";
	document.getElementById('simpleSliderOverlay::top.listRollOverSliderObject').style.background = "transparent url(" + imagePath + "sliderleft.gif) repeat scroll left center";
	document.getElementById('simpleSlider::top.listRollOverSliderObject').style.background = "transparent url(" + imagePath + "sliderright.gif) repeat scroll left center";
	document.getElementById('simpleSliderPointer::top.listRollOverSliderObject').style.background = "transparent url(" + imagePath + "knob.gif) no-repeat scroll center center";
	
}


recommendationFuncs.initListRolloverSlider = function(obj)
{

	top.sliderInitialText = "";
	top.listRollOverSliderObject = new sliderfuncs.SimpleSlider( "top.listRollOverSliderObject" );
	top.listRollOverSliderObject.setContainer( document.getElementById('ratingSlider') );
	top.listRollOverSliderObject.setMaxVal( 10 );
	top.listRollOverSliderObject.setStepSize ( 1.0 );
	top.listRollOverSliderObject.setValue( obj.rate );
	
	recommendationFuncs.setRolloverSliderRateText( -1 );
	
	top.listRollOverSliderObject.setPointerToValue = function()
	{
		var sliderObj = document.getElementById( "simpleSlider::" + this.id );
		var pointerObj = document.getElementById( "simpleSliderPointer::" + this.id );
		var xPosition = 237;
		var yPosition = sliderObj.offsetTop;
		if ( document.all )
		{
			yPosition = sliderObj.parentNode.parentNode.offsetTop + sliderObj.parentNode.parentNode.parentNode.offsetTop + 6;
		}
		pointerObj.style.left = (xPosition - 4) + ((this.size / (this.maxVal - this.minVal))*(this.value - this.minVal)) + "px";
		pointerObj.style.top = (yPosition + 10) + "px";
	}
	top.listRollOverSliderObject.addEventListener( function( event ){
		if( event.type == 'DragEnd' )
		{
			recommendationFuncs.setRolloverSliderRateText( event.slider.getValue() );
			top.sliderInitialText = document.getElementById('rateText').innerHTML;
			if(document.URL.indexOf('recommendation') > 0)
				recommendationFuncs.rateRecommendation( event.slider.getValue() );
			else
			{
				recommendationFuncs.rateFavoriteOrWishlist( event.slider.getValue() );
				obj.rate = event.slider.getValue();
			}
		}
		else if( event.type == 'Drag' )
		{
			recommendationFuncs.setRolloverSliderRateText( event.slider.getValue() );
			recommendationFuncs.colorUserRatedSlider();
		}
		else if( event.type == 'layoutDragAbort' )
		{
			document.getElementById('rateText').innerHTML = top.sliderInitialText;
			//document.getElementById('sliderTitle').innerHTML = 'Rate this title:';
		}
		else if( event.type == 'LayoutDrag' )
		{
			document.getElementById('sliderTitle').innerHTML = 'Your rating:';
			document.getElementById('rateText').innerHTML = '';
			recommendationFuncs.setRolloverSliderRateText( event.slider.getValue() );
		}
		
		
	} );
	top.listRollOverSliderObject.init();
}
recommendationFuncs.rateRecommendation = function( newRate )
{
	
	AjaxUserRecommendationsBean.updateUserRatingByAjax( myRatingsFuncs.selectedContentId, newRate, {
		
		callback: function(){ recommendationFuncs.showTooltip( 'ratingSlider', 'Thanks! This recommendation will be removed', true); },
		errorHandler: 	generalFunctions.handleAjaxServerErrors
		
		
	} );
	
}
recommendationFuncs.rateFavoriteOrWishlist = function( rate )
{
	AjaxUserRatingBean.submiteContentUserRating(myRatingsFuncs.selectedContentId,  parseInt( rate ), {
		
		callback: 		function(message) {recommendationFuncs.showTooltip('ratingSlider', message , false);},
  		
  		errorHandler: 	generalFunctions.handleAjaxServerErrors
  	
		}
	
	)
}

recommendationFuncs.setRolloverSliderRateText = function(rateAsNumber)
{
	var valueAsString = tastetestfuncs.valToName( rateAsNumber );
	document.getElementById('rateText').innerHTML = valueAsString;
}

myRatingsFuncs.removeRatingStrip = function( stripID, contentID )
{
	stripObj = document.getElementById( stripID );
	
	document.getElementById('ratingStripSlider').style.display='none';
	
	AjaxUserRatingBean.removeRating( contentID,{
		
		errorHandler: generalFunctions.handleAjaxServerErrors
		
	} );
	
	
	var stripTween = new Tween(stripObj.style,'height',Tween.regularEaseInOut,stripObj.clientHeight,0,1,'px');
	
	stripTween.onMotionFinished = function(){
		
		stripObj.style.display = 'none';
		
		document.getElementById('ratingNumTitle').innerHTML = "&nbsp;(" + --ratingNum + ")";
		
		};
		
	stripTween.start();
}

myRatingsFuncs.showRatingStripSlider = function (stripIndex, contentId)
{
	var posObj  = document.getElementById('rateButton['+ stripIndex +']');
	myRatingsFuncs.selectedContentId = contentId;
	myRatingsFuncs.selectedStripIndex = stripIndex;
	var stripRate = document.getElementById('digitalRate['+ stripIndex +']') 
	var rate = null;
	if( stripRate )
	{
		stripRate = stripRate.innerHTML;
		rate = stripRate.substring(0, stripRate.indexOf("/"));
		if( rate == '')
			rate = document.getElementById('notRatedRank['+ stripIndex +']').innerHTML;
	}
	
	myRatingsFuncs.initRatingStripSlider( posObj,  rate, stripIndex);
	document.getElementById('ratingStripSlider').style.left = ( getPosX( posObj ) -30 ) + "px";
	document.getElementById('ratingStripSlider').style.top =  ( getPosY( posObj) - 70 ) + "px";
	document.getElementById('ratingStripSlider').style.display = 'block';
	top.listRollOverSliderObject.setPointerToValue();
	discoveryCurrentContentId = contentId;
	
}
myRatingsFuncs.rate = function( rate, stripIndex )
{
	AjaxUserRatingBean.submiteContentUserRating(myRatingsFuncs.selectedContentId,  parseInt( rate ),{ 
		
		
		callback: function(data) {myRatingsFuncs.updateRatingStrip( rate, stripIndex );},
		errorHandler: generalFunctions.handleAjaxServerErrors
  	});

}
myRatingsFuncs.updateRatingStrip = function( rate, stripIndex )
{
	if( isNaN( rate ))
	{
		if(rate.indexOf('Likely') == 0)
		{
				document.getElementById('rateSymbolsContainer[' + myRatingsFuncs.selectedStripIndex + ']').style.display = 'none';
				document.getElementById('likelyOrNotForMeContainer[' + myRatingsFuncs.selectedStripIndex + ']').style.display = 'inline';
				document.getElementById('notRatedRank[' + myRatingsFuncs.selectedStripIndex + ']').className= 'likekyToSee';
				document.getElementById('notRatedRank[' + myRatingsFuncs.selectedStripIndex + ']').innerHTML = 'Likely to see';
				
		}
		else
		{
				document.getElementById('rateSymbolsContainer[' + myRatingsFuncs.selectedStripIndex + ']').style.display = 'none';
				document.getElementById('likelyOrNotForMeContainer[' + myRatingsFuncs.selectedStripIndex + ']').style.display = 'inline';
				document.getElementById('notRatedRank[' + myRatingsFuncs.selectedStripIndex + ']').className= 'notForMe';
				document.getElementById('notRatedRank[' + myRatingsFuncs.selectedStripIndex + ']').innerHTML = 'Not for me';
		}
	}
	else 
	{
		
		
		document.getElementById('digitalRate['+ stripIndex +']').innerHTML = rate + "/10";
		document.getElementById('textualRate['+ stripIndex +']').innerHTML = tastetestfuncs.valToName( rate );
		if(rate > 7.5)
			document.getElementById('rateImage['+ stripIndex +']').src = imagePath + "20_praise_red.png";
		else if(rate < 4.5)
			document.getElementById('rateImage['+ stripIndex +']').src = imagePath + "20_rubish_red.png";
		else
			document.getElementById('rateImage['+ stripIndex +']').src = imagePath + "spacer.gif";
		
		var today = new Date();
		document.getElementById('ratingDate['+ stripIndex +']').innerHTML =   (today.getMonth()+1) + "/" + today.getDate() + "/" + today.getFullYear().toString().substring(2);
		
		document.getElementById('likelyOrNotForMeContainer['+ stripIndex +']').style.display = 'none'
		document.getElementById('rateSymbolsContainer['+ stripIndex +']').style.display = 'inline'
	}
	
}
myRatingsFuncs.initRatingStripSlider = function( postionObj, rate, stripIndex )
{
	var sliderInitialText = "";
	if(isNaN( rate ))
	{
		var notForMeOfNotSeenIt = rate;
		rate = 0;
		
		if( notForMeOfNotSeenIt.indexOf('Likely') == 0 )
		{
			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('rateText').innerHTML = "";
		}
		else if( notForMeOfNotSeenIt.indexOf('Not') == 0 )
		{
			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('rateText').innerHTML = "";
		}
	}
	else
	{
	
			recommendationFuncs.setRolloverSliderRateText( rate );
			sliderInitialText = document.getElementById('rateText').innerHTML;
			document.getElementById('rolloverNotSeenIt').style.display = 'block';
			document.getElementById('rolloverNotForMe').style.display = 'none';
			document.getElementById('notSeenItPopup').style.display = 'none';
			document.getElementById('rolloverLikelyToSee').style.display = 'none';
	}
	
	top.listRollOverSliderObject = new sliderfuncs.SimpleSlider( "top.listRollOverSliderObject" );
	top.listRollOverSliderObject.setContainer( document.getElementById('ratingSlider') );
	top.listRollOverSliderObject.setMaxVal( 10 );
	top.listRollOverSliderObject.setStepSize ( 1.0 );
	top.listRollOverSliderObject.setValue( parseInt( rate ) );
	top.listRollOverSliderObject.setPointerToValue = function()
	{
		var sliderObj = document.getElementById( "simpleSlider::" + this.id );
		var pointerObj = document.getElementById( "simpleSliderPointer::" + this.id );
		var xPosition = 28;
		var yPosition = sliderObj.offsetTop;
		if ( document.all )
		{
			yPosition = sliderObj.parentNode.offsetTop + sliderObj.parentNode.parentNode.offsetTop + 6;
		}
		pointerObj.style.left = (xPosition - 4) + ((this.size / (this.maxVal - this.minVal))*(this.value - this.minVal)) + "px";
		
		if(document.all) 	pointerObj.style.top = (yPosition + 4) + "px";
		else				pointerObj.style.top = (yPosition + 10) + "px";
	}
		top.listRollOverSliderObject.addEventListener( function( event ){
		if( event.type == 'DragEnd' )
		{
			myRatingsFuncs.rate( event.slider.getValue(), stripIndex );
			document.getElementById('sliderTitle').innerHTML = 'Your rating:';
			recommendationFuncs.setRolloverSliderRateText( event.slider.getValue() );
			sliderInitialText = document.getElementById('rateText').innerHTML;
			setNotSeenIt();
		
		}
		if( event.type == 'Drag' )
		{
			recommendationFuncs.colorUserRatedSlider();
			recommendationFuncs.setRolloverSliderRateText( event.slider.getValue() );
		}
		if( event.type == 'layoutDragAbort' )
		{
			if( document.getElementById('rolloverLikelyToSee').style.display != 'none' || document.getElementById('rolloverNotForMe').style.display != 'none')
			{
				document.getElementById('rateText').innerHTML = '';
				
				document.getElementById('sliderTitle').innerHTML = 'Rate this title:';
				recommendationFuncs.setRolloverSliderRateText( -1 );
			}
			else
			{
				document.getElementById('rateText').innerHTML = sliderInitialText;
				
			}
		}
		if( event.type == 'LayoutDrag' )
		{
			document.getElementById('sliderTitle').innerHTML = 'Your rating:';
			document.getElementById('rateText').innerHTML = '';
			recommendationFuncs.setRolloverSliderRateText( event.slider.getValue() );
		}
		
		
		
	} );
	top.listRollOverSliderObject.init();
	
}

recommendationFuncs.nflxImportRatingChanged = function( checkbox )
{
	if( document.location.href.indexOf("-edit") > -1  && userInitialImports.rating == true) return;
	
	var infoArea = document.getElementById('nflxUserInfo');
	
	var expandingTween = null;
	
	if( checkbox.checked )
	{
		expandingTween = new Tween(infoArea.style,'height',Tween.regularEaseInOut,0,115,1,'px');
		
	}
	else
	{
		if( infoArea.style.height == "115px" )
			expandingTween = new Tween(infoArea.style,'height',Tween.regularEaseInOut,115,0,1,'px');
	}
	
	expandingTween.start();
}


recommendationFuncs.nflxCancelIntegration = function()
{
	utils.dimThePage();
	
	var browserHeight = document.all ? document.body.clientHeight : window.innerHeight;
	var scrollTop = document.all ? document.body.scrollTop : window.pageYOffset;
	
	
	
	document.getElementById('feedbackAlert').style.top = ( browserHeight/2 - 100 ) + "px";
	
	document.getElementById('feedbackAlert').style.display = "block";
	document.getElementById('alertQuestionService').style.display = "block";
}

recommendationFuncs.nflxUpdateIntegration = function()
{
	var ratingImportUpdate = document.getElementById('integrationOptionsForm:ratingOption');
	var reviewsImportUpdate = document.getElementById('integrationOptionsForm:reviewsOption');
	var removeRating = false;
	var removeReviews = false;
	
	/* if didn't change anything, do nothing*/
	if( (userInitialImports.rating == ratingImportUpdate.checked) && (userInitialImports.reviews == reviewsImportUpdate.checked) )
		return false;
		
	
	/* check what import settings are changed*/
	if( userInitialImports.rating == true && !ratingImportUpdate.checked )
	{
		removeRating = true;
	}
	if( userInitialImports.reviews == true && !reviewsImportUpdate.checked )
	{
		removeReviews = true;
	}
	if( (userInitialImports.rating == false && ratingImportUpdate.checked == true) || (userInitialImports.reviews == false && reviewsImportUpdate.checked == true) )
	{
		recommendationFuncs.isReimport = true
	}
	
	
	/* alert the user in case he/she chooses to remove an import option */
	if( removeRating || removeReviews )
	{
		recommendationFuncs.isReadyForSubmit = false;
		//document.getElementById('feedbackNotice').style.display = "block";
		utils.dimThePage();
		
		var browserHeight = document.all ? document.body.clientHeight : window.innerHeight;
		var scrollTop = document.all ? document.body.scrollTop : window.pageYOffset;
	
	
	
	document.getElementById('feedbackAlert').style.top = ( browserHeight/2 - 100 ) + "px";
		document.getElementById('feedbackAlert').style.display = "block";
	
		if( removeRating && removeReviews )
		{
			document.getElementById('alertQuestionBoth').style.display = "block";
		}
		else if ( removeRating )
		{
			document.getElementById('alertQuestionRatings').style.display = "block";
		}
		else if( removeReviews )
		{
			document.getElementById('alertQuestionReviews').style.display = "block";
		}
	}
	else if( !userInitialImports.rating && ratingImportUpdate.checked == true)
	{
		var username = document.getElementById('integrationOptionsForm:username').value;
		var pwd = document.getElementById('integrationOptionsForm:password').value;
		
		if(trim( username ) == '' || trim( pwd ) == '')
		{
			recommendationFuncs.isReadyForSubmit = false;
			utils.dimThePage();
			document.getElementById('feedbackAlert').style.display = "block";
			document.getElementById('alertUserInfo').style.display = "block";
		}
		
	}
	else
	{
		recommendationFuncs.isReadyForSubmit = true;
		
	}
	return true;
}

recommendationFuncs.nflxRemoveAlert = function()
{
	//document.getElementById('feedbackNotice').style.display = "none";
	utils.unDimThePage();
	var divs = document.getElementById('feedbackAlert').childNodes;
	
	for(var index=0; index<divs.length; index++) {
		
		if(divs[index].tagName=='DIV') divs[index].style.display = "none";
		
	}
	
	document.getElementById('feedbackAlert').style.display = "none";
	
}

recommendationFuncs.nflxStatusPageOnload = function()
{
	//AjaxController.startNflxIntegration( recommendationFuncs.checkIntegrationStatus );
	
	AjaxController.startNflxIntegration( 
		
		{
			errorHandler:function(errorString, exception) 
	  		{
	  			if( exception.errCode == 4009 )
	  			{
	  				window.clearInterval( recommendationFuncs.nflxInterval );
	  				var nflxIntegrationMovie = document.getElementById("nflxIntegrationPlayer")
	  				nflxIntegrationMovie.pauseVideo(); 
	  				document.getElementById('movieContainer').style.visibility = "hidden";
	  				utils.dimThePage();
	  				
	  				document.getElementById('feedbackAlert').style.display = "block";
	  				document.getElementById('importRatingError').style.display = "block"
	  				
	  				recommendationFuncs.integrateWhenFaultRatingImport = true;
	  				
	  			}
	  			else
	  			{
	  				recommendationFuncs.showGeneralError();
	  			}
	  		}
  		}
	)
	
	recommendationFuncs.nflxInterval = window.setInterval("AjaxController.getNflxIntegrationStatus(recommendationFuncs.checkIntegrationStatus)",5000);
	
}
recommendationFuncs.showGeneralError = function()
{
	try{
		
		window.clearInterval( recommendationFuncs.nflxInterval );
		var nflxIntegrationMovie = document.getElementById("nflxIntegrationPlayer");
		nflxIntegrationMovie.stopVideo();
		document.getElementById('movieContainer').style.display = "none";
		
	}catch(e){}
	
	utils.dimThePage();
	document.getElementById('feedbackAlert').style.display = "block";
  	document.getElementById('generalImportError').style.display = "block"
}
recommendationFuncs.integrationSecondAttempt = function()
{
	document.getElementById('reSubmitForm:firstAttempt').value = "false";
	var username = document.getElementById('reSubmitForm:nflxUsername').value;
	var pwd = document.getElementById('reSubmitForm:nflxPassword').value;
	
	if(trim(pwd) == '' || trim(username) == '' ) return false;
	
}
recommendationFuncs.continueIntegration = function()
{
	/* remove the alert */
	document.getElementById('feedbackAlert').style.display = "none";
	document.getElementById('importRatingError').style.display = "none"
	utils.unDimThePage();
	
	
	/* resume the clip */
	var nflxIntegrationMovie = document.getElementById("nflxIntegrationPlayer")
	nflxIntegrationMovie.playVideo(); 
	document.getElementById('movieContainer').style.visibility = "visible";
	document.getElementById('nflxIntegrationPlayer').playVideo();
	
	
	/* keep ask the server */
	recommendationFuncs.nflxInterval = window.setInterval("AjaxController.getNflxIntegrationStatus(recommendationFuncs.checkIntegrationStatus)",5000);
	
	  				
	return false;
}

recommendationFuncs.checkIntegrationStatus = function( integrationStatus )
{
	
	recommendationFuncs.integrationResultObj = integrationStatus;
	
	if(integrationStatus != null && integrationStatus.status == -1 && !recommendationFuncs.integrateWhenFaultRatingImport)
	{
		window.clearInterval( recommendationFuncs.nflxInterval );
		nflxFucntions.integrationStatus = -1;
		recommendationFuncs.showGeneralError();
	}
	else if(integrationStatus !=null &&  (integrationStatus.status == 2 || recommendationFuncs.integrateWhenFaultRatingImport ) )
	{
		window.clearInterval( recommendationFuncs.nflxInterval );
		nflxFucntions.integrationStatus = 2;
		recommendationFuncs.switchToIntegrationCompleted();
		
	}
//	else
//	{
//		window.clearInterval( recommendationFuncs.nflxInterval );
//		nflxFucntions.integrationStatus = -1;
//		alert('integration unknown error');
//	}
}
//recommendationFuncs.finishIntegrationProcess = function()
//{
//	alert('finish integration process');
//}
recommendationFuncs.switchToIntegrationCompleted = function()
{
	generalFunctions.hideNetflixFromHomePage();
	document.getElementById('importProcessSection').style.display = "none";
	document.getElementById('successfulImportSection').style.display = "block";
	
	return false;
	
}
recommendationFuncs.switchToIntegrationResults = function()
{
	var ratings = 		recommendationFuncs.integrationResultObj.ratingsCounter != null;
	var reviews = 		recommendationFuncs.integrationResultObj.reviewsCounter != null;
	var nflxHistory = 	recommendationFuncs.integrationResultObj.historyCounter != null;
	
	
	document.getElementById('ratingsNum').innerHTML = 		ratings ? recommendationFuncs.integrationResultObj.ratingsCounter.value : '';
	document.getElementById('reviewsNum').innerHTML = 		reviews ? recommendationFuncs.integrationResultObj.reviewsCounter.value : '';
	document.getElementById('titledWatchedNum').innerHTML = nflxHistory ? recommendationFuncs.integrationResultObj.historyCounter.value : '';
	
	if( !ratings ) 		document.getElementById('ratingStats').style.display = "none";
	if( !reviews ) 		document.getElementById('reviewsStats').style.display = "none";
	if( !nflxHistory ) 	document.getElementById('historyStats').style.display = "none";
	
	//if (ratings || reviews || nflxHistory)
	if( askedForRatings || askedForReviews )
	{
		document.getElementById('statsSection').style.display = "block";
	}
	else
	{
		document.getElementById('statsSection').style.display = "none";
	}
	
	try{
		document.getElementById('nflxIntegrationPlayer').style.display = "none";
		document.getElementById('nflxIntegrationPlayer').stopVideo();
	}
	catch(e){}
	document.getElementById('successfulImportSection').style.display = "none";
	document.getElementById('movieContainer').style.display = "none";
	document.getElementById('integrationResults').style.display = "block";
	
}
recommendationFuncs.cancelReviewsAndRatings = function()
{
	if( recommendationFuncs.isReimport ) {
		
		recommendationFuncs.isReadyForSubmit = true;
		document.getElementById('integrationOptionsForm').submit();
		return false;
	}
	
	var reviews = document.getElementById('integrationOptionsForm:reviewsOption').checked;
	var ratings = document.getElementById('integrationOptionsForm:ratingOption').checked;
	
	NetflixAjaxBean.updateIntegration(reviews,ratings,recommendationFuncs.fadeInOut('alertQuestionBoth','alertConfirmationBoth'));
	return false;
}
recommendationFuncs.cancelRatings = function()
{
	if( recommendationFuncs.isReimport ) {
		
		recommendationFuncs.isReadyForSubmit = true;
		document.getElementById('integrationOptionsForm').submit();
		return false;
	}
	
	var reviews = document.getElementById('integrationOptionsForm:reviewsOption').checked;
	var ratings = document.getElementById('integrationOptionsForm:ratingOption').checked;
	
	NetflixAjaxBean.updateIntegration(reviews,ratings,recommendationFuncs.fadeInOut('alertQuestionRatings','alertConfirmationRatings'));
	return false;
}
recommendationFuncs.cancelReviews = function()
{
	if( recommendationFuncs.isReimport ) {
		
		recommendationFuncs.isReadyForSubmit = true;
		document.getElementById('integrationOptionsForm').submit();
		return false;
	}
	
	var reviews = document.getElementById('integrationOptionsForm:reviewsOption').checked;
	var ratings = document.getElementById('integrationOptionsForm:ratingOption').checked;
	
	NetflixAjaxBean.updateIntegration(reviews,ratings,recommendationFuncs.fadeInOut('alertQuestionReviews','alertConfirmationReviews'));
	return false;
}
recommendationFuncs.cancelIntegration = function()
{
	affilateFilters.removeAffiliateFilter( affilateFilters.netflix );
	
	NetflixAjaxBean.cancelIntegration( recommendationFuncs.fadeInOut('alertQuestionService','alertConfirmationService') );
}

recommendationFuncs.fadeInOut = function(fadeOutObjectId, fadeInObjectId )
{	
	var fadeOut = new OpacityTween(document.getElementById(fadeOutObjectId),Tween.regularEaseOut, 100, 0, 1);
		
	fadeOut.onMotionFinished = function(){
		
		document.getElementById(fadeOutObjectId).style.display = "none";
		document.getElementById(fadeInObjectId).style.opacity = 0;
		document.getElementById(fadeInObjectId).style.display = "block";
		var fadeIn = new OpacityTween(document.getElementById(fadeInObjectId),Tween.regularEaseIn, 0, 100, 1);
		fadeIn.start();
	}
	
	fadeOut.start();
	
	return false;
}
recommendationFuncs.isReadyForSubmit = function()
{
	
	return recommendationFuncs.isReadyForSubmit;
	
}
recommendationFuncs.validateNflxIntegrationForm = function()
{
	var username = document.getElementById('integrationOptionsForm:username');
	var pwd = document.getElementById('integrationOptionsForm:password');
	var checkbox = document.getElementById('integrationOptionsForm:ratingOption');
	
	if(checkbox.checked && ( trim(username.value) == '' || trim(pwd.value) == '') )
	{
		//document.getElementById('feedbackNotice').style.display = "block";
		utils.dimThePage();
		
		document.getElementById('userFormfeedbackAlert').style.left = ( getPosX( document.getElementById('integrationOptionsForm') ) + 100)+ "px";
		document.getElementById('userFormfeedbackAlert').style.top = ( getPosY( document.getElementById('integrationOptionsForm') ))+ "px";
		document.getElementById('userFormfeedbackAlert').style.display = "block";
		document.getElementById('alertUserInfo').style.display = "block";
		
		return false;
	}
	
	return true;
}
recommendationFuncs.hideAlert = function(alertToHide, alertContainer)
{
	try{
		document.getElementById(alertToHide).style.display = "none";
		
		utils.unDimThePage();
		if(alertContainer == null || alertContainer == undefined)
			document.getElementById('feedbackAlert').style.display = "none";
		else
			document.getElementById(alertContainer).style.display = "none";
		
	}
	catch(e){}
	
}
recommendationFuncs.openNflxForgotPassword = function()
{
	
	var x= ((screen.width)/2 - 400 ) + "px"; 
	
	var myWindow=window.open('https://www.netflix.com/LoginHelp?lnkctr=ml_help','nflxWindow','left= ' + x +',width=1033,height=468');
	
	myWindow.focus();

	
}
recommendationFuncs.getRecommendations = function()
{

	
	AjaxUserRecommendationsBean.getRecommendationsByAjax(
	
		function(){
			
			document.location.href = document.location.href ;
			
		}
	
	);
	
	
	
}