function YouTube(id)
{
	
	// -------------------------------------------------------------------------------------------------------
	// Constants
	// -------------------------------------------------------------------------------------------------------
	
	// AJAX paths and parameters
	var YOTUBE_GET_EMBED_CODE_PATH = BASE + '/ajax/getembedcode';
	
	//-----------------------------------------------------------------------------------------------------------
	// Member variables
	//-----------------------------------------------------------------------------------------------------------

	// Public
	this.id = id;
	this.feed = null;
	this.currentPage = 1;
	this.maxPages = 8;
	this.numItemsPerPage = 5;
	this.containerId = 'videos';
	this.thumbWidth = 130;
	this.thumbHeight = 97;
	this.overlayImage = '';
	
	// Private
	var mNumPages = 1;
	
	//-----------------------------------------------------------------------------------------------------------
	// Public functions
	//-----------------------------------------------------------------------------------------------------------

	this.showFeed = showFeed;
	this.showPage = showPage;
	this.playVideo = playVideo;

	
	//-----------------------------------------------------------------------------------------------------------
	// Functions
	//-----------------------------------------------------------------------------------------------------------
	
	function showFeed(data)
	{
		var videocount = $('#video_box').find('a').length;

		// TODO need to remove limit of dispaly videos
		// Feed
		var newarr = new Array(data.entry);
		var feed = newarr;			
		var entries = data.entry || [];
		this.feed = feed;
		mNumPages = Math.ceil(this.feed.length / this.numItemsPerPage);
		
		this.showPage(1,data,videocount);
	}
	
	function showPage(page,data,vcount)
	{
		if (page > mNumPages)
		{
			return;
		}
		
		this.currentPage = page;
		var html = '';

		var firstItem = 0;
		var i;
		//firstItem + this.feed.length
		for (i = firstItem; i < vcount ; i++)
		{
				
			if (i >= this.feed.length)
			{
				break;
			}
			
			var entry = this.feed[i];
			var title = entry.title.$t;
			var vidoeDescription = entry.media$group.media$description.$t;
			var playerUrl = this.feed[i].media$group.media$player.url;
			var thumbImg = data.entry.media$group.media$thumbnail[i].url;

			var urlVars = getUrlVars(playerUrl);
			
			html += '<div class="video">'
				+ '<div class="description">'
				+ '<a href="javascript:void(0)" rel="'+ urlVars['v'] +'" class="title youtubeVLink headerText">' + data.entry.title.$t + '</a>\n'
						+ '<div class="descriptionText">'
						+ '<div style="float:left; width: 70px"><img src="' + thumbImg + '" width="70" height="70" alt="Default Thumbnail" align="right"/></div>'
								+'<div style="float:left; width: 215px; padding-left: 5px">'+ vidoeDescription + '</div>\n'
						+ '</div>\n'
				+ '</div>\n'
				+ '</div>\n'
				+ '<hr />\n';
				
				
				$('#tangier_videos').append(html);	
				
		}
		
		$('.videoTitle').html('<div class="title">' + data.entry.title.$t + '</div>');
		$('.contentHolder').html('<div class="videoDescription">' + vidoeDescription + '</div>');
	}
	
	function getUrlVars(url)
	{
	    var vars = [], hash;
	    var hashes = url.slice(url.indexOf('?') + 1).split('&');
	    for(var i = 0; i < hashes.length; i++)
	    {
	        hash = hashes[i].split('=');
	        vars.push(hash[0]);
	        vars[hash[0]] = hash[1];
	    }
	    return vars;
	}
	
	function playVideo(v)
	{
		
		$.ajax({
			url: YOTUBE_GET_EMBED_CODE_PATH + "/" + v ,
			success: function(msg)
			{
				$("#nowPlayingVideo").html(msg);
				
			}
		});
		
	}    
}

