/* babychannel_class.js
*
*	BabyChannel -- a simple class for making BabyChannel Brightcove3 API requests
*
*	Author: Ronan Rafferty
*	Date: 09/10/2008
* 
* 	Sample Usage: TODO add an example
* 
*/
	function BabyChannel() 
	{			
		//if(window.console != undefined) console.log("BabyChannel class constructor")
			
		// Instance Properties	
		this.currentTags = "";
		this.searchByTags = true;
		this.searchText = "";
		this.myBabyChannel = "";
		this.firstLoad = true;
		
		// Create a new BC3Api request object
		this.bc3Obj = new BC3Api();
		
		// Provides default div references to return content to the page
		this.displayObj = {
			error: "error",
			results: "results",
			menu: "menu",
			title: "title",
			popular: "popular",
			basePath: ""	
		};
		
		// load 'myBabyChannel'
		var myBabyChannelCookie = $.cookie(this.COOKIE_NAME);
		this.myBabyChannel = (myBabyChannelCookie != null)? myBabyChannelCookie : "" ;
				// dataStore for calls
		this.currentJsonData = null;
		this.popularJsonData = null;
		this.myBabyChannelJsonData = null;
	}

/*	Static Properties
 */
	BabyChannel.prototype.COOKIE_NAME = 'mybabychannel_cookie';		

