$(document).ready(function() 
		{		
			//first check if cookie exists
			if ($.cookie('showRelatedByVideoId')!=null)
			{
				//cookie exists
				///now see value is yes or no
				if ($.cookie('showRelatedByVideoId')=='yes')
				{
					showrelByVideoId();					
				} 
				else if ($.cookie('showRelatedByVideoId')=='no')
				{					
					hiderelByVideoId();
				}
			}
			else
			{
				//no cookie at all, so we need to show
				showrelByVideoId();
			}
			
		});
function showrelByVideoId()
		{	
		
			getRelatedVideosByVideoId(videoId);
			$('div.relatedByVideoId').slideDown('slow'); 
			if ($.cookie('showRelatedByVideoId')!=null)
			{
				if ($.cookie('showRelatedByVideoId')=='no')
				{					
					$.cookie('showRelatedByVideoId', 'yes', { expires: 120 }); 
				}
			}
			else
			{
				$.cookie('showRelatedByVideoId', 'yes', { expires: 120 }); 
			}
			
			$("div#relPlace").empty();	
			$("div#relPlace").append("<a href=\"javascript:hiderelByVideoId();\" class=\"hideClassRelByVideoId\">Hide</a>");	
		}
		
function hiderelByVideoId()
		{
			$('div#relPlace').empty().append("<a href=\"javascript:showrelByVideoId();\"  class=\"showClassRel\" >Show related videos</a>");	
			$('div.relatedByVideoId').slideUp("slow"); 
			
			if ($.cookie('showRelatedByVideoId')!=null)
			{
				if ($.cookie('showRelatedByVideoId')=='yes')
				{					
					$.cookie('showRelatedByVideoId', 'no', { expires: 120 }); 
				}
			}
		}		

function getRelatedVideosByVideoId(videoIdt)
{
	
	$('div.relatedByVideoId').empty().append("Loading Related videos..");
	
	$.ajax({
		url:"../ajax/relatedVideosFromVideoId.aspx",
		data:{videoId:videoIdt},
		success:function(data){
		if(data=="")
			$('div.relatedByVideoId').empty().append("<b>No related videos found</b>");
		else		
			$('div.relatedByVideoId').empty().append(data);
	}
	});
}




