//global variables to hold from and to number to get videos from cached list




//alert(userName);
var pageNo=1;
var perPage=20;


$(document).ready(function() 
		{		
			//first check if cookie exists
			if ($.cookie('showRelated')!=null)
			{
				//cookie exists
				///now see value is yes or no
				if ($.cookie('showRelated')=="yes")
				{
					showrel();					
				} 
				else if ($.cookie('showRelated')=="no")
				{					
					hiderel();
				}
			}
			else
			{
				//no cookie at all, so we need to show
				showrel();
			}
			
		});
function showrel()
		{	
			getRelatedVideos(userName,pageNo,perPage);
			$("div.related").show("slow");
			
			//set cookie which expires in 120 days
			$.cookie('showRelated', 'yes', { expires: 120 }); 
			$("a.showClassRel").empty();
			$("a.hideClassRel").empty().append("Hide");	
				
		}
		
function hiderel()
		{
			$("div.related").hide("slow");	
			$("a.showClassRel").empty().append("Show me Videos Uploaded by same user");	
			$("a.hideClassRel").empty();	
			//$("a.hideClass").html.empty();
			//set cookie value to no and store it for next 120 days
			$.cookie('showRelated', 'no', { expires: 120 }); 		
		}	
function getRelatedVideos(userNamet,pageNot,perPaget)
{
	//$("div#currentlyWatching").hide("slow");
	$("div.related").empty().append("Loading..");
	
	$.ajax({
		url:"../ajax/relatedVideos.aspx",
		data:{videoUserId:userNamet,
		pageNo:pageNot,
		perPage:perPaget},
		success:function(data){
		if(data=="")
			$("div.related").empty().append("<b>No videos found</b>");
		else		
			$("div.related").empty().append(data);
	}
	});
}