/*	Methods
 */ 	
 	/* loadPage
 	 * 
 	 * Loads a page when the HTML page is first loaded
 	 *
 	 * @param	callback:				A string with the JavaScript function name which will be called on completion
 	 * @param	tags:					A string of tags to search brightcove with
 	 * @param	displayObj (opt):		An object that provides div references to return content to the page
	 */
	BabyChannel.prototype.firstPageLoad = function (callback, tags, displayObj)
	{				
		//if(window.console != undefined) console.log("BabyChannel class constructor")
		
		// Set tags & displayObj
		this.currentTags = tags;
		
		if(displayObj)	this.displayObj = displayObj;
		
		var success = this.bc3Obj.findVideosByLineupId({	id: "topVideos", 
															playlist_id: "1859711546",
															callback: "babyChannel.videosByLineupIdResults",
															fields : "videoIds"
													});	
		this.loadMostPopular();
		this.getMyBabyChannel();
	}
			
 	/* loadPage
 	 * 
 	 * Loads a page when the HTML page is first loaded
 	 *
 	 * @param	callback:				A string with the JavaScript function name which will be called on completion
 	 * @param	tags:					A string of tags to search brightcove with
 	 * @param	displayObj (opt):		An object that provides div references to return content to the page
	 */
	BabyChannel.prototype.tagPageLoad = function (callback, tags, displayObj)
	{					
		//if(window.console != undefined) console.log("BabyChannel.tagPageLoad")
		
		// Set tags & displayObj
		this.currentTags = tags;
		
		if(displayObj)	this.displayObj = displayObj;
		
		var success = this.bc3Obj.findVideosByTags({	id: "topVideos", 
														and_tags: this.currentTags,
														callback: callback,
														page_size: "6",
														page_number: "0",
														sort_by: "MODIFIED_DATE",
														sort_order: "DESC",
														get_item_count : "true",
														fields : "id,name,thumbnailURL,shortDescription"															
													});	
		this.loadMostPopular();
		this.getMyBabyChannel();
	}
	
 	/* loadPage
 	 *
 	 * Calls a page of videos from a specific page number
 	 * 
 	 * @param	pageNumber:				The page number to load
 	 * @param	callback:				A string with the JavaScript function name which will be called on completion
	 */
	BabyChannel.prototype.loadPage = function (pageNumber, callback)
	{									
		//if(window.console != undefined) console.log("BabyChannel.loadPage")
			
		var success = this.bc3Obj.findVideosByTags({	id: "topVideos", 
														and_tags: this.currentTags, 
														callback: callback,
														page_size: "6",
														page_number: (pageNumber-1),
														sort_by: "MODIFIED_DATE",
														sort_order: "DESC",
														get_item_count : "true",
														fields : "id,name,thumbnailURL,shortDescription"
													});	
		this.loadMostPopular();
	}
 	/* sliderLoad
 	 *
 	 * Calls a page of videos from a specific page number
 	 * 
 	 * @param	tag:				The additional slider tag
	 */
	BabyChannel.prototype.sliderLoad = function (tag)
	{									
		//if(window.console != undefined) console.log("BabyChannel.sliderLoad")
		
		var success = this.bc3Obj.findVideosByTags({	id: "topVideos", 
														and_tags: (this.currentTags + "," + tag),
														callback: "babyChannel.videosByTagResults",
														page_size: "6",
														page_number: "0",
														sort_by: "MODIFIED_DATE",
														sort_order: "DESC",
														get_item_count : "true",
														fields : "id,name,thumbnailURL,shortDescription"															
													});	
	}
	
 	/* loadMostPopular
 	 *
 	 * Calls for the most popular videos from a certain section
	 */
	BabyChannel.prototype.loadMostPopular = function ()
	{									
		//if(window.console != undefined) console.log("BabyChannel.loadMostPopular")
					
		var success = this.bc3Obj.findVideosByTags({	id: "topVideos", 
														and_tags: this.currentTags, 
														callback: "babyChannel.videosByTagPopularResults",
														page_size: "10",
														page_number: 0,
														get_item_count : "true",
														sort_by: "PLAYS_TRAILING_WEEK",
														sort_order: "DESC",
														fields : "id,name,thumbnailURL,shortDescription"
													});	
	}
	
	/* videoSearch
	 * 
	 * Calls a text search of the brightcove videos.
	 * 
	 * @param	searchText:		The text to search by. 'baby channel' is added to this term.
 	 * @param	callback:		A string with the JavaScript function name which will be called on completion
	 */
	BabyChannel.prototype.videoSearch = function (searchText, callback)
	{									
		//if(window.console != undefined) console.log("BabyChannel.videoSearch")
		
		this.searchByTags = false;
		
		var success = this.bc3Obj.findVideosByText({	id: "topVideos", 
														text: searchText, 
														callback: callback,
														page_size: "100",
														page_number: 0,
														get_item_count : "true",
														fields : "id,name,thumbnailURL,shortDescription,tags"
													});	
	}
	
	/* videoSearchPage
	 * 
	 * Mocks a call back funtion. Pulls a section from the loaded search text and passes it to the correct function.
	 * 
	 * @param	pageNumber:		The number of the page to search.
	 */
	BabyChannel.prototype.videoSearchPage = function (pageNumber)
	{									
		//if(window.console != undefined) console.log("BabyChannel.videoSearchPage")
		
		this.currentJsonData.page_number = pageNumber-1;
		
		this.videosByTagResults(this.currentJsonData);
	}
		 
	 /* getMyBabyChannel
 	 *
 	 * Returns the videos contained in MyBabyChannel
	 */
	 BabyChannel.prototype.getMyBabyChannel = function ()
	 {									
		//if(window.console != undefined) console.log("BabyChannel.getMyBabyChannel")
		
	 	var videoList = this.myBabyChannel.split("\n").join(",");
	 	
	 	if(videoList != null && videoList != undefined && videoList != ""){
			var success = this.bc3Obj.findVideosByIds({	id: "topVideos", 
															video_ids: videoList,
															callback: "babyChannel.videosForMyBabyResults",
															fields : "id,name,thumbnailURL,shortDescription"
														});	
	 	} else {
			// clear the current results
			document.getElementById("myBabyChannelTitleData").innerHTML = "My Baby Channel (0)";
			document.getElementById("myBabyChannelData").innerHTML = "<img src=\""+this.displayObj.basePath+"/images/mybabychannel_empty.jpg\" alt=\"Add to your\" />";
	 	}
	 }
	
	/* callResult
 	 *
 	 * Calls a page of videos from a specific page number
 	 * 
 	 * @param	success:	True or False
 	 * @param	args:		An object containing the relevant messages {success: "message", error: "message"}
	 */
	BabyChannel.prototype.callResult = function (success, args)
	{									
		//if(window.console != undefined) console.log("BabyChannel.callResult")
		
		if(success){
			//document.getElementById(this.displayObj.error).innerHTML = args.success;
		} else {
			//output error
			//document.getElementById(this.displayObj.error).innerHTML = args.error;
		}
	}
	
	/* buildPageTitle
 	 *
 	 * Builds a title with the clips being viewed and total clips
 	 * 
	 */
	BabyChannel.prototype.buildPageTitle = function ()
	{									
		//if(window.console != undefined) console.log("BabyChannel.buildPageTitle")
		
		var jd = this.currentJsonData;
		var currentPage = (jd.page_number * jd.page_size) + 1;
		var toPage = currentPage-1  + jd.page_size;
		var titleHtml = currentPage + " - " + ((toPage <= jd.total_count)? toPage : jd.total_count) + " of " + jd.total_count + " clips";
		
		document.getElementById("thumbnailBlockTitle").innerHTML = titleHtml;
	}
	
	/* buildPagingMenu
 	 *
 	 * Builds a HTML paging menu to 'page' through the results
 	 * 
	 */
	BabyChannel.prototype.buildPagingMenu = function ()
	{									
		//if(window.console != undefined) console.log("BabyChannel.buildPagingMenu")
		
		var jd = this.currentJsonData;
		var pgTotal = Math.ceil(jd.total_count/jd.page_size);
		var currentPage = jd.page_number + 1;
		var startPage = (pgTotal > jd.page_size && currentPage >= jd.page_size)? currentPage-5 : 1;
		var endPage = (pgTotal > jd.page_size && currentPage >= jd.page_size)? currentPage : ((pgTotal > jd.page_size)? jd.page_size : pgTotal);
		var menuHtml = "";
		var spaceHtml = "&nbsp;&nbsp;&nbsp;";
		var searchFunction = (this.searchByTags)? "babyChannel.loadPage" : "babyChannel.videoSearchPage";
		
		if(currentPage != 1) menuHtml += "<a href=\"#\" onclick=\""+searchFunction+"('"+(currentPage-1)+"', 'babyChannel.videosByTagResults'); return false\"><<</a>"+spaceHtml;
				
		for(var i=startPage; i<=endPage; i++)
		{
			if(i != currentPage){
				menuHtml += "<a href=\"#\" onclick=\""+searchFunction+"('"+i+"', 'babyChannel.videosByTagResults'); return false\">"+i+"</a>"+spaceHtml;
			} else {
				menuHtml += "<a href=\"#\" onclick=\""+searchFunction+"('"+i+"', 'babyChannel.videosByTagResults'); return false\">["+i+"]</a>"+spaceHtml;
			}
		}
		
		if(currentPage < pgTotal) menuHtml += "<a href=\"#\" onclick=\""+searchFunction+"('"+(currentPage+1)+"', 'babyChannel.videosByTagResults'); return false\">>></a>"+spaceHtml;
		
		document.getElementById("thumbnailBlockMenu").innerHTML = menuHtml;
	}
	
	/* getVideoDetail
 	 *
 	 * Returns the information on a video.
 	 * 
 	 * @param	id		The id of the video to get the information from
	 */
	 BabyChannel.prototype.getVideoDetail = function (id)
	 {									
		//if(window.console != undefined) console.log("BabyChannel.getVideoDetail")
		
	 	if(this.currentJsonData != null && this.currentJsonData["items"].length > 0){
		 	for (var i=0; i<this.currentJsonData["items"].length; i++) {
		 		if(this.currentJsonData["items"][i].id == id) return this.currentJsonData["items"][i];
			}
	 	} else {
	 		return null;
	 	}
	 }
	
	/* getPopularVideoDetail
 	 *
 	 * Returns the information on a video from the popular list.
 	 * 
 	 * @param	id		The id of the video to get the information from
	 */
	 BabyChannel.prototype.getPopularVideoDetail = function (id)
	 {									
		//if(window.console != undefined) console.log("BabyChannel.getPopularVideoDetail")
		
	 	if(this.popularJsonData != null && this.popularJsonData["items"].length > 0){
		 	for (var i=0; i<this.popularJsonData["items"].length; i++) {
		 		if(this.popularJsonData["items"][i].id == id) return this.popularJsonData["items"][i];
			}
	 	} else {
	 		return null;
	 	}
	 }
	
	/* getMyBabyChannelVideoDetail
 	 *
 	 * Returns the information on a video from the popular list.
 	 * 
 	 * @param	id		The id of the video to get the information from
	 */
	 BabyChannel.prototype.getMyBabyChannelVideoDetail = function (id)
	 {									
		//if(window.console != undefined) console.log("BabyChannel.getMyBabyChannelVideoDetail")
		
	 	if(this.myBabyChannelJsonData != null && this.myBabyChannelJsonData["items"].length > 0){
		 	for (var i=0; i<this.popularJsonData["items"].length; i++) {
		 		if(this.myBabyChannelJsonData["items"][i].id == id) return this.myBabyChannelJsonData["items"][i];
			}
	 	} else {
	 		return null;
	 	}
	 }
	 
	 
	 /* addToMyBabyChannel;
	  * 
	  * @param bcId		The brightcove ID of the video to add to the 'myBabyChannel';
	  */
	 BabyChannel.prototype.addToMyBabyChannel = function (bcId)
	 {									
		//if(window.console != undefined) console.log("BabyChannel.addToMyBabyChannel")
		
	 	if(bcId != undefined && this.myBabyChannel.search(bcId) == -1){
 			this.myBabyChannel += bcId + "\n";
 			$.cookie(this.COOKIE_NAME, this.myBabyChannel, { path: '/'});
	 		this.getMyBabyChannel();
	 	} 
	 }
	 
	 /* removeFromMyBabyChannel;
	  * 
	  * @param bcId		The brightcove ID of the video to remove from the 'myBabyChannel';
	  */
	 BabyChannel.prototype.removeFromMyBabyChannel = function (bcId)
	 {									
		//if(window.console != undefined) console.log("BabyChannel.removeFromMyBabyChannel")
		
	 	bcId = bcId + "\n";
	 	
	 	if(bcId != undefined && this.myBabyChannel.search(bcId) != -1){
 			this.myBabyChannel =this.myBabyChannel.replace(bcId, "");
 			$.cookie(this.COOKIE_NAME, this.myBabyChannel, { path: '/'});
	 		this.getMyBabyChannel();
	 	}
	 }
	 
	 /* noSearchResults;
	  * 
	  */
	 BabyChannel.prototype.noSearchResults = function ()
	 {									
		//if(window.console != undefined) console.log("BabyChannel.noSearchResults")
		
	 		// title menu
	 		document.getElementById("thumbnailBlockTitle").innerHTML = "Sorry no videos returned";
	 		
	 		// menu
	 		document.getElementById("thumbnailBlockMenu").innerHTML = "";
	 	
	 		// results table
			document.getElementById("thumbnailBlockImg1").innerHTML = "";
			document.getElementById("thumbnailBlockTxt1").innerHTML = "";
			document.getElementById("thumbnailBlockPlay1").innerHTML = "";
			document.getElementById("thumbnailBlockAdd1").innerHTML = "";
	 }

	 
/*	Call Back Methods
 */ 	
	/* videosByLineupIdResults
 	 *
 	 * A callback function that recieves brightcove jsonData data and calls the videos for display
 	 * 
 	 * @param jsonData	The returned data set from brightcove
 	 * 
	 */
	BabyChannel.prototype.videosByLineupIdResults = function (jsonData)
	{											
		//if(window.console != undefined) console.log("BabyChannel.videosByLineupIdResults")
				
		if(jsonData.videoIds != undefined){
		
			var success = this.bc3Obj.findVideosByIds({	id: "topVideos", 
															video_ids: jsonData.videoIds,
															callback: "babyChannel.videosByTagResults",
															fields : "id,name,thumbnailURL,shortDescription",
															get_item_count : "true"
														});	
		}
	}
 	
	/* videosByTagResults
 	 *
 	 * A callback function that recieves brightcove jsonData data and rewites it to the relevant HTML tags by id
 	 * 
 	 * @param jsonData	The returned data set from brightcove
 	 * 
	 */
	BabyChannel.prototype.videosByTagResults = function (jsonData)
	{										
		//if(window.console != undefined) console.log("BabyChannel.videosByTagResults")
					
		// clear the 'table'
		for(var i=1; i<=6; i++)
		{
			document.getElementById("thumbnailBlockImg"+i).innerHTML = "&nbsp;";
			document.getElementById("thumbnailBlockTxt"+i).innerHTML = "&nbsp;";
			document.getElementById("thumbnailBlockPlay"+i).innerHTML = "&nbsp;";
			document.getElementById("thumbnailBlockAdd"+i).innerHTML = "&nbsp;";
		}
		
		// test the results
		if(jsonData["items"].length > 0 || !this.searchByTags){
			// store
			this.currentJsonData = jsonData;
			
			var jd = this.currentJsonData;
		
			// display the results			
			for (var i=0; i<6; i++) {	
				
				var trg = (this.searchByTags)? i : i + (jd.page_number * jd.page_size);
						
				if(jd["items"][trg] == undefined) break;
				
				var title = jd["items"][trg];
				
				var linkStart = "<a href=\"#\" onclick=\"loadContentById(" + title.id + ")\" title='"+title.shortDescription+"' class=\"thumbnailTooltip\">";
				var linkEnd = "</a>";
				
				document.getElementById("thumbnailBlockImg"+(i+1)).innerHTML = linkStart + "<img src=\""+ title.thumbnailURL+"\ alt=\"Thumbnail "+i+"\" class=\"thumbnails\" />" + linkEnd;
				document.getElementById("thumbnailBlockTxt"+(i+1)).innerHTML = title.name;
				document.getElementById("thumbnailBlockPlay"+(i+1)).innerHTML = linkStart + "<img src=\""+this.displayObj.basePath+"/images/playButton.jpg\" alt=\"Play\" />" + linkEnd;
				document.getElementById("thumbnailBlockAdd"+(i+1)).innerHTML = "<a href=\"#\" onclick=\"babyChannel.addToMyBabyChannel(" + title.id + "); return false\"><img src=\""+this.displayObj.basePath+"/images/addButton.jpg\" alt=\"Add\"/></a>";				
			}
						
			// build the title and menu
			this.buildPageTitle();
			this.buildPagingMenu();
			
			createPlayer();			
		} else {
			// no search results
			this.noSearchResults();
		}
		
		// play if first
		if(this.firstLoad && appReady){
			this.firstLoad = false;
			loadContentById(jsonData["items"][0].id);
		}
	}	
 	
	/* videosByTextResults
 	 *
 	 * A callback function that recieves brightcove jsonData data and rewites it to the relevant HTML tags by id.
 	 * This function also filters out results by tags *due to brightcoves lack of functionality
 	 * 
 	 * @param jsonData	The returned data set from brightcove
 	 * 
	 */
	BabyChannel.prototype.videosByTextResults = function (jsonData)
	{											
		//if(window.console != undefined) console.log("BabyChannel.videosByTextResults")
				
		// clear the 'table'
		for(var i=1; i<=6; i++)
		{
			document.getElementById("thumbnailBlockImg"+i).innerHTML = "&nbsp;";
			document.getElementById("thumbnailBlockTxt"+i).innerHTML = "&nbsp;";
			document.getElementById("thumbnailBlockPlay"+i).innerHTML = "&nbsp;";
			document.getElementById("thumbnailBlockAdd"+i).innerHTML = "&nbsp;";
		}
		
		// test the results
		if(jsonData["items"].length > 0){
						
			/* Filter the results
			 * 
			 * Due to Brightcove inadequacey we cannot filter search results by tags. Therefore we have
			 * to filter and hack the search functions.
			 */
			var filteredItems = new Array();
			
			for (var i=0; i<jsonData["items"].length; i++) 
			{				
				var tagMatch = false;
				var itemRef;
				
				// search current tags against item tags	
				for (var n=0; n<jsonData["items"][i].tags.length; n++) 	
				{
					itemRef = jsonData["items"][i];
					if(itemRef.tags[n] == "babychannel" || itemRef.tags[n] == "baby channel"){
						tagMatch = true;
						break;
					}
				}
				
				// if the any tag matches store
				if(tagMatch == true) filteredItems.push(itemRef); 
			}
			
			// Reproduce the JSON data for our mocked search
			this.currentJsonData = jsonData;	
			this.currentJsonData.items = filteredItems;		
			this.currentJsonData.total_count = this.currentJsonData["items"].length;
			this.currentJsonData.page_number = 0;
			this.currentJsonData.page_size = 6;
		
			// display the results			
			for (var i=0; i<this.currentJsonData["items"].length; i++) 
			{
				var title = this.currentJsonData["items"][i];				
				var linkStart = "<a href=\"#\" onclick=\"loadContentById(" + title.id + ")\" title='"+title.shortDescription+"' class=\"thumbnailTooltip\">";
				var linkEnd = "</a>";
				
				document.getElementById("thumbnailBlockImg"+(i+1)).innerHTML = linkStart + "<img src=\""+ title.thumbnailURL+"\ alt=\"Thumbnail "+i+"\" class=\"thumbnails\" />" + linkEnd;
				document.getElementById("thumbnailBlockTxt"+(i+1)).innerHTML = title.name;
				document.getElementById("thumbnailBlockPlay"+(i+1)).innerHTML = linkStart + "<img src=\""+this.displayObj.basePath+"/images/playButton.jpg\" alt=\"Play\" />" + linkEnd;
				document.getElementById("thumbnailBlockAdd"+(i+1)).innerHTML = "<a href=\"#\" onclick=\"babyChannel.addToMyBabyChannel(" + title.id + "); return false\"><img src=\""+this.displayObj.basePath+"/images/addButton.jpg\" alt=\"Add\"/></a>";				
			
				if(i==5) break;
			}
						
			// build the title and menu
			this.buildPageTitle();
			this.buildPagingMenu();
			//tooltip();
			applyJQuery();
			
		} else {
			// no search results
			this.noSearchResults();
		}
	}	
	
	/* videosByTagPopularResults
 	 *
 	 * A callback function that recieves brightcove jsonData data and rewites it to the relevant HTML tags by id
 	 * 
 	 * @param jsonData	The returned data set from brightcove
 	 * 
	 */
	BabyChannel.prototype.videosByTagPopularResults = function (jsonData)
	{											
		//if(window.console != undefined) console.log("BabyChannel.videosByTagPopularResults")
		
		// test the results
		if(jsonData["items"].length > 0){
		
			// store
			this.popularJsonData = jsonData;
		
			// display the results
			var resp = document.getElementById(this.displayObj.popular);
			var respHtml = "";
			
			for (var i=0; i<jsonData["items"].length; i++) {
				var title = jsonData["items"][i];
				var str = "";
				
				str += "<span>" + title.name + ",</span>";
				str += "<p>" + title.shortDescription + "</p>";
				str += "<p class=\"mpsBlock\">";
				str += "<a href=\"#\" onclick=\"babyChannel.addToMyBabyChannel(" + title.id + "); return false\"><img src=\""+this.displayObj.basePath+"/images/addBlueButton.jpg\" alt=\"Stop\" class=\"imgSmall\"></a>";
				str += "<a href=\"#\" onclick=\"loadPopularContentById(" + title.id + ")\"><img src=\""+this.displayObj.basePath+"/images/playBlueButton.jpg\" alt=\"Play\" class=\"imgSmall\"></a>";
				str += "</p>";				

				respHtml += str;
			}
			
			resp.innerHTML = respHtml;
						
		} else {
			// display error
			//this.callResult(false, {error: "No results returned"});
		}
	}
		
	/* videosForMyBabyResults
 	 *
 	 * A callback function that recieves brightcove jsonData data and rewites it to the relevant HTML tags by id
 	 * 
 	 * @param jsonData	The returned data set from brightcove
 	 * 
	 */
	BabyChannel.prototype.videosForMyBabyResults = function (jsonData)
	{										
		//if(window.console != undefined) console.log("BabyChannel.videosForMyBabyResults")
				
		// display the results
		var resp = document.getElementById("myBabyChannelData");
		var respHtml = "";
				
		// test the results
		if(jsonData["items"] != undefined && jsonData["items"].length > 0){
			
			this.myBabyChannelJsonData = jsonData;
			
			for (var i=0; i<jsonData["items"].length; i++) {
				var title = jsonData["items"][i];
				var str = "";
				
				var linkStart = "<a href=\"#\" onclick=\"loadMyBabyChannelContentById(" + title.id + ")\">";
				var linkEnd = "</a>";
				
				str += "<p><img src=\"" + title.thumbnailURL + "\" class=\"imgBig\">";
				str += "<span>" + title.name + "<hr />";
				str += linkStart + "<img src=\"" + this.displayObj.basePath + "/images/play.jpg\" alt=\"Play\" class=\"imgSmall \">" + linkEnd;
				str += "<a href=\"#\" onclick=\"babyChannel.removeFromMyBabyChannel(" + title.id + "); return false\" title=\""+title.shortDescription+"\"><img src=\"" + this.displayObj.basePath + "/images/stop.jpg\" alt=\"Stop\" class=\"imgSmall \"  style=\"margin-right:75px;\"></a>";
				str += "<strong>&nbsp;</strong>";
				str += "</span>";
				str += "</p>";			

				respHtml += str;
			}
			
			document.getElementById("myBabyChannelTitleData").innerHTML = "My Baby Channel (" + jsonData["items"].length  + ")";
			
			resp.innerHTML = respHtml;
			
			applyJQuery();			
		} 
	}
