function addAssetsFromWeb(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed, assetRating,assetLevel,programmeId,assetGenre){
assetFromWeb.push(new simpleAsset(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed, assetRating,assetLevel,programmeId,assetGenre));}
function addAssetsFromEmail(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed, assetRating,assetLevel,programmeId,assetGenre){
assetFromEmail.push( new simpleAsset(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed, assetRating,assetLevel,programmeId,assetGenre));}
function addSearchAsset(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,programmeId,assetGenre){
searchAssetArray.push(new simpleAsset(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel, programmeId,assetGenre));}
function addLatestProgrammeBySeasonAsset(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel, programmeId,assetGenre){
latestProgrammeBySeasonAssetArray.push(new simpleAsset(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating, assetLevel,programmeId,assetGenre));}
function addMoreEpisodeAsset(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,programmeId, assetGenre){
moreEpisodeAssetArray.push( new simpleAsset(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,programmeId,assetGenre));}
function addLatestPromosByChannelAsset(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags, assetViewed,assetRating,assetLevel,assetAstroChannelName,programmeId,assetGenre){
latestPromosByChannelAssetArray.push(new simpleAsset_set2(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,assetAstroChannelName,programmeId,assetGenre));}
function addTopViewedAsset(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,assetAstroChannelName, programmeId,assetGenre){
topViewedAssetArray.push(new simpleAsset_set2(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel, assetAstroChannelName,programmeId,assetGenre));}
function addLatestProgrammeByChannelAsset(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,assetAstroChannelName,programmeId,assetGenre){
latestProgrammeByChannelAssetArray.push(new simpleAsset_set2(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,assetAstroChannelName,programmeId,assetGenre));}
function addLatestProgrammeByGenreAsset(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,assetAstroChannelName,programmeId,assetGenre){
latestProgrammeByGenreAssetArray.push(new simpleAsset_set2(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,assetAstroChannelName,programmeId,assetGenre));}
function addAsset(groupId,assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,assetAstroChannelName, programmeId,assetGenre){
	if(groupId == "138"){
	assetArray_138.push(new simpleAsset_set3(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,assetAstroChannelName,programmeId,assetGenre));}
	else if(groupId == "140"){
	assetArray_140.push(new simpleAsset_set3(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,assetAstroChannelName,programmeId,assetGenre));}
	else if(groupId == "142"){
	assetArray_142.push(new simpleAsset_set3(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,assetAstroChannelName,programmeId,assetGenre));}}
function addAllChannels(section,channelId,channelName,channelNumber,channelLogo){
	if(section=="previews"){
		allChannelsArray.push(new Channels(channelId,channelName,channelNumber,channelLogo));}
	else{
		allChannelsArray2.push(new Channels(channelId,channelName,channelNumber,channelLogo));}}
function addPreRoll(preRollId,preRollType,preRollName,preRollUrl,preRollSponsor,preRollSecUrl,preRollTargetUrl){
	preRollArray.push( new PreRoll(preRollId,preRollType,preRollName,preRollUrl,preRollSponsor,preRollSecUrl,preRollTargetUrl));}
function addProgrammes(programmeId,programmeName,programmeImage,programmeSeason,programmeGenreId){
	allProgrammesArray.push(new Programmes(programmeId,programmeName,programmeImage,programmeSeason,programmeGenreId));}
function addAllGenres(genreId,genreName){
	allGenresArray.push( new Channels( genreId, genreName ));}
function simpleAsset(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,programmeId,assetGenre){
	this.assetId = assetId;
	this.assetImage = assetImage;	
	this.assetVideo = assetVideo;		
	this.assetTitle = assetTitle;
	this.assetLengthMinutes = assetLengthMinutes;
	this.assetSynopsis =  assetSynopsis;
	this.assetTags = assetTags;
	this.assetViewed = assetViewed;
	this.assetRating = assetRating;
	this.assetLevel = assetLevel;
	this.programmeId = programmeId;
	this.assetGenre = assetGenre;}
function simpleAsset_set2(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,assetAstroChannelName, programmeId,assetGenre){
	this.assetId = assetId;
	this.assetImage = assetImage;	
	this.assetVideo = assetVideo;		
	this.assetTitle = assetTitle;
	this.assetLengthMinutes = assetLengthMinutes;
	this.assetSynopsis =  assetSynopsis;
	this.assetTags = assetTags;
	this.assetViewed = assetViewed;
	this.assetRating = assetRating;
	this.assetLevel = assetLevel;
	this.assetAstroChannelName = assetAstroChannelName;	
	this.programmeId = programmeId;
	this.assetGenre = assetGenre;}
function simpleAsset_set3(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes,assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,assetAstroChannelName, programmeId,assetGenre){
	this.assetId = assetId;
	this.assetImage = assetImage;	
	this.assetVideo = assetVideo;		
	this.assetTitle = assetTitle;
	this.assetLengthMinutes = assetLengthMinutes;
	this.assetSynopsis =  assetSynopsis;
	this.assetTags = assetTags;
	this.assetViewed = assetViewed;
	this.assetRating = assetRating;
	this.assetLevel = assetLevel;
	this.assetAstroChannelName = assetAstroChannelName;	
	this.programmeId = programmeId;
	this.assetGenre = assetGenre;}
function Channels(channelId,channelName,channelNumber,channelLogo){
	this.channelId = channelId;
	this.channelName = channelName;
	this.channelNumber = channelNumber;
	this.channelLogo = channelLogo;}
function Programmes(programmeId,programmeName,programmeImage,programmeSeason,programmeGenreId){
	this.programmeId = programmeId;
	this.programmeName = programmeName;
	this.programmeImage = programmeImage;
	this.programmeSeason = programmeSeason;
	this.programmeGenreId = programmeGenreId;}
function Genres(genreId,genreName){
	this.genreId = genreId;
	this.genreName = genreName;}
function PreRoll(preRollId,preRollType,preRollName,preRollUrl,preRollSponsor,preRollSecUrl,preRollTargetUrl){
	this.preRollId = preRollId;
	this.preRollType = preRollType;
	this.preRollName = preRollName;
	this.preRollUrl = preRollUrl;
	this.preRollSponsor = preRollSponsor;
	this.preRollSecUrl = preRollSecUrl;
	this.preRollTargetUrl = preRollTargetUrl;}
function displayAssets(trailDIV,displayDIV,selectedArray,limitPerPage,offset){
	var onmouseover_tip;
	globalSelectedArray = selectedArray;	
	if(selectedArray == "moreEpisodeAssetArray"){
		onmouseover_tip = ",LEFT,false";}
	else{
		onmouseover_tip = ",LEFT,true";}	
	selectedArray = eval(selectedArray);
	if((offset != "0") && (offset >= selectedArray.length)){
		return;}
	var htmlOutput = "";
	var maxLimit = "";
	if (limitPerPage == "all"){
		maxLimit =  selectedArray.length;} 
	else{
		maxLimit = parseInt(limitPerPage) + parseInt(offset);}
	for ( var i = offset ; i < maxLimit ; i++ ){		
		if ( i == selectedArray.length ){			
			break;
		}		
		if (( globalSelectedArray == "allChannelsArray" ) || ( globalSelectedArray == "allChannelsArray2" ))
		{			
			htmlOutput+= "\
<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"" + skinFolder + "/images/list_video_bg.gif\">\
  <tr>\
	<td width=\"3\" height=\"6\"></td>\
	<td width=\"80\"></td>\
	<td width=\"11\"></td>\
	<td width=\"74\"></td>\
	<td width=\"18\"></td>\
	<td width=\"9\"></td>\
	<td width=\"36\"></td>\
	<td width=\"23\"></td>\
	<td width=\"32\"></td>\
	<td width=\"12\"></td>\
  </tr>\
  <tr>\
	<td height=\"15\"></td>\
	<td rowspan=\"6\" valign=\"top\"><img onClick=\"showSecondaryTab('user','"+selectedArray[i].channelId+"','"+selectedArray[i].channelName+"');setChannelName('"+selectedArray[i].channelName+"');//getPromosByChannel('"+selectedArray[i].channelId+"')\" style=\"cursor:pointer;\" src="+serverURL+selectedArray[i].channelLogo+" width=\"80\" height=\"60\"></td>\
	<td></td>\
	<td colspan=\"5\" valign=\"top\"><span class=\"style1\">"+selectedArray[i].channelName+"</a></span><br></td>\
	<td></td>\
	<td></td>\
  </tr>\
  <tr>\
	<td height=\"21\"></td>\
	<td></td>\
	<td colspan=\"3\" valign=\"top\"><span class=\"style2\">Channel "+selectedArray[i].channelNumber+"</span></td>\
	<td>&nbsp;</td>\
	<td colspan=\"2\" valign=\"top\"></td>\
	<td></td>\
  </tr>\
  \
  <tr>\
	<td height=\"4\"></td>\
	<td></td>\
	<td rowspan=\"3\" valign=\"top\"></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
  </tr>\
  <tr>\
	<td height=\"13\"></td>\
	<td></td>\
	<td></td>\
	<td colspan=\"4\" valign=\"top\" align=\"right\"></td>\
  <td></td>\
  </tr>\
  <tr>\
	<td height=\"2\"></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
  </tr>\
  <tr>\
	<td height=\"5\"></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
  </tr>\
  <tr>\
	<td height=\"5\"></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
  </tr> \
</table>\
					";			
		} 
		else 
		{		
			if((selectedArray[i].assetTitle != "") && (selectedArray[i].assetTitle != "undefined"))
			{
				var strX = selectedArray[i].assetTitle;
				strX = strX.replace(/'/, "");
			}
			
			var dispLock = "";
			if ((selectedArray[i].assetLevel == "3" ) || (selectedArray[i].assetLevel == "4")) 
			{ 
				dispLock = "<img src=\"" + skinFolder + "/images/lock.gif\" onMouseover=\"Tip('You have to be an Astro subscriber to view this video',CENTERMOUSE, true, OFFSETX, 0,WIDTH,200)\">";
			}
			
			if ( selectedArray[i].assetId == "331200" ) 
			{
				htmlOutput+= "\
	<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"" + skinFolder + "/images/list_video_bg.gif\">\
	  <tr>\
		<td width=\"3\" height=\"6\"></td>\
		<td width=\"80\"></td>\
		<td width=\"11\"></td>\
		<td width=\"74\"></td>\
		<td width=\"18\"></td>\
		<td width=\"9\"></td>\
		<td width=\"36\"></td>\
		<td width=\"23\"></td>\
		<td width=\"32\"></td>\
		<td width=\"12\"></td>\
	  </tr>\
	  <tr>\
		<td height=\"15\"></td>\
		<td rowspan=\"6\" valign=\"top\"><img style=\"cursor:pointer;\" onClick=\"playNow('user','"+selectedArray[i].assetId+"','"+globalSelectedArray+"');\" src="+selectedArray[i].assetImage+" width=\"80\" height=\"60\"></td>\
		<td></td>\
		<td colspan=\"6\" valign=\"top\"><span class=\"style1\"><a style=\"cursor:pointer;\" onMouseover=\"Tip('"+strX+"',LEFT,true)\" onClick=\"playNow('user','"+selectedArray[i].assetId+"','"+globalSelectedArray+"');\">"+(strX).substr(0,30)+"</a></span><br></td>\
		<td></td>\
		<td></td>\
	  </tr>\
	  <tr>\
		<td height=\"21\"></td>\
		<td></td>\
		<td colspan=\"3\" valign=\"top\"><span class=\"style2\">"+(selectedArray[i].assetGenre).substr(0,17)+"&nbsp;"+dispLock+"</span></td>\
		<td>&nbsp;</td>\
		<td colspan=\"2\" valign=\"top\">&nbsp;</td>\
		<td></td>\
	  </tr>\
	  \
	  <tr>\
		<td height=\"4\"></td>\
		<td></td>\
		<td rowspan=\"3\" valign=\"top\"><a style=\"cursor:pointer;\" onClick=\"playNow('user','"+selectedArray[i].assetId+"','"+globalSelectedArray+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_playvideo.gif\" alt=\"play video\" width=\"23\" height=\"20\" /></a><img src=\"" + skinFolder + "/images/buttons/btn_addvideo.gif\" alt=\"add to playlist not available\" width=\"24\" height=\"20\" /><img src=\"" + skinFolder + "/images/buttons/btn_sendtofriend.gif\" alt=\"send to friend not available\" width=\"27\" height=\"20\" /></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
	  </tr>\
	  <tr>\
		<td height=\"13\"></td>\
		<td></td>\
		<td></td>\
		<td colspan=\"4\" valign=\"top\" align=\"right\"><span class=\"style2\" >"+selectedArray[i].assetLengthMinutes+" min(s)&nbsp; </span></td>\
	  <td></td>\
	  </tr>\
	  <tr>\
		<td height=\"2\"></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
	  </tr>\
	  <tr>\
		<td height=\"5\"></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
	  </tr>\
	  <tr>\
		<td height=\"5\"></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
	  </tr> \
	</table>\
						";			
			}
			else
			{		
				htmlOutput+= "\
	<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"" + skinFolder + "/images/list_video_bg.gif\">\
	  <tr>\
		<td width=\"3\" height=\"6\"></td>\
		<td width=\"80\"></td>\
		<td width=\"11\"></td>\
		<td width=\"74\"></td>\
		<td width=\"18\"></td>\
		<td width=\"9\"></td>\
		<td width=\"36\"></td>\
		<td width=\"23\"></td>\
		<td width=\"32\"></td>\
		<td width=\"12\"></td>\
	  </tr>\
	  <tr>\
		<td height=\"15\"></td>\
		<td rowspan=\"6\" valign=\"top\"><img style=\"cursor:pointer;\" onClick=\"playNow('user','"+selectedArray[i].assetId+"','"+globalSelectedArray+"');\" src="+selectedArray[i].assetImage+" width=\"80\" height=\"60\"></td>\
		<td></td>\
		<td colspan=\"6\" valign=\"top\"><span class=\"style1\"><a style=\"cursor:pointer;\" onMouseover=\"Tip('"+strX+"'"+onmouseover_tip+")\" onClick=\"playNow('user','"+selectedArray[i].assetId+"','"+globalSelectedArray+"');\">"+(strX).substr(0,30)+"</a></span><br></td>\
		<td></td>\
		<td></td>\
	  </tr>\
	  <tr>\
		<td height=\"21\"></td>\
		<td></td>\
		<td colspan=\"3\" valign=\"top\"><span class=\"style2\">"+(selectedArray[i].assetGenre).substr(0,17)+"&nbsp;"+dispLock+"</span></td>\
		<td>&nbsp;</td>\
		<td colspan=\"2\" valign=\"top\">"+displayStarRating(selectedArray[i].assetRating)+"</td>\
		<td></td>\
	  </tr>\
	  \
	  <tr>\
		<td height=\"4\"></td>\
		<td></td>\
		<td rowspan=\"3\" valign=\"top\"><a style=\"cursor:pointer;\" onClick=\"playNow('user','"+selectedArray[i].assetId+"','"+globalSelectedArray+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_playvideo.gif\" alt=\"play video\" width=\"23\" height=\"20\" /></a><a style=\"cursor:pointer;\" onClick=\"addToPlaylist('"+selectedArray[i].assetId+"','"+globalSelectedArray+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_addvideo.gif\" alt=\"add to playlist\" width=\"24\" height=\"20\" /></a><a style=\"cursor:pointer;\" onClick=\"shareNow('"+selectedArray[i].assetId+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_sendtofriend.gif\" alt=\"send to friend\" width=\"27\" height=\"20\" /></a></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
	  </tr>\
	  <tr>\
		<td height=\"13\"></td>\
		<td></td>\
		<td></td>\
		<td colspan=\"4\" valign=\"top\" align=\"right\"><span class=\"style2\" >views : "+selectedArray[i].assetViewed+"&nbsp; </span></td>\
	  <td></td>\
	  </tr>\
	  <tr>\
		<td height=\"2\"></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
	  </tr>\
	  <tr>\
		<td height=\"5\"></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
	  </tr>\
	  <tr>\
		<td height=\"5\"></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
		<td></td>\
	  </tr> \
	</table>\
						";
			}
		}
	}	
	WriteLayer(displayDIV,null,htmlOutput);
	displayResultTrail(trailDIV,displayDIV,globalSelectedArray,limitPerPage,offset);			
}
function displayResultTrail(trailDIV,displayDIV,selectedArray,limitPerPage,currentPage){	
	globalSelectedArray = selectedArray;
	selectedArray = eval(selectedArray);
	var htmlOutput = "";	
	if( limitPerPage == "all" ){
		maxLimit =  selectedArray.length;
		limitPerPage = maxLimit;
	}
	var pageNumber = selectedArray.length/limitPerPage;	
	var globalOffset = currentPage;	
	var offset = 0;
	var isCurrent = "";
	var maxPageNumber = parseInt(pageNumber) + 1;		
	var startPageNumber = 1;	
	var totalVideo = selectedArray.length;		
	if ((currentPage >= 56 ) && (currentPage < 92)){		
		startPageNumber = 15; 
		offset = 56; 
		htmlOutput += "...";
	}
	if ((currentPage >= 92) && (currentPage < 128 )){		
		startPageNumber = 24; 
		offset = 92; 
		htmlOutput += "...";
	}
	if ((currentPage >= 128) && (currentPage < 164)){		
		startPageNumber = 33; 
		offset = 128;
		htmlOutput += "...";
	}
	if ((currentPage >= 164) && (currentPage < 200)){		
		startPageNumber = 42; 
		offset = 164; 
		htmlOutput += "...";
	}	
	if ((currentPage >= 200) && (currentPage < 236)){		
		startPageNumber = 51; 
		offset = 200; 
		htmlOutput += "...";
	}
	if ((currentPage >= 236) && (currentPage < 272)){		
		startPageNumber = 60; 
		offset = 236; 
		htmlOutput += "...";
	}
	if ((currentPage >= 272) && (currentPage < 308)){		
		startPageNumber = 69; 
		offset = 272; 
		htmlOutput += "...";
	}	
	if ((currentPage >= 308) && (currentPage < 344)){			
		startPageNumber = 78; 
		offset = 308; 
		htmlOutput += "...";
	}
	if ((currentPage >= 344 ) && (currentPage < 380)){
		startPageNumber = 87; 
		offset = 344; 
		htmlOutput += "...";
	}
	if ((currentPage >= 380) && (currentPage < 412)){		
		startPageNumber = 96; 
		offset = 380; 
		htmlOutput += "...";
	}
	if ((currentPage >= 412) && (currentPage < 436)){		
		startPageNumber = 104; 
		offset = 412; 
		htmlOutput += "...";
	}
	if ((currentPage >= 436) && (currentPage < 460 )){		
		startPageNumber = 110; 
		offset = 436; 
		htmlOutput += "...";
	}
	if ((currentPage >= 460) && (currentPage < 484 )){		
		startPageNumber = 116; 
		offset = 460; 
		htmlOutput += "...";
	}
	if ((currentPage >= 484) && (currentPage < 508)){		
		startPageNumber = 122; 
		offset = 484; 
		htmlOutput += "...";
	}
	if ((currentPage >= 508) && (currentPage < 532 )){		
		startPageNumber = 128; 
		offset = 508; 
		htmlOutput += "...";
	}
	if ((currentPage >= 532) && (currentPage < 556 )){		
		startPageNumber = 134; 
		offset = 532; 
		htmlOutput += "...";
	}
	if((selectedArray.length % limitPerPage) > 0 ){
		maxPageNumber = parseInt(maxPageNumber) + 1;
	}	
	for( var i = startPageNumber; i < maxPageNumber; i++ ){
		//writing the previous next algorithm
		if ((offset == currentPage) || ((isCurrent == "") && (globalOffset == '0'))){
			//bold the current selected page
			isCurrent = "<span class=\"style19\"><font size=3>"+i+"</font></span>";				
			// setting the previous button values
			// check if offset is at the beginning of the page
			if ( globalOffset != "0" ){
				// setting previous btn value
				var tmpOffset = parseInt(offset) - parseInt(limitPerPage) ;				
				// if the value is negative, then reset the offset to 0
				if ( tmpOffset < 0 ){
					tmpOffset = 0;
				}
			} 
			else{
				var tmpOffset = parseInt(offset);				
			}
			//writing previous and next button
			var previousNextBtn = "<a style=\"cursor:pointer;\"  onClick=\"displayAssets('"+trailDIV+"','"+displayDIV+"','"+globalSelectedArray+"','"+limitPerPage+"','"+tmpOffset+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_left.gif\" alt=\"previous page\"  /></a>";
			// setting the next button values			
			tmpOffset = parseInt(globalOffset)+parseInt(limitPerPage);			
			//globalOffset = parseInt(globalOffset);
			selArrLen = selectedArray.length+"";			
			//write the next button values
			previousNextBtn += "<a style=\"cursor:pointer;\"  onClick=\"displayAssets('"+trailDIV+"','"+displayDIV+"','"+globalSelectedArray+"','"+limitPerPage+"','"+tmpOffset+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_right.gif\" alt=\"next page\" /></a>";				
			//reset previousNext btn if result returns 1 pager only
			if (  pageNumber < 1 ){
				previousNextBtn = "";
			}
		} 
		else{
			isCurrent = parseInt(i);
		}		
		//start page trail	(for end dot dot)	
		if ( (i == 14) || (i == 23) || (i == 32) || (i == 41) || (i == 50) || (i == 59) || (i == 68) || (i == 77) || (i == 86) || (i == 95) || (i == 103) || (i == 109) || (i == 115) || (i == 121) || (i == 127) || (i == 133) || (i == 139) || (i == 145)){			
//			if(((totalVideo <= 56) && (totalVideo > 52 ))||((totalVideo <= 92) && (totalVideo > 88 ))||((totalVideo <= 128) && (totalVideo > 124 ))||((totalVideo <= 164) && (totalVideo > 162 )))
//			{
//				htmlOutput += "<a style=\"cursor:pointer;\" onClick=\"displayAssets('"+trailDIV+"','"+displayDIV+"','"+globalSelectedArray+"','"+limitPerPage+"','"+offset+"');\">"+isCurrent+"</a> ";				
//				break;	
//			}
//			else
//			{				
				htmlOutput += "<a style=\"cursor:pointer;\" onClick=\"displayAssets('"+trailDIV+"','"+displayDIV+"','"+globalSelectedArray+"','"+limitPerPage+"','"+offset+"');\">"+isCurrent+"</a> ...";
				break;	
//			}					
		}//end page trail
		htmlOutput += "<a style=\"cursor:pointer;\" onClick=\"displayAssets('"+trailDIV+"','"+displayDIV+"','"+globalSelectedArray+"','"+limitPerPage+"','"+offset+"');\">"+isCurrent+"</a> ";		
		//increase the offset 
		offset += parseInt(limitPerPage);
	}//end for
	//append page to htmlOutput	
	htmlOutput = "Page: "+htmlOutput;	
	//write page trail layer
	WriteLayer(trailDIV,null,htmlOutput);	
	//writing the next btn
	if((trailDIV == "WO_allTrail") || (trailDIV == "PL_allTrail") || (trailDIV == "PR_allTrail")|| (trailDIV == "MV_allTrail")||(trailDIV=="PLB_allTrail")||(trailDIV=="PRB_allTrail")){
		WriteLayer(trailDIV+'_previousNext',null,previousNextBtn);	
	}
	else if(trailDIV == "allTrailMoreEpisodes"){
		WriteLayer('previousNextMoreEpisodes',null,previousNextBtn);		
	} 
	else{
		WriteLayer('previousNext',null,previousNextBtn);	
	}
}
function displayAssetsByType(trailDIV,displayDIV,selectedArray,limitPerPage,offset){
	globalSelectedArray = selectedArray;	
	selectedArray = eval(selectedArray);	
	if((offset != "0") && (offset >= selectedArray.length)){
		return;}	
	var htmlOutput = "";
	var maxLimit = "";	
	if(limitPerPage == "all"){
		maxLimit =  selectedArray.length;} 
	else{
		maxLimit = parseInt(limitPerPage) + parseInt(offset);}
	if(globalSelectedArray == "searchAssetArray"){
		document.getElementById("searchTerm").innerHTML = "Your search for \""+tmpsearchString+"\" returns "+searchAssetArray.length+" results";}	
	for(var i = offset ; i < maxLimit ; i++){
		if(i == selectedArray.length){
			break;}
		var dispLock = "";
		if((selectedArray[i].assetLevel == "3") || (selectedArray[i].assetLevel == "4")){ 
			dispLock = "<img src=\"" + skinFolder + "/images/lock.gif\" onMouseover=\"Tip('You have to be an Astro subscriber to view this video')\">";}
		htmlOutputA = "\
		<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#464646\">\
		  <tr>";  
		if(globalSelectedArray != "allProgrammesArray"){ 
			htmlOutputB = "\
		<td height=\"71\" valign=\"top\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"" + skinFolder + "/images/list_video_bg.gif\">\
		  <tr>\
			<td width=\"7\" height=\"6\"></td>\
			<td width=\"80\"></td>\
			<td width=\"10\"></td>\
			<td width=\"74\"></td>\
			<td width=\"14\"></td>\
			<td width=\"10\"></td>\
			<td width=\"41\"></td>\
			<td width=\"10\"></td>\
			<td width=\"45\"></td>\
			<td width=\"6\"></td>\
		  </tr>\
		  <tr>\
			<td height=\"15\"></td>\
			<td rowspan=\"6\" valign=\"top\"><img style=\"cursor:pointer;\" onClick=\"pageScroll('-500');playNow('user','"+selectedArray[i].assetId+"','"+globalSelectedArray+"');\" src="+selectedArray[i].assetImage+" width=\"80\" height=\"60\" /></td>\
			<td></td>\
			<td colspan=\"5\" valign=\"top\"><a class=\"style1\" style=\"cursor:pointer;\" onMouseover=\"Tip('"+selectedArray[i].assetTitle+"');\" onClick=\"pageScroll('-500');playNow('user','"+selectedArray[i].assetId+"','"+globalSelectedArray+"');\">"+(selectedArray[i].assetTitle).substr(0,20)+"</a><br /></td>\
			<td></td>\
			<td></td>\
		  </tr>\
		  <tr>\
			<td height=\"21\"></td>\
			<td></td>\
			<td colspan=\"3\" valign=\"top\"><span class=\"style2\">"+(selectedArray[i].assetGenre).substr(0,17)+"&nbsp;"+dispLock+"</span></td>\
			<td>&nbsp;</td>\
			<td colspan=\"2\" valign=\"top\">"+displayStarRating(selectedArray[i].assetRating)+"</td>\
			<td>&nbsp;</td>\
		  </tr>\
		  <tr>\
			<td height=\"4\"></td>\
			<td></td>\
			<td rowspan=\"3\" valign=\"top\"><a style=\"cursor:pointer;\" onClick=\"pageScroll('-500');playNow('user','"+selectedArray[i].assetId+"','"+globalSelectedArray+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_playvideo.gif\" alt=\"play video\" width=\"23\" height=\"20\" /></a><a style=\"cursor:pointer;\" onClick=\"addToPlaylist('"+selectedArray[i].assetId+"','"+globalSelectedArray+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_addvideo.gif\" alt=\"add to playlist\" width=\"24\" height=\"20\" /></a><a style=\"cursor:pointer;\" onClick=\"shareNow('"+selectedArray[i].assetId+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_sendtofriend.gif\" alt=\"send to friend\" width=\"27\" height=\"20\" /></a></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
		  </tr>\
		  <tr>\
			<td height=\"13\"></td>\
			<td></td>\
			<td></td>\
			<td colspan=\"5\" valign=\"top\" align=\"right\"><span class=\"style2\">views: "+selectedArray[i].assetViewed+" &nbsp;</span></td>\
		  </tr>\
		  <tr>\
			<td height=\"2\"></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
		  </tr>\
		  <tr>\
			<td height=\"5\"></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
		  </tr>\
		  <tr>\
			<td height=\"5\"></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
		  </tr>\
		</table>\
		</td>";
		} else 
		{
  			htmlOutputB = "\
		<td height=\"71\" width=\"297\" valign=\"top\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"" + skinFolder + "/images/list_video_bg.gif\">\
		  <tr>\
			<td width=\"7\" height=\"6\"></td>\
			<td width=\"80\"></td>\
			<td width=\"10\"></td>\
			<td width=\"74\"></td>\
			<td width=\"14\"></td>\
			<td width=\"10\"></td>\
			<td width=\"41\"></td>\
			<td width=\"10\"></td>\
			<td width=\"45\"></td>\
			<td width=\"6\"></td>\
		  </tr>\
		  <tr>\
			<td height=\"44\"></td>\
			<td rowspan=\"6\" valign=\"top\"><img style=\"cursor:pointer;\" onClick=\"loadGenreByProgramme('user','"+selectedArray[i].programmeId+"', '"+selectedArray[i].programmeSeason+"','"+selectedArray[i].programmeGenreId+"');\" src="+serverURL+selectedArray[i].programmeImage+" width=\"80\" height=\"60\" /></td>\
			<td></td>\
			<td height=\"65\" colspan=\"6\" valign=\"top\"><a class=\"style1\" style=\"cursor:pointer;\" onClick=\"loadGenreByProgramme('user','"+selectedArray[i].programmeId+"', '"+selectedArray[i].programmeSeason+"','"+selectedArray[i].programmeGenreId+"');\">"+selectedArray[i].programmeName+"</a></span><br/><span class=\"style2\">Season "+selectedArray[i].programmeSeason+"</span></td>\
			<td></td>\
		  </tr>\
		</table>\
		</td>";
		}		
		htmlOutputC = "<td height=\"71\" valign=\"top\" bgcolor=\"#333333\">&nbsp;</td>";		
		htmlOutputD = "</tr></table>";
		htmlOutputF = "<td height=\"71\" width=\"297\" valign=\"top\" bgcolor=\"#333333\">&nbsp;</td>";
		if(((i % 2) == 0) || (i==0)){
			htmlOutput += htmlOutputA + htmlOutputB ;
			if(i == (selectedArray.length -1)){
				htmlOutput += htmlOutputC + htmlOutputF;}
			type = "even";} 
		else{
			htmlOutput += htmlOutputC + htmlOutputB + htmlOutputD ;
			type = "odd";}}	
	WriteLayer(displayDIV,null,htmlOutput);	
	displayResultTrailByType(trailDIV,displayDIV,globalSelectedArray,limitPerPage,offset);}
function displayResultTrailByType(trailDIV,displayDIV,selectedArray,limitPerPage,currentPage){
	globalSelectedArray = selectedArray;
	selectedArray = eval(selectedArray);
	var htmlOutput = "";	
	if(limitPerPage == "all"){
		maxLimit =  selectedArray.length;
		limitPerPage = maxLimit;}
	var pageNumber = selectedArray.length/limitPerPage;	
	var globalOffset = currentPage;
	var offset = 0;
	var isCurrent = "";
	var maxPageNumber = parseInt(pageNumber) + 1;
	var startPageNumber = 1;	
	if((currentPage >= 200 )&& (currentPage < 400)){
		startPageNumber = 21;
		offset = 200;
		htmlOutput += "...";}
	if((currentPage >= 400) && (currentPage < 600)){	
		startPageNumber = 41;
		offset = 400;
		htmlOutput += "...";}
	if((currentPage >= 600) && (currentPage < 800)){	
		startPageNumber = 61;
		offset = 600;
		htmlOutput += "...";}	
	if((currentPage >= 800) && (currentPage < 1000)){	
		startPageNumber = 81;
		offset = 800;
		htmlOutput += "...";}	
	if((currentPage >= 1000) && (currentPage < 1200 )){		
		startPageNumber = 101;
		offset = 1000;
		htmlOutput += "...";}		
//	if((currentPage >= 600 ) && ( currentPage < 700)){		
//		startPageNumber = 121;
//		offset = 600;
//		htmlOutput += "...";}	
//	if(( currentPage >= 700 ) && ( currentPage < 800)){				
//		startPageNumber = 141;
//		offset = 700;
//		htmlOutput += "...";}
//	if((currentPage >= 800 ) && ( currentPage < 900)){
//		startPageNumber = 161;
//		offset = 800;
//		htmlOutput += "...";}	
	if((selectedArray.length % limitPerPage) > 0 ){
		maxPageNumber = parseInt(maxPageNumber) + 1;}	
	for(var i = startPageNumber; i < maxPageNumber; i++){
		if((offset == currentPage) || ((isCurrent == "")&&(globalOffset == '0'))){
			isCurrent = "<span class=\"style19\"><font size=3>"+i+"</font></span>";	
			if ( globalOffset != "0" ){
				var tmpOffset = parseInt(offset) - parseInt(limitPerPage) ;				
				if(tmpOffset < 0 ){
					tmpOffset = 0;}} 
			else{
				var tmpOffset = parseInt(offset);}
			var previousNextBtn = "<a style=\"cursor:pointer;\" onClick=\"displayAssetsByType('"+trailDIV+"','"+displayDIV+"','"+globalSelectedArray+"','"+limitPerPage+"','"+tmpOffset+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_left.gif\" alt=\"previous page\"  /></a>";	
			tmpOffset = parseInt(globalOffset)+parseInt(limitPerPage);
			selArrLen = selectedArray.length+"";
			previousNextBtn += "<a style=\"cursor:pointer;\" onClick=\"displayAssetsByType('"+trailDIV+"','"+displayDIV+"','"+globalSelectedArray+"','"+limitPerPage+"','"+tmpOffset+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_right.gif\" alt=\"next page\"/></a>";	

			if(pageNumber < 1){
				previousNextBtn = "";}} 
		else{isCurrent = parseInt(i);} 
		if ( (i == 20) || (i == 40) || (i == 60) || (i == 80) || (i == 100) || (i == 120) || (i == 140)|| (i == 160)|| (i == 180)){
			htmlOutput += "<a style=\"cursor:pointer;\" onClick=\"displayAssetsByType('"+trailDIV+"','"+displayDIV+"','"+globalSelectedArray+"','"+limitPerPage+"','"+offset+"');\">"+isCurrent+"</a> ...";			
			break;} 
		htmlOutput += "<a style=\"cursor:pointer;\" onClick=\"displayAssetsByType('"+trailDIV+"','"+displayDIV+"','"+globalSelectedArray+"','"+limitPerPage+"','"+offset+"');\">"+isCurrent+"</a> ";
		offset += parseInt(limitPerPage);}
	htmlOutput = "Page: "+htmlOutput;
	WriteLayer(trailDIV,null,htmlOutput);	
	if(trailDIV == "allTrailAllProgramme"){
		WriteLayer('previousNextAllProgramme',null,previousNextBtn);}
	else if(trailDIV == "allTrailSearch"){
		WriteLayer('previousNextSearch',null,previousNextBtn);} 
	else{
		WriteLayer('previousNextByType',null,previousNextBtn);}}

function  displaySearch(trailDIV,displayDIV,selectedArray,limitPerPage,offset){
	globalSelectedArray = selectedArray;
	selectedArray = eval(selectedArray);
	if((offset != "0") && (offset >= selectedArray.length)){
		return;}	
	var htmlOutput = "";
	var maxLimit = "";	
	if(limitPerPage == "all"){
		maxLimit =  selectedArray.length;} 
	else{
		maxLimit = parseInt(limitPerPage) + parseInt(offset);}
	if(globalSelectedArray == "searchAssetArray"){
		document.getElementById("searchTerm").innerHTML = "Your search for \""+tmpsearchString+"\" returns "+searchAssetArray.length+" results";}	
	for(var i = offset ; i < maxLimit ; i++){
		if(i == selectedArray.length){			
			break;}		
		var dispLock = "";
		if((selectedArray[i].assetLevel == "3") || (selectedArray[i].assetLevel == "4")){ 
			dispLock = "<img src=\"" + skinFolder + "/images/lock.gif\" onMouseover=\"Tip('You have to be an Astro subscriber to view this video')\">";}
		htmlOutputA = "\
		<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#464646\">\
		  <tr>";  
		if(globalSelectedArray != "allProgrammesArray"){ 
			htmlOutputB = "\
		<td height=\"71\" valign=\"top\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"" + skinFolder + "/images/list_video_bg.gif\">\
		  <tr>\
			<td width=\"7\" height=\"6\"></td>\
			<td width=\"80\"></td>\
			<td width=\"10\"></td>\
			<td width=\"74\"></td>\
			<td width=\"14\"></td>\
			<td width=\"10\"></td>\
			<td width=\"41\"></td>\
			<td width=\"10\"></td>\
			<td width=\"45\"></td>\
			<td width=\"6\"></td>\
		  </tr>\
		  <tr>\
			<td height=\"15\"></td>\
			<td rowspan=\"6\" valign=\"top\"><img style=\"cursor:pointer;\" onClick=\"pageScroll('-500');playNow('user','"+selectedArray[i].assetId+"','"+globalSelectedArray+"');\" src="+selectedArray[i].assetImage+" width=\"80\" height=\"60\" /></td>\
			<td></td>\
			<td colspan=\"5\" valign=\"top\"><a class=\"style1\" style=\"cursor:pointer;\" onMouseover=\"Tip('"+selectedArray[i].assetTitle+"');\" onClick=\"pageScroll('-500');playNow('user','"+selectedArray[i].assetId+"','"+globalSelectedArray+"');\">"+(selectedArray[i].assetTitle).substr(0,20)+"</a><br /></td>\
			<td></td>\
			<td></td>\
		  </tr>\
		  <tr>\
			<td height=\"21\"></td>\
			<td></td>\
			<td colspan=\"3\" valign=\"top\"><span class=\"style2\">"+(selectedArray[i].assetGenre).substr(0,17)+"&nbsp;"+dispLock+"</span></td>\
			<td>&nbsp;</td>\
			<td colspan=\"2\" valign=\"top\">"+displayStarRating(selectedArray[i].assetRating)+"</td>\
			<td>&nbsp;</td>\
		  </tr>\
		  <tr>\
			<td height=\"4\"></td>\
			<td></td>\
			<td rowspan=\"3\" valign=\"top\"><a style=\"cursor:pointer;\" onClick=\"pageScroll('-500');playNow('user','"+selectedArray[i].assetId+"','"+globalSelectedArray+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_playvideo.gif\" alt=\"play video\" width=\"23\" height=\"20\" /></a><a style=\"cursor:pointer;\" onClick=\"addToPlaylist('"+selectedArray[i].assetId+"','"+globalSelectedArray+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_addvideo.gif\" alt=\"add to playlist\" width=\"24\" height=\"20\" /></a><a style=\"cursor:pointer;\" onClick=\"shareNow('"+selectedArray[i].assetId+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_sendtofriend.gif\" alt=\"send to friend\" width=\"27\" height=\"20\" /></a></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
		  </tr>\
		  <tr>\
			<td height=\"13\"></td>\
			<td></td>\
			<td></td>\
			<td colspan=\"5\" valign=\"top\" align=\"right\"><span class=\"style2\">views: "+selectedArray[i].assetViewed+" &nbsp;</span></td>\
		  </tr>\
		  <tr>\
			<td height=\"2\"></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
		  </tr>\
		  <tr>\
			<td height=\"5\"></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
		  </tr>\
		  <tr>\
			<td height=\"5\"></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
			<td></td>\
		  </tr>\
		</table>\
		</td>";
		} else 
		{
  			htmlOutputB = "\
		<td height=\"71\" width=\"297\" valign=\"top\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"" + skinFolder + "/images/list_video_bg.gif\">\
		  <tr>\
			<td width=\"7\" height=\"6\"></td>\
			<td width=\"80\"></td>\
			<td width=\"10\"></td>\
			<td width=\"74\"></td>\
			<td width=\"14\"></td>\
			<td width=\"10\"></td>\
			<td width=\"41\"></td>\
			<td width=\"10\"></td>\
			<td width=\"45\"></td>\
			<td width=\"6\"></td>\
		  </tr>\
		  <tr>\
			<td height=\"44\"></td>\
			<td rowspan=\"6\" valign=\"top\"><img style=\"cursor:pointer;\" onClick=\"loadGenreByProgramme('user','"+selectedArray[i].programmeId+"', '"+selectedArray[i].programmeSeason+"','"+selectedArray[i].programmeGenreId+"');\" src="+serverURL+selectedArray[i].programmeImage+" width=\"80\" height=\"60\" /></td>\
			<td></td>\
			<td height=\"65\" colspan=\"6\" valign=\"top\"><a class=\"style1\" style=\"cursor:pointer;\" onClick=\"loadGenreByProgramme('user','"+selectedArray[i].programmeId+"', '"+selectedArray[i].programmeSeason+"','"+selectedArray[i].programmeGenreId+"');\">"+selectedArray[i].programmeName+"</a></span><br/><span class=\"style2\">Season "+selectedArray[i].programmeSeason+"</span></td>\
			<td></td>\
		  </tr>\
		</table>\
		</td>";}
		htmlOutputC = "<td height=\"71\" valign=\"top\" bgcolor=\"#333333\">&nbsp;</td>";		
		htmlOutputD = "</tr></table>";		
		htmlOutputF = "<td height=\"71\" width=\"297\" valign=\"top\" bgcolor=\"#333333\">&nbsp;</td>";
		if(((i % 2) == 0) || (i==0)){
			htmlOutput += htmlOutputA + htmlOutputB ;
			if(i == (selectedArray.length -1)){
				htmlOutput += htmlOutputC + htmlOutputF;}
			type = "even";} 
		else{
			htmlOutput += htmlOutputC + htmlOutputB + htmlOutputD ;
			type = "odd";}}
	WriteLayer(displayDIV,null,htmlOutput);
	displayResultTrailByType_x(trailDIV,displayDIV,globalSelectedArray,limitPerPage,offset);}
function displayResultTrailByType_x(trailDIV,displayDIV,selectedArray,limitPerPage,currentPage){
	globalSelectedArray = selectedArray;	
	selectedArray = eval(selectedArray);	
	var htmlOutput = "";	
	if(limitPerPage == "all"){
		maxLimit =  selectedArray.length;
		limitPerPage = maxLimit;}	
	var pageNumber = selectedArray.length/limitPerPage;	
	var globalOffset = currentPage;
	var offset = 0;
	var isCurrent = "";
	var maxPageNumber = parseInt(pageNumber) + 1;
	var startPageNumber = 1;	
	if((currentPage >= 160) && (currentPage < 320)){
		startPageNumber = 21;
		offset = 160;
		htmlOutput += "...";}
	if((currentPage >= 320 ) && ( currentPage < 480)){
		startPageNumber = 41;
		offset = 320;
		htmlOutput += "...";}
	if((currentPage >= 480 ) && ( currentPage < 640 )){
		startPageNumber = 61;
		offset = 480;
		htmlOutput += "...";}	
	if((currentPage >= 640 )&& (currentPage < 800)){		
		startPageNumber = 81;
		offset = 640;
		htmlOutput += "...";}
	if((selectedArray.length % limitPerPage) > 0){
		maxPageNumber = parseInt(maxPageNumber) + 1;}
	for(var i = startPageNumber; i < maxPageNumber; i++){
		if((offset == currentPage) || ((isCurrent == "")&&(globalOffset == '0'))){
			isCurrent = "<span class=\"style19\"><font size=3>"+i+"</font></span>";	
			if(globalOffset != "0"){
				var tmpOffset = parseInt(offset) - parseInt(limitPerPage) ;				
				if(tmpOffset < 0){
					tmpOffset = 0;}} 
			else{
				var tmpOffset = parseInt(offset);}
			var previousNextBtn = "<a style=\"cursor:pointer;\" onClick=\"displaySearch('"+trailDIV+"','"+displayDIV+"','"+globalSelectedArray+"','"+limitPerPage+"','"+tmpOffset+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_left.gif\" alt=\"previous page\"  /></a>";
			tmpOffset = parseInt(globalOffset)+parseInt(limitPerPage);
			selArrLen = selectedArray.length+"";
			previousNextBtn += "<a style=\"cursor:pointer;\" onClick=\"displaySearch('"+trailDIV+"','"+displayDIV+"','"+globalSelectedArray+"','"+limitPerPage+"','"+tmpOffset+"');\"><img src=\"" + skinFolder + "/images/buttons/btn_right.gif\" alt=\"next page\"/></a>";			
			if(pageNumber < 1){
				previousNextBtn = "";}}
			else{
			isCurrent = parseInt(i);}
		if((i == 20) || (i == 40) || (i == 60) || (i == 80) || (i == 100) || (i == 120) || (i == 140)|| (i == 160)|| (i == 180)){
			htmlOutput += "<a style=\"cursor:pointer;\" onClick=\"displaySearch('"+trailDIV+"','"+displayDIV+"','"+globalSelectedArray+"','"+limitPerPage+"','"+offset+"');\">"+isCurrent+"</a> ...";			
			break;} 
		htmlOutput += "<a style=\"cursor:pointer;\" onClick=\"displaySearch('"+trailDIV+"','"+displayDIV+"','"+globalSelectedArray+"','"+limitPerPage+"','"+offset+"');\">"+isCurrent+"</a> ";			
		offset += parseInt(limitPerPage);}
	htmlOutput = "Page: "+htmlOutput;	
	WriteLayer(trailDIV,null,htmlOutput);	
	if(trailDIV == "allTrailAllProgramme"){
		WriteLayer('previousNextAllProgramme',null,previousNextBtn);} 
	else if ( trailDIV == "allTrailSearch" ){
		WriteLayer('previousNextSearch',null,previousNextBtn);} 
	else{
		WriteLayer('previousNextByType',null,previousNextBtn);}}
var global_mediaId = "", tmpuserId,tmpmediaId,tmpsystemInfo,tmpno,tmptype,retrygetDRMlicense = 0;
function processDRM(mediaId){
	var userId = "1";
	var no = "1";
	var type = "vod";
	global_mediaId = mediaId;
	
	//alert(global_mediaId);
	//get system info
	//document.all.status.innerHTML = "";
	//document.all.status.innerHTML = "DRM: Getting the system info";
	var systemInfo = document.all.licenseManager.GetSystemInfo();	
	
//theInput = document.getElementById(”thetextbox”);
//theInput.value = document.all.licenseManager.GetSystemInfo();

	//document.cookie = ijurq = systemInfo;
	
//	set fso = CreateObject("Scripting.FileSystemObject");  
//    set s = fso.CreateTextFile("C:\test.txt", True);
//    s.writeline(systemInfo);
//    s.writeline("Bye");
//    s.writeline("-----------------------------");
//    s.Close();
	
	//document.cookie = 'systemInfo=' + systemInfo;
	//document.cookie = 'systemInfo="' + mediaId + '"';
	//alert(systemInfo);
	//document.getElementById("epassloginid").value = systemInfo;
	if ( systemInfo != "" ){
		document.all.status.innerHTML = "";
		//document.all.status.innerHTML = "DRM: System info acquired, getting the drm license..";
		//get drm license
		getDRMlicense(userId,mediaId,systemInfo,no,type );		
	}
}
function storeDRMlicense(mediaLicense){
	//store drm license
	document.all.licenseManager.storeLicense(mediaLicense);
	document.all.status.innerHTML = "";
	//document.all.status.innerHTML = "DRM: Media license stored";
	playDRMvideo();
}
function playDRMvideo(){
	//set the server URL
	//var serverURL = "http://202.157.188.231";
	var mediaId = global_mediaId;
	// play the video
	document.all.status.innerHTML = "&nbsp;Loading...";
	//var fullMediaURL = serverURL + mediaId;
	var fullMediaURL = "mms://202.179.118.92" + mediaId;
	loadMediaPlayerFile( fullMediaURL );	
	//document.all.status.innerHTML = "&nbsp; Video has finally loaded";
}
function getDRMlicense( userId, mediaId, systemInfo, no, type ){
	tmpuserId = userId;
	tmpmediaId = mediaId;
	tmpsystemInfo = systemInfo;
	tmpno = no;
	tmptype = type;
	//alert("x");
	
    var soapMessage, WsUrl, webMethod;
	myXMLdrm = new ActiveXObject("Microsoft.XMLHTTP");
	WsUrl = addrWebServices;
	webMethod="getDRMlicense"; 
	soapMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
	soapMessage += "<soap:Body>";
	soapMessage += "<" + webMethod + " xmlns=\"http://tempuri.org/\">";
	soapMessage += "<userId>"+ userId +"</userId>";
	soapMessage += "<mediaId>"+ mediaId +"</mediaId>";
	soapMessage += "<systemInfo><![CDATA["+ systemInfo +"]]></systemInfo>";
	soapMessage += "<no>"+ no +"</no>";
	soapMessage += "<type>"+ type +"</type>";	
	soapMessage += "</" + webMethod + ">";
	soapMessage += "</soap:Body>";
	soapMessage += "</soap:Envelope>";
	//alert(soapMessage);
	myXMLdrm.onreadystatechange = getDRMlicenseCallback;
	myXMLdrm.Open("POST",WsUrl, true);        
	myXMLdrm.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	myXMLdrm.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	myXMLdrm.send(soapMessage);
}
function getDRMlicenseCallback(){	
	if (myXMLdrm.readyState == 4)
	{
		var htmlOutput = "";
		if (myXMLdrm.status == 200)
		{   
			var x = myXMLdrm.responseXML;
			var xx = x.childNodes[1].xml;
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");
			var root = xmlObject.getElementsByTagName('DRMlicense')[0];
			//var license = root.firstChild.nodeValue;
			var license = root.firstChild.nodeValue;
			
			//alert(license);
			//document.all.licenseResponse.value = license;
			document.all.status.innerHTML = "";
			//alert(license);
			storeDRMlicense(license);
		} 
		else{
			//alert(myXMLdrm.status);
			if (retrygetDRMlicense < 5){
				retrygetDRMlicense += 1;
				getDRMlicense(  tmpuserId,tmpmediaId,tmpsystemInfo,tmpno,tmptype );					
			}
			else{
				tmpuserId = "";
				tmpmediaId = "";
				tmpsystemInfo = "";
				tmpno = "";
				tmptype = "";		
				retrygetDRMlicense = 0;
				//htmlOutput = "<span class=\"style33\"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Error loading channel, please try again later...</span>";
				//WriteLayer('status',null,htmlOutput);	
				document.all.status.innerHTML = "";
				//document.all.status.innerHTML = "DRM: media license acquisition failed";			
			}
		}
    }
}
var bannerAssetId = "", global_preRoll_cursor = "", preRollArray;
function checkRemoteBannerExists(remoteBannerURL){
	checkRemoteBanner = new ActiveXObject("Microsoft.XMLHTTP");
	checkRemoteBanner.onreadystatechange = checkRemoteBannerExistsCallback;
	checkRemoteBanner.Open("GET",remoteBannerURL, true);        
	checkRemoteBanner.send();  
}
function checkRemoteBannerExistsCallback(){
	if (checkRemoteBanner.readyState == 4){
		var htmlOutput = "";
		if(checkRemoteBanner.status == 200){  
			var bannerResponse = checkRemoteBanner.responseText;  
			if(bannerResponse == "<!--null-->"){
				var assetId = bannerAssetId;
				var type = '1'; // ori is 1
				var region = 'HK';
				getAllPreRolls( assetId, type, region );
			} 
			else{
				document.all.divBannerPreRoll.innerHTML = bannerResponse;
			}
		}
	}
}
function getAllPreRolls( assetId, type, region ){
	preRollArray = new Array();
    var soapMessage, WsUrl, webMethod;
	myXMLpreRoll = new ActiveXObject("Microsoft.XMLHTTP");
	WsUrl = addrWebServices;
	webMethod="getAllPreRolls"; 
	soapMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
	soapMessage += "  <soap:Body>";
	soapMessage += "    <" + webMethod + " xmlns=\"http://tempuri.org/\">";
	soapMessage += "	<assetId>"+ assetId +"</assetId>";
	soapMessage += "	<type>"+ type +"</type>";
	soapMessage += "	<region>"+ region +"</region>";
	soapMessage += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";
	myXMLpreRoll.onreadystatechange = getAllPreRollsCallback;
	myXMLpreRoll.Open("POST",WsUrl, true);        
	myXMLpreRoll.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	myXMLpreRoll.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	myXMLpreRoll.send(soapMessage);  
}
function getAllPreRollsCallback(){
	if(myXMLpreRoll.readyState == 4){
		if(myXMLpreRoll.status == 200){  
			global_preRoll_cursor = 0;
			var x = myXMLpreRoll.responseXML;
			var xx = x.childNodes[1].xml;
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");
			var root = xmlObject.getElementsByTagName("preRolls")[0];			
			var preRolls = root.getElementsByTagName("preRoll");
			var epassLoginId = getCookie("loginid");
			if( epassLoginId == "" ){
				epassLoginId = "0";
			}			
			if ( preRolls.length > 0 ){
				for ( i = 0; i < preRolls.length ; i++ ){
					preRoll = preRolls[i];
					var preRollId = preRoll.getAttribute('preRollId');
					var preRollName = preRoll.getElementsByTagName('preRollName')[0].firstChild.nodeValue;
					var preRollType = preRoll.getElementsByTagName('preRollType')[0].firstChild.nodeValue;
					if ( preRoll.getElementsByTagName('preRollUrl')[0] ){
						if ( preRoll.getElementsByTagName('preRollUrl')[0].firstChild != null ){
							var preRollUrl = preRoll.getElementsByTagName('preRollUrl')[0].firstChild.nodeValue;
						} 
						else{
							var preRollUrl = "";
						}
					} 
					else{
						var preRollUrl = "";
					}					
					var preRollSponsor = preRoll.getElementsByTagName('preRollSponsor')[0].firstChild.nodeValue;													
					if( preRoll.getElementsByTagName('preRollSecUrl')[0] ){
						if ( preRoll.getElementsByTagName('preRollSecUrl')[0].firstChild != null ){
							var preRollSecUrl = preRoll.getElementsByTagName('preRollSecUrl')[0].firstChild.nodeValue;
						}
						else{
							var preRollSecUrl = "";
						}						
					} 
					else{
						var preRollSecUrl = "";
					}					
					if(preRoll.getElementsByTagName('preRollTargetUrl')[0]){
						if ( preRoll.getElementsByTagName('preRollTargetUrl')[0].firstChild != null ){
							var preRollTargetUrl = preRoll.getElementsByTagName('preRollTargetUrl')[0].firstChild.nodeValue;				
						} 
						else{
							var preRollTargetUrl = "";
						}
					} 
					else{
						var preRollTargetUrl = "";
					}
					addPreRoll( preRollId,preRollType,preRollName,preRollUrl,preRollSponsor,preRollSecUrl,preRollTargetUrl );
				}
				if ( preRollArray[global_preRoll_cursor].preRollUrl != "" ){
					var mediaPath = preRollArray[global_preRoll_cursor].preRollUrl;
					global_play_type = "preRoll";
					loadMediaPlayerFile( mediaPath );
					sendStatsPrerollView( epassLoginId, preRollArray[global_preRoll_cursor].preRollId);
				} 
				else{
					var mediaPath = "test2.wmv";
					global_play_type = "preRoll";					
					loadMediaPlayerFile( mediaPath );
				}
				if(preRollArray[global_preRoll_cursor].preRollSecUrl != "" ){					
					document.all.divBannerPreRoll.innerHTML = '<a href="'+preRollArray[global_preRoll_cursor].preRollTargetUrl+'" onClick="sendStatsPrerollClick('+epassLoginId+','+preRollArray[global_preRoll_cursor].preRollId+');"><img src="'+preRollArray[global_preRoll_cursor].preRollSecUrl+'"></a>';
				} 
				else{
					var preRollId = "0";					
					document.all.divBannerPreRoll.innerHTML = '<a href="http://www.astro.com.my" target="_blank"><img style="cursor:pointer;" onClick="sendStatsPrerollClick('+epassLoginId+','+preRollArray[global_preRoll_cursor].preRollId+');" src="banner/default_banner_288x61.gif"></a>';
					sendStatsPrerollView( epassLoginId, preRollArray[global_preRoll_cursor].preRollId);
				}
			} 
			else{				
				var mediaPath = "test2.wmv";
				global_play_type = "preRoll";				
				var fullMediaPath = appPath + mediaPath;		
				loadMediaPlayerFile( fullMediaPath );
				var preRollId = "0";					
				document.all.divBannerPreRoll.innerHTML = '<a href="http://www.astro.com.my" target="_blank"><img style="cursor:pointer;" onClick="sendStatsPrerollClick('+epassLoginId+','+preRollId+');" src="banner/default_banner_288x61.gif"></a>';
			}			
		}
	}
}
function getBannerPreRoll( assetId ){
	bannerAssetId = assetId;
	var remoteBannerURL = "http://202.179.118.19/ads/banner_300x62.asp?q=astrotv&t="+assetId;
	checkRemoteBannerExists( remoteBannerURL );
}
function getVideoPreRoll( assetId ){
	bannerAssetId = assetId;
	var assetId = bannerAssetId;
	var type = '2'; // 2 is for sync, 0 is for video, both are working but gives both video and banner
	var region = 'MY';
	getAllPreRolls( assetId, type, region );
}
function loadPage(actionBy,page){
	if(document.getElementById("list2").innerHTML == ""){ 
		loadPlaylistPanel();
		showPlaylist();		
		if(getCookie("loginid") != ""){
			loadAllUserPlaylistFromWS();}}	
	else{
		loadAllUserPlaylistFromWS();}	
	if(cpanelState == "open"){
		displayControlPanel();}	
	if(page == "whats on"){
		unloadPage('previews');
		unloadPage('programmes');		
		unloadPage('genres');
		unloadPage('playlist');		
		document.getElementById("tab_whatson_editorspick").style.display = "block";
		document.getElementById("tab_whatson_mostviewed").style.display = "block";
		document.getElementById("tab_editors_pick_bg").style.display = "block";
		document.getElementById("tab_most_viewed_bg").style.display = "block";	
		var currentPageId = "138";			
		checkAssetsByGroupId(actionBy,currentPageId,'','','');} 	
	if(page == "previews"){			
		setMenuActive('2');
		globalPage = "previews";		
		unloadPage("whats on");
		unloadPage('programmes');		
		unloadPage('genres');
		unloadPage('playlist');			
		document.getElementById("tab_previews_latest").style.display = "block";
		document.getElementById("tab_previews_latest_bg").style.display = "block";
		document.getElementById("tab_previews_bychannels").style.display = "block";
		document.getElementById("tab_previews_bychannels_bg").style.display = "block";
		document.getElementById("apDiv5").style.display = "block";		
		var currentPageId = "115";
		checkAssetsByGroupId(actionBy,'140','','','');} 	
	if(page == "programmes"){
		globalPage = "programmes";		
		unloadPage("whats on");
		unloadPage('previews');
		unloadPage('genres');
		unloadPage('playlist');			
		document.getElementById("tab_programmes_latest").style.display = "block";
		document.getElementById("tab_programmes_latest_bg").style.display = "block";
		document.getElementById("tab_programmes_bychannels").style.display = "block";
		document.getElementById("tab_programmes_bychannels_bg").style.display = "block";
		document.getElementById("apDiv5").style.display = "block";		
		checkAssetsByGroupId(actionBy,'142','','','');} 	
	if(page == "genres"){		
		unloadPage("whats on");
		unloadPage('previews');
		unloadPage('programmes');		
		unloadPage('playlist');			
		document.getElementById("tab_genre_list").style.display = "block";
		document.getElementById("tab_genre_list_bg").style.display = "block";
		document.getElementById("apDiv5").style.display = "block";
		checkGenres();}	
	if(page == "playlist"){		
		unloadPage("whats on");
		unloadPage('previews');
		unloadPage('programmes');		
		unloadPage('genres');		
		document.getElementById("tab_playlist_list").style.display = "block";
		document.getElementById("apDiv5").style.display = "block";			
		if(document.getElementById("tab_whatson_editorspick"))
		{MM_showHideLayers('tab_whatson_editorspick','','hide');}		
		if(document.getElementById("WhatsOn"))
		{MM_showHideLayers('WhatsOn','','hide');}		
		if(document.getElementById("tab_whatson_mostviewed"))
		{MM_showHideLayers('tab_whatson_mostviewed','','hide');}		
		if(document.getElementById("MostViewed"))
		{MM_showHideLayers('MostViewed','','hide');}		
		if(document.getElementById("tab_previews_latest"))
		{MM_showHideLayers('tab_previews_latest','','hide');}		
		if(document.getElementById("PreviewLatest"))		
		{MM_showHideLayers('PreviewLatest','','hide');}		
		if(document.getElementById("tab_previews_bychannels"))	
		{MM_showHideLayers('tab_previews_bychannels','','hide');}		
		if(document.getElementById("PLByChannels"))	
		{MM_showHideLayers('PLByChannels','','hide');}		
		if(document.getElementById("apDiv5"))	
		{MM_showHideLayers('apDiv5','','hide');}				
		if(document.getElementById("tab_programmes_latest"))	
		{MM_showHideLayers('tab_programmes_latest','','hide');}		
		if(document.getElementById("ProgrammeLatest"))
		{MM_showHideLayers('ProgrammeLatest','','hide');}			
		if(document.getElementById("tab_programmes_bychannels"))
		{MM_showHideLayers('tab_programmes_bychannels','','hide');}
		if(document.getElementById("PRByChannels"))
		{MM_showHideLayers('PRByChannels','','hide');}
		if(document.getElementById("list1"))
		{MM_showHideLayers('list1','','hide');}		
		if(document.getElementById("GenreList"))
		{MM_showHideLayers('GenreList','','hide');}		
		if(document.getElementById("list2"))
		{MM_showHideLayers('list2','','show');}		
		if(document.getElementById("list2").innerHTML == ""){ 
			loadPlaylistPanel();
			showPlaylist();
			if(getCookie("loginid") != ""){
				loadAllUserPlaylistFromWS();}} 
		else{
			loadAllUserPlaylistFromWS();}}	
	/*omniture codes start here*/	
		global_tab = page;
		setOmnitureValues(actionBy,'loadPage',page,'none','none','none');			
	/*omniture codes end here*/
}
function unloadPage(page){	
	if(page == "whats on"){
		document.getElementById("tab_whatson_editorspick").style.display = "none";
		document.getElementById("tab_whatson_mostviewed").style.display = "none";
		document.getElementById("tab_editors_pick_bg").style.display = "none";
		document.getElementById("tab_most_viewed_bg").style.display = "none";}	
	if(page == "previews"){
		document.getElementById("tab_previews_latest").style.display = "none";
		document.getElementById("tab_previews_latest_bg").style.display = "none";
		document.getElementById("tab_previews_bychannels").style.display = "none";
		document.getElementById("tab_previews_bychannels_bg").style.display = "none";
		document.getElementById("apDiv5").style.display = "none";}	
	if(page == "programmes"){
		document.getElementById("tab_programmes_latest").style.display = "none";
		document.getElementById("tab_programmes_latest_bg").style.display = "none";
		document.getElementById("tab_programmes_bychannels").style.display = "none";
		document.getElementById("tab_programmes_bychannels_bg").style.display = "none";
		document.getElementById("apDiv5").style.display = "none";}	
	if(page == "genres"){		
		document.getElementById("tab_genre_list").style.display = "none";
		document.getElementById("tab_genre_list_bg").style.display = "none";}	
	if(page == "playlist"){
		if(document.getElementById("tab_playlist_list").style.display == "block"){
			var htmlOutput = "";}
		document.getElementById("tab_playlist_list").style.display = "none";	
		MM_showHideLayers('list1','','show','list2','','hide');}}
function showSecondaryTab(actionBy,selectedChannel,referrer){
	if(globalChannelSection == "previews"){
		document.getElementById("tab_previews_latest").style.display = "none";
		document.getElementById("tab_previews_latest_bg").style.display = "none";
		document.getElementById("tab_previews_bychannels").style.display = "none";
		document.getElementById("tab_previews_bychannels_bg").style.display = "none";
		checkPromosByChannel(actionBy,selectedChannel,referrer);} 	
	if(globalChannelSection == "programmes"){		
		document.getElementById("tab_programmes_latest").style.display = "none";
		document.getElementById("tab_programmes_latest_bg").style.display = "none";
		document.getElementById("tab_programmes_bychannels").style.display = "none";
		document.getElementById("tab_programmes_bychannels_bg").style.display = "none";
		checkProgrammeByChannel(actionBy,selectedChannel,referrer);}	
	if(globalChannelSection == "genres"){		
		document.getElementById("tab_genre_list").style.display = "none";
		document.getElementById("tab_genre_list_bg").style.display = "none";
		MM_showHideLayers('apDiv5','','show');
		getLatestProgrammeByGenre(actionBy,selectedChannel,referrer);}	
	if(globalChannelSection == "playlist"){		
		document.getElementById("tab_playlist_list").style.display = "none";
		MM_showHideLayers('apDiv5','','show');}}
function hideSecondaryTab(actionBy){
	if(globalChannelSection == "previews"){		
		document.getElementById("tab_previews_latest").style.display = "block";
		document.getElementById("tab_previews_latest_bg").style.display = "block";
		document.getElementById("tab_previews_bychannels").style.display = "block";
		document.getElementById("tab_previews_bychannels_bg").style.display = "block";	
		checkChannels('auto','previews','1');} 	
	if(globalChannelSection == "programmes"){		
		document.getElementById("tab_programmes_latest").style.display = "block";
		document.getElementById("tab_programmes_latest_bg").style.display = "block";
		document.getElementById("tab_programmes_bychannels").style.display = "block";
		document.getElementById("tab_programmes_bychannels_bg").style.display = "block";
		checkChannels('auto','programmes','2');}	
	if(globalChannelSection == "genres"){		
		document.getElementById("tab_genre_list").style.display = "block";
		document.getElementById("tab_genre_list_bg").style.display = "block";
		checkGenres();}	
	if(globalChannelSection == "playlist"){	
		document.getElementById("tab_playlist_list").style.display = "block";
		MM_showHideLayers('apDiv5','','hide');}}
function setChannelName(channelName){
	document.getElementById("spanChannelName").innerHTML = channelName;}
function loadGenreByProgramme(actionBy,programmeId, programmeSeason, programmeGenreId){	
	pageScroll('-500');	
	if(document.getElementById("comments").style.visibility == "visible"){
		document.getElementById('comments').style.visibility = "hidden";
		document.getElementById('comments-centered').style.visibility = "hidden";}
		unloadPage("whats on");
		unloadPage('previews');
		unloadPage('programmes');	
		unloadPage('playlist');		
		document.getElementById("tab_genre_list").style.display = "none";
		document.getElementById("tab_genre_list_bg").style.display = "none";
		document.getElementById("apDiv5").style.display = "block";		
		MM_showHideLayers('apDiv5','','show');
		getLatestProgrammesBySeason(actionBy, programmeId, programmeSeason, programmeGenreId);
		globalChannelSection = "genres";
		setMenuActive('4');}
function setMenuActive(number){	
	document.getElementById("menu_0"+number+"_btn").background = "" + skinFolder + "/images/buttons/btn_0"+number+"b.gif";
	for( i=1;i<=5;i++ ){
		if(document.getElementById("menu_0"+i+"_btn").background != "" + skinFolder + "/images/buttons/btn_0"+number+"b.gif"){
			document.getElementById("menu_0"+i+"_btn").background = "" + skinFolder + "/images/buttons/btn_0"+i+".gif";
}}}
var lastHighlight,retryRate=0,tmptheAssetId,tmptheRating,currentlyPlayingId,currentlyPlayingArray,currentlyPlayingURL, currentlyProgId;
var gbVideoName = "",gbDuration=1,gbActionBy = "",arryAssetVOD, globalAutoPlay = false;
function showNowPlaying(){
	document.getElementById('divPlayNow').style.display = "";}
function ratingState(theStar){
	var theState;
	if(theStar == 0){theState = "";}
	if(theStar == 1){theState = "Poor";}
	if(theStar == 2){theState = "Fair";}
	if(theStar == 3){theState = "Average";}
	if(theStar == 4){theState = "Good";}
	if(theStar == 5){theState = "Excellent";}
	document.getElementById('divRateState').innerHTML = "&nbsp;" + theState;}
function playNowFromPlaylist(actionBy, theId, theArray){
	var epassLoginId = "0";
	if( getCookie("loginid")!= "" ){
		epassLoginId = getCookie("loginid");} 	
	var seederDate = "0";	
	if ((getCookie("seederDate") != "") || (getCookie("seederDate") != undefined)){
		seederDate = getCookie("seederDate");}	
	var seederTime = "0";	
	if ((getCookie("seederTime") != "") || (getCookie("seederTime") != undefined)){
		seederTime = getCookie("seederTime");}
	sendStatsVideoPlayInPlaylist(epassLoginId, theId, seederDate, seederTime);
	playNow(actionBy,theId,theArray);}
function playNow(actionBy,theId,theArray){
	if(document.getElementById("divNotAuthorized").style.display == "block"){
		document.getElementById("divNotAuthorized").style.display = "none";}	
	if(document.getElementById("MediaPlayer").style.display == 'none'){
		document.getElementById("MediaPlayer").style.display = 'block';}	
	document.getElementById("divPauseBtn").style.display = "block";	
	document.getElementById("divPlayBtn").style.display = "none";	
	if(document.getElementById('comments').style.visibility == 'visible'){
		closeControlPanel();}	
	if(document.getElementById("videoStop")){
		if(document.getElementById("videoStop").style.display == 'block'){
			document.getElementById("videoStop").style.display = 'none';
			document.getElementById("MediaPlayer").style.display = 'block';}}	
	if(document.getElementById("share")){
		document.all.share.style.visibility = "hidden";}	
	if(document.getElementById("shareResponse")){
		document.all.shareResponse.style.visibility = "hidden";}	
	var tempArray = eval(theArray),assetLevel = "";	
	for(var i=0; i < tempArray.length; i++){
		if (tempArray[i].assetId == theId){
			currentlyPlayingURL = serverURL+tempArray[i].assetVideo;
			assetLevel = tempArray[i].assetLevel;}}	
	if(!checkUserAuthorization(assetLevel)){
		return false;}
	showNowPlaying();
	document.getElementById('divPlayNow').innerHTML = '<br><p class="style9">&nbsp;&nbsp;<img src="' + skinFolder + '/images/load.gif" width="10" height="10" align="absmiddle">&nbsp;Loading info...</p>';	
	for(var i=0; i < tempArray.length; i++){						
		if (tempArray[i].assetId == theId){
			var assetId = tempArray[i].assetId;
			var assetImage = tempArray[i].assetImage;
			var assetVideo = tempArray[i].assetVideo;
			var assetTitle = tempArray[i].assetTitle;
			var assetLanguage = tempArray[i].assetLanguage;
			var assetLengthMinutes = tempArray[i].assetLengthMinutes;
			var assetSynopsis = tempArray[i].assetSynopsis;				
			var assetTags = tempArray[i].assetTags;
			var assetViewed = tempArray[i].assetViewed;
			var assetRating = tempArray[i].assetRating;
			var assetAstroChannelName = tempArray[i].assetAstroChannelName;				
			var assetGenre = tempArray[i].assetGenre;	
			var progId = tempArray[i].programmeId;
			currentlyPlayingId = assetId; 
			currentlyProgId = progId; 
			currentlyPlayingArray = tempArray;			
			gbVideoName = assetTitle;
			gbDuration = assetLengthMinutes;			
			gbDuration = gbDuration.replace(/ min/i, "");
			gbDuration = gbDuration.replace(/ sec/i, "");				
			gbActionBy = actionBy;	
			if(assetTags != ""){
				var txtTags = '<font color="#FFFFFF">Tags:</font>&nbsp;';}
			else{var txtTags = '';}
			var ArrayassetTags = assetTags.split(",");
			var theTagLink = "";			
			for (var x=0; x < ArrayassetTags.length; x++){
				theTagLink += '<a style="cursor:pointer" onClick="goTagSearch(\'' + ArrayassetTags[x] + '\', \''+ tempArray[i].assetId +'\');">' + ArrayassetTags[x] + '</a>';
				if (x != eval(ArrayassetTags.length - 1)){ theTagLink += ", "; }}				

			var theRateFunc = '<div id="divRateThisAsset"><table class="style9" border=0 cellspacing=0 cellpadding=0><tr><td>Rate this video : ' +
			'<a style="cursor:pointer" onClick="goRateVideo(\'' + tempArray[i].assetId + '\',\'1\');"><img align="absmiddle" src="' + skinFolder + '/images/star2b.gif" name="rate1" width="14" height="14" border="0" id="Image2"  onMouseOver="ratingState(1); MM_swapImage(\'rate1\',\'\',\'' + skinFolder + '/images/star2.gif\',1)" onMouseOut="ratingState(0); MM_swapImgRestore()" /></a>' +
			'<a style="cursor:pointer" onClick="goRateVideo(\'' + tempArray[i].assetId + '\',\'2\');"><img align="absmiddle" src="' + skinFolder + '/images/star2b.gif" name="rate2" width="14" height="14" border="0" id="Image21" onMouseOver="ratingState(2); MM_swapImage(\'rate1\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate2\',\'\',\'' + skinFolder + '/images/star2.gif\',1)" onMouseOut="ratingState(0); MM_swapImgRestore()" /></a>' +
			'<a style="cursor:pointer" onClick="goRateVideo(\'' + tempArray[i].assetId + '\',\'3\');"><img align="absmiddle" src="' + skinFolder + '/images/star2b.gif" name="rate3" width="14" height="14" border="0" id="Image22" onMouseOver="ratingState(3); MM_swapImage(\'rate1\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate2\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate3\',\'\',\'' + skinFolder + '/images/star2.gif\',1)" onMouseOut="ratingState(0); MM_swapImgRestore()" /></a>' +
			'<a style="cursor:pointer" onClick="goRateVideo(\'' + tempArray[i].assetId + '\',\'4\');"><img align="absmiddle" src="' + skinFolder + '/images/star2b.gif" name="rate4" width="14" height="14" border="0" id="Image23" onMouseOver="ratingState(4); MM_swapImage(\'rate1\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate2\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate3\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate4\',\'\',\'' + skinFolder + '/images/star2.gif\',1)" onMouseOut="ratingState(0); MM_swapImgRestore()" /></a>' +
			'<a style="cursor:pointer" onClick="goRateVideo(\'' + tempArray[i].assetId + '\',\'5\');"><img align="absmiddle" src="' + skinFolder + '/images/star2b.gif" name="rate5" width="14" height="14" border="0" id="Image24" onMouseOver="ratingState(5); MM_swapImage(\'rate1\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate2\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate3\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate4\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate5\',\'\',\'' + skinFolder + '/images/star2.gif\',1)" onMouseOut="ratingState(0); MM_swapImgRestore()" /></a>' +
			'</td><td><div id=divRateState>&nbsp;</div></td></tr></table></div>' +
			'<div id="divRateThisAsset2" class="style11" style="display:none">submitting...</div>' +
			'<div id="divRateThisAsset3" class="style11" style="display:none">Thank you for rating.</div>' +
			'<div id="divDisplayRatedAsset" class="style9" style="display:none"></div>' +
			'<div id="divRateThisAsset4" class="pl_notify" style="display:none">Please login to rate video.</div>' +
			'<div id="divRateThisAssetAlready" class="style11" style="display:none">You already rate this video today.</div>';			
			
			var theContent = '<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"' + skinFolder + '/images/index_31.gif\">\
<tr>\
<td colspan=\"2\" rowspan=\"2\" valign=\"top\">&nbsp;</td>\
<td width=\"55\" height=\"16\"></td>\
<td width=\"57\"></td>\
<td width=\"151\"></td>\
<td colspan=\"2\" rowspan=\"2\" valign=\"top\">&nbsp;</td>\
</tr>\
<tr>\
<td height=\"122\" colspan=\"3\" valign=\"top\"><p><span class=\"style8\">' + assetTitle + '</span><br>\
	  <span class=\"style2\">' + assetGenre + '</span></p><p class=\"style9\" style=\"height:70; width:100%; overflow:auto; \">' + assetSynopsis + '</p></td>\
</tr>\
<tr>\
<td width=\"6\" height=\"8\"></td>\
<td width=\"11\"></td>\
<td></td>\
<td></td>\
<td></td>\
<td width=\"11\"></td>\
<td width=\"7\"></td>\
</tr>\
<tr>\
<td height=\"13\"></td>\
<td></td>\
<td colspan=\"5\" valign=\"top\">' + theRateFunc + '</td>\
</tr>\
<tr>\
<td height=\"24\"></td>\
<td></td>\
<td>&nbsp;</td>\
<td></td>\
<td></td>\
<td></td>\
<td></td>\
</tr>\
<tr>\
<td height=\"24\"></td>\
<td></td>\
<td colspan=\"3\" valign=\"top\" class=\"style7\">' + txtTags + theTagLink + ' </td>\
<td></td>\
<td></td>\
</tr>\
<tr>\
<td height=\"5\"></td>\
<td></td>\
<td></td>\
<td></td>\
<td></td>\
<td></td>\
<td></td>\
</tr>\
<tr>\
<td height=\"19\"></td>\
<td></td>\
<td colspan=\"2\" valign=\"top\"><a style=\"cursor:pointer\" onClick=\"shareNow(\'' + assetId + '\');\"><img src=\"' + skinFolder + '/images/buttons/btn_sharevideo.gif\" alt=\"share this video\" width=\"112\" height=\"19\" border=0 /></a></td>\
<td>&nbsp;</td>\
<td></td>\
<td></td>\
</tr>\
<tr>\
<td height=\"23\"></td>\
<td></td>\
<td>&nbsp;</td>\
<td></td>\
<td></td>\
<td></td>\
<td></td>\
</tr>\
<tr>\
<td rowspan=\"2\" valign=\"top\">\
  <img src=\"' + skinFolder + '/images/index_37.gif\" width=\"6\" height=\"63\" alt=\"\"></td>\
<td height=\"58\" colspan=\"5\" valign=\"top\">\
<!--img src=\"' + skinFolder + '/images/ads/advert_small.gif\" width=\"285\" height=\"58\" alt=\"\"-->\
<div id="divBannerPreRoll" style="height:61px; width:288px; overflow:hidden; background-color: #CCCCCC;"></div></td>\
<td rowspan=\"2\" valign=\"top\">\
<img src=\"' + skinFolder + '/images/index_39.gif\" width=\"7\" height=\"63\" alt=\"\"></td>\
</tr>\
<tr>\
<td height=\"5\" colspan=\"5\" valign=\"top\">\
  <img src=\"' + skinFolder + '/images/index_52.gif\" width=\"285\" height=\"5\" alt=\"\"></td>\
</tr>\
</table>\
';
			document.getElementById('divPlayNow').innerHTML = theContent;
			MM_showHideLayers('tab3','','show','tab4','','hide','list3','','show','list4','','hide')
			global_play_type = "single";				
			getVideoPreRoll(assetId);
			global_play_type = "single";
			global_mediaId = assetVideo;
			if(lastHighlight !== undefined && lastHighlight != ""){
				if(document.getElementById(lastHighlight)){ 
					document.getElementById(lastHighlight).style.background = "url(' + skinFolder + '/images/listing_bg.gif)"; 
					var tmpStarArray = lastHighlight.split("Asset");
					var lastNo = tmpStarArray[1];}}
			if(theArray == "arryActivePlaylistAsset"){
				var highlightDivName = 'playlistAsset' + i;				
				document.getElementById(highlightDivName).style.background = "url(' + skinFolder + '/images/listing_bg_02.gif)";
				lastHighlight = highlightDivName;}
			else{lastHighlight = "";}
			var epassLoginId = getCookie("loginid");
			if(epassLoginId == ""){ 
				epassLoginId = "0";}		
			var seederDate = "0";			
			if((getCookie("seederDate") != "") || (getCookie("seederDate") != undefined)){
				seederDate = getCookie("seederDate");}				
			var seederTime = "0";	
			if((getCookie("seederTime") != "") || (getCookie("seederTime") != undefined)){
				seederTime = getCookie("seederTime");}							
			sendstatsViewVideo(epassLoginId, assetId, seederDate, seederTime);
			getMoreCheck(progId, assetId);
			/*omniture codes start here*/	
			switch(theArray){
				case "assetArray_138":
					setOmnitureValues(actionBy,'getAssetsByGroupId','138',assetTitle,'event17',assetId);	
					break;
				case "assetArray_140":
					setOmnitureValues(actionBy,'getAssetsByGroupId','140',assetTitle,'event17',assetId);						
					break;
				case "assetArray_142":
					setOmnitureValues(actionBy,'getAssetsByGroupId','142',assetTitle,'event17',assetId);
					break;
				case "latestPromosByChannelAssetArray":
					setOmnitureValues(actionBy,'getlatestPromosByChannel',assetAstroChannelName,assetTitle,'event17',assetId);	
					break;
				case "latestProgrammeByChannelAssetArray":
					setOmnitureValues(actionBy,'getlatestProgrammeByChannel',assetAstroChannelName,assetTitle,'event17',assetId);	
					break;
				case "latestProgrammeByGenreAssetArray":
					setOmnitureValues(actionBy,'getlatestProgrammeByGenre',assetGenre,assetTitle,'event17',assetId);
					break;
				case "topViewedAssetArray":						
					setOmnitureValues(actionBy,'getMostViewedAssets','mostviewed',assetTitle,'event17',assetId);
					break;	
				case "moreEpisodeAssetArray":
					switch(global_tab){
						case "138":
							setOmnitureValues(actionBy,'getAssetsByGroupId','138',assetTitle,'event17',assetId);								
							break;
						case "mostviewed":
							setOmnitureValues(actionBy,'getMostViewedAssets','mostviewed',assetTitle,'event17',assetId);
							break;
						case "140":
							setOmnitureValues(actionBy,'getAssetsByGroupId','140',assetTitle,'event17',assetId);								
							break;
						case "prom_byChannel":
							setOmnitureValues(actionBy,'getlatestPromosByChannel',assetAstroChannelName,assetTitle,'event17',assetId);	
							break;
						case "142":
							setOmnitureValues(actionBy,'getAssetsByGroupId','142',assetTitle,'event17',assetId);								
							break;
						case "prog_byChannel":
							setOmnitureValues(actionBy,'getlatestProgrammeByChannel',assetAstroChannelName,assetTitle,'event17',assetId);
							break;
						case "prog_byGenres":
							setOmnitureValues(actionBy,'getlatestProgrammeByGenre',assetGenre,assetTitle,'event17',assetId);
							break;}
					break;}				
			/*omniture codes end here*/				
		}}}
function goTagSearch(theTag,tagAsset){
	getSearchAssets( theTag, '500', 'all','view','false');
	searchNow2(theTag);	
	var tagSeeder = tagAsset;
	sendstatsMostTagClicks(tagSeeder);}
function displayStarRating2(rating){
	var myStar = "";
	for(var i = 1; i <= 5; i++){
		if(i <= rating){
			myStar += "<img src=\"" + skinFolder + "/images/star.gif\" width=\"11\" height=\"13\" />";}
		else{
			myStar += "<img src=\"" + skinFolder + "/images/starb.gif\" width=\"11\" height=\"13\" />";}}
	return myStar;}
function displayStarRating3(rating){
	var myStar = "";
	for(var i = 1; i <= 5; i++){
		if(i <= rating){
			myStar += "<img src=\"" + skinFolder + "/images/star2.gif\" width=\"11\" height=\"11\" />";}
		else{
			myStar += "<img src=\"" + skinFolder + "/images/star2b.gif\" width=\"11\" height=\"11\" />";}}
	return myStar;}
function goRateVideo(theAssetId,theRating){
	tmptheAssetId = theAssetId;
	tmptheRating = theRating;
	if (loginid == "" || loginid === undefined){
		document.getElementById('divRateThisAsset').style.display = "none";	
		document.getElementById('divRateThisAsset2').style.display = "none";
		document.getElementById('divRateThisAsset3').style.display = "none";
		document.getElementById('divRateThisAsset4').style.display = "";
		setTimeout("new Effect.Fade(document.getElementById('divRateThisAsset4'))",3000);
		setTimeout("new Effect.Appear(document.getElementById('divRateThisAsset'))",4000);}
	else{
		var alreadyRate;		
		alreadyRate = getCookie(loginid + theAssetId);
		if(alreadyRate == "1"){ 
			document.getElementById('divRateThisAsset').style.display = "none";	
			document.getElementById('divRateThisAsset2').style.display = "none";
			document.getElementById('divRateThisAsset3').style.display = "none";
			document.getElementById('divRateThisAsset4').style.display = "none";
			document.getElementById('divRateThisAssetAlready').style.display = "";
			setTimeout("new Effect.Fade(document.getElementById('divRateThisAssetAlready'))",3000);
			setTimeout("new Effect.Appear(document.getElementById('divRateThisAsset'))",4000);}
		else{
			document.getElementById('divRateThisAsset').style.display = "none";
			document.getElementById('divRateThisAsset2').style.display = "";	
			XMLassetRateIt = false;
			XMLassetRateIt = new ActiveXObject("Microsoft.XMLHTTP");			
			var soapMessage, webMethod;			
			webMethod="setAssetRating"; 			
			soapMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
			soapMessage += "  <soap:Body>";
			soapMessage += "    <" + webMethod + " xmlns=\"http://tempuri.org/\">";
			soapMessage += "	<epassLoginId>"+ loginid +"</epassLoginId>";
			soapMessage += "	<assetId>"+ theAssetId +"</assetId>";	
			soapMessage += "	<rating>"+ theRating +"</rating>";
			soapMessage += "    </" + webMethod + ">";
			soapMessage += "  </soap:Body>";
			soapMessage += "</soap:Envelope>";
			XMLassetRateIt.onreadystatechange = goRateVideoCB;
			XMLassetRateIt.Open("POST",addrWebServices, true);        
			XMLassetRateIt.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
			XMLassetRateIt.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
			XMLassetRateIt.send(soapMessage);}}}
function goRateVideoCB(){
	if (XMLassetRateIt.readyState == 4){
		if (XMLassetRateIt.status == 200){			
			document.getElementById('divRateThisAsset2').style.display = "none";
			document.getElementById('divRateThisAsset3').style.display = "";
			dispStarRated(tmptheAssetId);
			setCookie(loginid + tmptheAssetId,"1",1);			
			tmptheAssetId = "";
			tmptheRating = "";}
		else{
			if(retryRate < 5){
				retryRate += 1;
				goRateVideo(tmptheAssetId,tmptheRating);
				tmptheAssetId = "";
				tmptheRating = "";}
			else{
				retryRate = 0;
				document.getElementById('divRateThisAsset2').style.display = "none";
				document.getElementById('divRateThisAsset').style.display = "";
				tmptheAssetId = "";
				tmptheRating = "";}}}}
function clearAssetsListing(){
	htmlOutput = "";
	WriteLayer('displayAllAssets',null,htmlOutput);	
}
function clearMainPanel(){
	htmlOutput = "";
	WriteLayer('mainPanel',null,htmlOutput);	
}
function displayHomePageAds() {
	//htmlOutput = "<div id=\"homepageAds\"><img src=\"home_flash/home_intro_01.jpg\" width=\"242\" height=\"347\" border=\"0\" usemap=\"#Map\" /><img src=\"home_flash/home_intro_02.jpg\" width=\"247\" height=\"347\" border=\"0\" usemap=\"#Map2\" /><img src=\"home_flash/home_intro_03.jpg\" width=\"224\" height=\"347\" border=\"0\" usemap=\"#Map3\" /><img src=\"home_flash/home_intro_04.jpg\" width=\"233\" height=\"347\" border=\"0\" usemap=\"#Map4\" /></div>";
	// writing to mainPanel
	htmlOutput = '\
				<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="946" height="347">\
				<param name="movie" value="home_flash/intro.swf">\
				<param name="quality" value="high">\
				<param name="wmode" value="transparent">\
				<embed wmode="transparent" src="home_flash/intro.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="946" height="347"></embed>\
				</object>\
				';
	WriteLayer('mainPanel',null,htmlOutput);
}
function displayNewsletter(){
	clearByTypeContents();	
	if ( loginid != "" ){

		htmlOutput = '\
					<div id="newsLetterSubs" style="position:absolute; width:400px; height:349px; z-index:1003; visibility: visible; ">\
						<iframe src="http://www.epass.com.my/cgi-bin/epass/v4/email/inc_astrotv_newsletter.asp?loginid='+loginid+'" height="349" width="405" scrolling="No" frameborder="0"></iframe>\
					</div>\
						';
		
	} else {
		
		htmlOutput = "<span class=\"style33\"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Please login first to subscribe to astro.tv newsletter</span>";
		
	}
		WriteLayer('displayAllAssetsByType',null,htmlOutput);			
}
function clearByTypeContents() {
	document.all.displayAllAssetsByType.innerHTML = "";
	document.all.allTrailByType.innerHTML = "";
	document.all.previousNextByType.innerHTML = "";	
}
function closeBrowserFullscreen(){
	setCookie("isFullscreen");
	self.close();
}
function showBrowserFullscreen(){
	var isFullscreen = getCookie("isFullscreen");
	setCookie("isFullscreen","true");		
	window.open(location.href,'fullscreen','fullscreen,scrollbars');
}
function getFullScreenInfo(){
	var isFullscreen = getCookie("isFullscreen");
	if(isFullscreen == "true" ){
		document.getElementById("fullscreenBtn").innerHTML = '<span class="style19" style="vertical-align:middle; cursor:pointer;" onClick="closeBrowserFullscreen();">CLOSE FULLSCREEN</span>';
	}
}
// we are using controls for media player 9. This is assuming that the user will not be using wmp 6.4
// method to control 6.4 are really2 different
// reference: http://msdn2.microsoft.com/en-us/library/bb262746.aspx
global_state="";
global_play_type="";
global_playlist_cursor="";
global_state_stop=false;
videos = new Array();
videos[0] = "sample.wmv";
videos[1] = "sample2.mpg";
videos[2] = "sample.wmv";	
function loadAnotherPreRoll(){
	var epassLoginId = getCookie("loginid");
	if ( epassLoginId == "" ){
		epassLoginId = "0";
	}
	var mediaPath = preRollArray[global_preRoll_cursor].preRollUrl;
	loadMediaPlayerFile( mediaPath );	
}
function playAll(selectedPlaylist ){
	if (selectedPlaylist.length != 0){
		global_play_type = "all";		
		global_playlist_cursor=0;		
		selectedPlaylist = eval(selectedPlaylist);
		if ( document.all.videoStop.style.display == 'block' ){
			document.all.videoStop.style.display='none';
		}
		var assetLevel = selectedPlaylist[ global_playlist_cursor ].assetLevel;
		if ( !checkUserAuthorization(assetLevel) ){
			return false;
		}		
		currentlyPlayingId = selectedPlaylist[ global_playlist_cursor ].assetId;
		var mediaPath = selectedPlaylist[ global_playlist_cursor ].assetVideo;		
		processDRM( mediaPath );		
		document.getElementById("divPauseBtn").style.display = "block";
		document.getElementById("divPlayBtn").style.display = "none";
	}	
}
function getPreviousItemFromPlaylist( selectedPlaylist ){
	if ( global_play_type == "single" ){
		return;
	}	
	g_selectedPlaylist = selectedPlaylist;
	selectedPlaylist = eval(selectedPlaylist);
	global_state="new";
	global_playlist_cursor--;
	if (  global_playlist_cursor > -1  ){
		var mediaPath = selectedPlaylist[ global_playlist_cursor ].assetVideo;		
		var assetLevel = selectedPlaylist[ global_playlist_cursor ].assetLevel;
		if ( !checkUserAuthorization(assetLevel) ){
			return false;
		}		
		setTimeout("processDRM('"+mediaPath+"');",1250);		
	} 
	else{
		stopMediaPlayer();
		global_playlist_cursor++;
	}	
}
function getNextItemFromPlaylist(selectedPlaylist){
	if ( global_play_type == "single" ){
		return;
	}	
	g_selectedPlaylist = selectedPlaylist;	
	selectedPlaylist = eval(selectedPlaylist);
	global_state="new";
	global_playlist_cursor++;
	if (  global_playlist_cursor < selectedPlaylist.length  ){
		var mediaPath = selectedPlaylist[ global_playlist_cursor ].assetVideo;	
		var assetLevel = selectedPlaylist[ global_playlist_cursor ].assetLevel;
		if ( !checkUserAuthorization(assetLevel) ){
			return false;
		}		
		setTimeout("processDRM('"+mediaPath+"');",1250);		
	} 
	else{
		stopMediaPlayer();
		showVideoStopAction();
		global_playlist_cursor--;
	}	
}
function playNowTest( file ){
	global_play_type = "single";
	loadMediaPlayerFile( file );
		document.getElementById("divPauseBtn").style.display = "block";
		document.getElementById("divPlayBtn").style.display = "none";	
}
function getMediaPlayerStatus(){
	currentStatus = document.MediaPlayer.status;
	return currentStatus;
}
function loadMediaPlayerFile( file ){
	document.all.MediaPlayer.URL = file;
	
	if ( ( global_preRoll_cursor != 0 ) && (global_play_type == "preRoll") ){		
		return;
	}
	if ( global_play_type == "all" ){		
		document.all.MediaPlayer.style.display = "block";
		//if ( document.getElementById("kProgressbarEmpty")){document.getElementById("kProgressbarEmpty").style.display = "none";}
		//if (document.getElementById("kProgressbar")){document.getElementById("kProgressbar").style.display = "block";}		
		document.getElementById("divPlayNow").style.display = "block";
		if (lastHighlight !== undefined && lastHighlight != ""){
			if (document.getElementById(lastHighlight)) { 
				document.getElementById(lastHighlight).style.background = 'url(' + skinFolder + '/images/listing_bg.gif)'; 
				var tmpStarArray = lastHighlight.split("Asset");
				var lastNo = tmpStarArray[1];
			}
		}
		var highlightDivName = 'playlistAsset' + global_playlist_cursor;
		document.getElementById(highlightDivName).style.background = 'url(' + skinFolder + '/images/listing_bg_02.gif)';
		lastHighlight = highlightDivName;		
		var assetTags = arryActivePlaylistAsset[global_playlist_cursor].assetTags;
		var assetViewed = arryActivePlaylistAsset[global_playlist_cursor].assetViewed;
		var assetRating = arryActivePlaylistAsset[global_playlist_cursor].assetRating;
						  
		if (assetTags != ""){
			var txtTags = '<font color="#FFFFFF">Tags:</font>&nbsp;';
		}
		else{
			var txtTags = '';
		}
		var ArrayassetTags = assetTags.split(",");
		var theTagLink = "";				
		for (var x=0; x < ArrayassetTags.length; x++){
			theTagLink += '<a style="cursor:pointer" onClick="goTagSearch(\'' + ArrayassetTags[x] + '\', \'' + arryActivePlaylistAsset[global_playlist_cursor].assetId + '\' );">' + ArrayassetTags[x] + '</a>';
			if (x != eval(ArrayassetTags.length - 1)){ theTagLink += ", "; }
		}
				

		var theRateFunc = '<div id="divRateThisAsset"><table class="style9" border=0 cellspacing=0 cellpadding=0><tr><td>Rate this video : ' +
				'<a style="cursor:pointer" onClick="goRateVideo(\'' + arryActivePlaylistAsset[global_playlist_cursor].assetId + '\',\'1\');"><img align="absmiddle" src="' + skinFolder + '/images/star2b.gif" name="rate1" width="14" height="14" border="0" id="Image2"  onMouseOver="ratingState(1); MM_swapImage(\'rate1\',\'\',\'' + skinFolder + '/images/star2.gif\',1)" onMouseOut="ratingState(0); MM_swapImgRestore()" /></a>' +
				'<a style="cursor:pointer" onClick="goRateVideo(\'' + arryActivePlaylistAsset[global_playlist_cursor].assetId + '\',\'2\');"><img align="absmiddle" src="' + skinFolder + '/images/star2b.gif" name="rate2" width="14" height="14" border="0" id="Image21" onMouseOver="ratingState(2); MM_swapImage(\'rate1\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate2\',\'\',\'' + skinFolder + '/images/star2.gif\',1)" onMouseOut="ratingState(0); MM_swapImgRestore()" /></a>' +
				'<a style="cursor:pointer" onClick="goRateVideo(\'' + arryActivePlaylistAsset[global_playlist_cursor].assetId + '\',\'3\');"><img align="absmiddle" src="' + skinFolder + '/images/star2b.gif" name="rate3" width="14" height="14" border="0" id="Image22" onMouseOver="ratingState(3); MM_swapImage(\'rate1\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate2\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate3\',\'\',\'' + skinFolder + '/images/star2.gif\',1)" onMouseOut="ratingState(0); MM_swapImgRestore()" /></a>' +
				'<a style="cursor:pointer" onClick="goRateVideo(\'' + arryActivePlaylistAsset[global_playlist_cursor].assetId + '\',\'4\');"><img align="absmiddle" src="' + skinFolder + '/images/star2b.gif" name="rate4" width="14" height="14" border="0" id="Image23" onMouseOver="ratingState(4); MM_swapImage(\'rate1\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate2\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate3\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate4\',\'\',\'' + skinFolder + '/images/star2.gif\',1)" onMouseOut="ratingState(0); MM_swapImgRestore()" /></a>' +
				'<a style="cursor:pointer" onClick="goRateVideo(\'' + arryActivePlaylistAsset[global_playlist_cursor].assetId + '\',\'5\');"><img align="absmiddle" src="' + skinFolder + '/images/star2b.gif" name="rate5" width="14" height="14" border="0" id="Image24" onMouseOver="ratingState(5); MM_swapImage(\'rate1\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate2\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate3\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate4\',\'\',\'' + skinFolder + '/images/star2.gif\',\'rate5\',\'\',\'' + skinFolder + '/images/star2.gif\',1)" onMouseOut="ratingState(0); MM_swapImgRestore()" /></a>' +
				'</td><td><div id=divRateState>&nbsp;</div></td></tr></table></div>' +
				'<div id="divRateThisAsset2" class="style11" style="display:none">submitting...</div>' +
				'<div id="divRateThisAsset3" class="style11" style="display:none">Thank you for rating.</div>' +
				'<div id="divDisplayRatedAsset" class="style9" style="display:none"></div>' +				
				'<div id="divRateThisAsset4" class="pl_notify" style="display:none">Please login to rate video.</div>' +
				'<div id="divRateThisAssetAlready" class="pl_notify" style="display:none">You already rate this video today.</div>';		
		
		var theContent = '<table  align="center" width="100%" background="' + skinFolder + '/images/playing_default.gif" height="277" border="0" cellpadding="7" cellspacing="0"><tr><td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'<tr><td colspan="2"><span class="style6">' + arryActivePlaylistAsset[global_playlist_cursor].assetTitle + '</span></td></tr><tr><td width="235"><span class="style7">' + arryActivePlaylistAsset[global_playlist_cursor].assetGenre + '</span></td>' +
		'<td align="right">' + displayStarRating2(arryActivePlaylistAsset[global_playlist_cursor].assetRating) + '</td></tr><tr><td height="5" colspan="2"></td></tr><tr><td colspan="2"><div style="height:55; width:100%; overflow:auto" class="style9">' + arryActivePlaylistAsset[global_playlist_cursor].assetSynopsis + '</div></td>' +
		'</tr><tr><td height="5" colspan="2"></td></tr><tr><td colspan="2"><div style="height:40; width:100%; overflow:auto" class="style11"> ' + txtTags + theTagLink + '</div></td>' +
		'</tr><tr><td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td>' +
		'<a style="cursor:pointer" onClick="shareNow(\'' + arryActivePlaylistAsset[global_playlist_cursor].assetId + '\');"><img src="' + skinFolder + '/images/playing_share.gif" alt="share this video" width="112" height="19" border=0 /></a></td><td align="right"><span class="style7">' + arryActivePlaylistAsset[global_playlist_cursor].assetLengthMinutes + ' Minute(s) | Views: ' + arryActivePlaylistAsset[global_playlist_cursor].assetViewed + '</span></td>' +
		'</tr></table></td></tr><tr><td height="5" colspan="2"></td></tr><tr><td class="style9" colspan="2" height="14">' +
		theRateFunc + '</td></tr></table></td></tr><tr><td align="center" valign=bottom>' +
		'<div id="divBannerPreRoll" style="height:61px; width:288px; overflow:hidden; background-color: #CCCCCC;"></div></td></tr></table>';

		// new content
		var theContent = '<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"' + skinFolder + '/images/index_31.gif\">\
  <tr>\
	<td colspan=\"2\" rowspan=\"2\" valign=\"top\">&nbsp;</td>\
	<td width=\"55\" height=\"16\"></td>\
	<td width=\"57\"></td>\
	<td width=\"151\"></td>\
	<td colspan=\"2\" rowspan=\"2\" valign=\"top\">&nbsp;</td>\
  </tr>\
  <tr>\
	<td height=\"122\" colspan=\"3\" valign=\"top\"><p><span class=\"style8\">' + arryActivePlaylistAsset[global_playlist_cursor].assetTitle + '</span><br>\
		  <span class=\"style2\">' + arryActivePlaylistAsset[global_playlist_cursor].assetGenre + '</span></p><p class=\"style9\" style=\"height:70; width:100%; overflow:auto; \">' + arryActivePlaylistAsset[global_playlist_cursor].assetSynopsis + '</p></td>\
  </tr>\
  <tr>\
	<td width=\"6\" height=\"8\"></td>\
	<td width=\"11\"></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td width=\"11\"></td>\
	<td width=\"7\"></td>\
  </tr>\
  <tr>\
	<td height=\"13\"></td>\
	<td></td>\
	<td colspan=\"5\" valign=\"top\">' + theRateFunc + '</td>\
  </tr>\
  <tr>\
	<td height=\"24\"></td>\
	<td></td>\
	<td>&nbsp;</td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
  </tr>\
  <tr>\
	<td height=\"24\"></td>\
	<td></td>\
	<td colspan=\"3\" valign=\"top\" class=\"style7\">' + txtTags + theTagLink + ' </td>\
	<td></td>\
	<td></td>\
  </tr>\
  <tr>\
	<td height=\"5\"></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
  </tr>\
  <tr>\
	<td height=\"19\"></td>\
	<td></td>\
	<td colspan=\"2\" valign=\"top\"><a style=\"cursor:pointer\" onClick=\"shareNow(\'' + arryActivePlaylistAsset[global_playlist_cursor].assetId + '\');\"><img src=\"' + skinFolder + '/images/buttons/btn_sharevideo.gif\" alt=\"share this video\" width=\"112\" height=\"19\" border=0 /></a></td>\
	<td>&nbsp;</td>\
	<td></td>\
	<td></td>\
  </tr>\
  <tr>\
	<td height=\"23\"></td>\
	<td></td>\
	<td>&nbsp;</td>\
	<td></td>\
	<td></td>\
	<td></td>\
	<td></td>\
  </tr>\
  <tr>\
	<td rowspan=\"2\" valign=\"top\">\
	  <img src=\"' + skinFolder + '/images/index_37.gif\" width=\"6\" height=\"63\" alt=\"\"></td>\
<td height=\"58\" colspan=\"5\" valign=\"top\">\
	<div id="divBannerPreRoll" style="height:61px; width:288px; overflow:hidden; background-color: #CCCCCC;"></div></td>\
<td rowspan=\"2\" valign=\"top\">\
	<img src=\"' + skinFolder + '/images/index_39.gif\" width=\"7\" height=\"63\" alt=\"\"></td>\
</tr>\
  <tr>\
	<td height=\"5\" colspan=\"5\" valign=\"top\">\
	  <img src=\"' + skinFolder + '/images/index_52.gif\" width=\"285\" height=\"5\" alt=\"\"></td>\
  </tr>\
</table>\
';

		document.getElementById('divPlayNow').innerHTML = theContent;				
	}
}
function playMediaPlayer(){
	if ( global_state == "paused" ){
		document.MediaPlayer.controls.play();
		document.getElementById("divPauseBtn").style.display = "block";
		document.getElementById("divPlayBtn").style.display = "none";
	} 
	else if(global_state == "playing"){
		pauseMediaPlayer();
	} 
	else if((global_state == "ended") && (global_play_type == "single") ){
		if ( document.getElementById("videoStop")){
			document.all.videoStop.style.display='none';
			document.all.MediaPlayer.style.display = 'block';		
			//if ( document.getElementById("kProgressbarEmpty")){document.getElementById("kProgressbarEmpty").style.display = "none";}
			//if (document.getElementById("kProgressbar")){document.getElementById("kProgressbar").style.display = "block";}
			document.MediaPlayer.controls.play();			
			document.getElementById("divPauseBtn").style.display = "block";
			document.getElementById("divPlayBtn").style.display = "none";
		}
	} 
	else if ( global_state == "stopped" ){
		document.MediaPlayer.controls.play();		
		document.getElementById("divPauseBtn").style.display = "block";
		document.getElementById("divPlayBtn").style.display = "none";
	}
}
function stopMediaPlayer(){
	document.MediaPlayer.controls.stop();
	global_state_stop = true;	
	document.getElementById("divPauseBtn").style.display = "none";
	document.getElementById("divPlayBtn").style.display = "block";
	global_state = "stopped";
}
function pauseMediaPlayer(){
	document.getElementById("divPauseBtn").style.display = "none";
	document.getElementById("divPlayBtn").style.display = "block";		
	document.MediaPlayer.controls.pause();	
}
function resumeMediaPlayer(){
	document.MediaPlayer.controls.play();
	document.getElementById("divPauseBtn").style.display = "block";
	document.getElementById("divPlayBtn").style.display = "none";
}
function muteMediaPlayer(){
	if(document.MediaPlayer.settings.mute){
		document.MediaPlayer.settings.mute = false;
		document.getElementById("volumeOn").style.display = "block";
		document.getElementById("volumeOff").style.display = "none";			
	} else{
		document.MediaPlayer.settings.mute = true;		
		document.getElementById("volumeOn").style.display = "none";
		document.getElementById("volumeOff").style.display = "block";		
	}
}
function showFullscreen(){
	var mpStatus = document.MediaPlayer.status;
	myRegExp = new RegExp("Playing");
	if ( mpStatus.match(myRegExp) ){
		showFullscreenMsg();
		setTimeout("mediaPlayerFullscreen()",2000);
	}
}
function mediaPlayerFullscreen(){
	document.getElementById("MediaPlayer").style.display = "block";
	//if ( document.getElementById("kProgressbarEmpty")){document.getElementById("kProgressbarEmpty").style.display = "none";}
	//if (document.getElementById("kProgressbar")){document.getElementById("kProgressbar").style.display = "block";}
	document.all.divViewFullscreen.style.display='none';		
	document.MediaPlayer.fullScreen = true;
}
function showFullscreenMsg(){	
	htmlOutput = '\
	<table width="320" height="240" border="0" cellpadding="0" cellspacing="0" background="' + skinFolder + '/images/video_blank.gif">\
	  <tr>\
		<td width="65" height="50">&nbsp;</td>\
		<td width="177">&nbsp;</td>\
		<td width="78">&nbsp;</td>\
	  </tr>\
	  <tr>\
		<td height="115"></td>\
		<td valign="top"><span class="style19" align="justify"><br/><br/>Entering fullscreen mode.<br/><br/>Please < ESC > to return to this screen.</span></td>\
		<td></td>\
	  </tr>\
	  <tr>\
		<td height="75"></td>\
		<td>&nbsp;</td>\
		<td></td>\
	  </tr>\
	</table>\
		';
	document.getElementById("MediaPlayer").style.display = "none";
	//if ( document.getElementById("kProgressbarEmpty")){document.getElementById("kProgressbarEmpty").style.display = "block";}
	//if (document.getElementById("kProgressbar")){document.getElementById("kProgressbar").style.display = "none";};
	if( document.getElementById("divViewFullscreen").innerHTML == "" ){
		WriteLayer('divViewFullscreen',null,htmlOutput);	
		document.all.divViewFullscreen.style.display='block';		
	}
	else{
		document.all.divViewFullscreen.style.display='block';		
	}	
}
function showVideoStopAction(){
	document.getElementById("divNotAuthorized").style.display = "none";
	document.getElementById("divPauseBtn").style.display = "none";
	document.getElementById("divPlayBtn").style.display = "block";
	htmlOutput = '\
		<table width="320" height="240" border="0" cellpadding="0" cellspacing="0" background="' + skinFolder + '/images/video_blank.gif">\
		  <tr>\
			<td width="75" height="80">&nbsp;</td>\
			<td width="157">&nbsp;</td>\
			<td width="88">&nbsp;</td>\
		  </tr>\
		  <tr>\
			<td height="28"></td>\
			<td valign="top"><a style="cursor:pointer;" onClick="replayNow();"><img src="' + skinFolder + '/images/video_replay.gif" width="157" height="27" border="0" /></a></td>\
			<td></td>\
		  </tr>\
		  <tr>\
			<td height="10"></td>\
			<td></td>\
			<td></td>\
		  </tr>\
		  <tr>\
			<td height="27"></td>\
			<td valign="top"><a style="cursor:pointer;" onClick="reshareNow();"><img src="' + skinFolder + '/images/video_share.gif" width="157" height="27" border="0" /></a></td>\
			<td></td>\
		  </tr>\
		  <tr>\
			<td height="95"></td>\
			<td>&nbsp;</td>\
			<td></td>\
		  </tr>\
		</table>\
			';
	document.getElementById("MediaPlayer").style.display = "none";
	//if ( document.getElementById("kProgressbarEmpty")){document.getElementById("kProgressbarEmpty").style.display = "block";}
	//if (document.getElementById("kProgressbar")){document.getElementById("kProgressbar").style.display = "none";};
	if ( document.getElementById("videoStop").innerHTML == "" ){
		WriteLayer('videoStop',null,htmlOutput);	
		document.all.videoStop.style.display='block';		
	} 
	else{
		document.all.videoStop.style.display='block';		
	}
}
function replayNow(){
	document.all.videoStop.style.display='none';
	document.all.MediaPlayer.style.display='block';	
	//if ( document.getElementById("kProgressbarEmpty")){document.getElementById("kProgressbarEmpty").style.display = "none";}
	//if (document.getElementById("kProgressbar")){document.getElementById("kProgressbar").style.display = "block";}
	if ( global_play_type == "single" ){
		// where is this function izura?
		//playNow('user',currentlyPlayingId,currentlyPlayingArray);
			playMediaPlayer();
	} 
	else{
		playAll(arryActivePlaylistAsset);
	}
}
function reshareNow(){
	document.all.videoStop.style.display='none';
	shareNow(currentlyPlayingId);
}
function checkUserAuthorization(assetLevel){
	var reason = "";
	if ( assetLevel == "4" ){ 
		if (getCookie("loginid") == ""){
			reason = "This video is for astro sport subscriber only.";
			showUserNotAuthorized(reason);
			return false;
		} 
		else{
			if( getCookie("level") != assetLevel ){
				reason = "This video is for astro sport subscriber only.";
				showUserNotAuthorized(reason);
				return false;
			} 
		}
	}
	else if (assetLevel == "3"){ 
		if (getCookie("loginid") == "") 
		{
			reason = "This video is for subscriber only.";
			showUserNotAuthorized(reason);
			return false;
		} 
		else{
			if ((getCookie("level") == "3")  || (getCookie("level") == "4")){}
			else{
				reason = "This video is for subscriber only.";
				showUserNotAuthorized(reason);
				return false;
			} 
		}
	}
	else if(assetLevel == "2"){
		if (getCookie("loginid") == ""){
			reason = "NOTLOGIN";
			showUserNotAuthorized(reason);
			return false;
		}		
	}	
	return true;	
}
function showUserNotAuthorized(reason){
	if (reason == "NOTLOGIN"){		
	htmlOutput = '\
		<table width="320" height="240" border="0" cellpadding="0" cellspacing="0" background="' + skinFolder + '/images/video_blank.gif">\
		  <tr>\
			<td width="65" height="50">&nbsp;</td>\
			<td width="177">&nbsp;</td>\
			<td width="78">&nbsp;</td>\
		  </tr>\
		  <tr>\
			<td height="115"></td>\
			<td valign="top"><span class="style19" align="justify">Sorry. Please log in.</td>\
			<td></td>\
		  </tr>\
		  <tr>\
			<td height="75"></td>\
			<td align="right" valign="top"><span class="style19"><a style="cursor:hand;" onclick="hideUserNotAuthorized()">close</a></span></td>\
			<td></td>\
		  </tr>\
		</table>\
			';			
	}
	else if(reason == "This video is for astro sport subscriber only."){
	htmlOutput = '\
		<table width="320" height="240" border="0" cellpadding="0" cellspacing="0" background="' + skinFolder + '/images/video_blank.gif">\
		  <tr>\
			<td width="65" height="50">&nbsp;</td>\
			<td width="177">&nbsp;</td>\
			<td width="78">&nbsp;</td>\
		  </tr>\
		  <tr>\
			<td height="115"></td>\
			<td valign="top"><span class="style19" align="justify">Sorry. You are only allowed to view this video or channel if you are also an astro sport subscriber. <br><br>Please visit Astro.com.my or call our customer service to upgrade.</td>\
			<td></td>\
		  </tr>\
		  <tr>\
			<td height="75"></td>\
			<td align="right" valign="top"><span class="style19"><a style="cursor:hand;" onclick="hideUserNotAuthorized()">close</a></span></td>\
			<td></td>\
		  </tr>\
		</table>\
			';			
	}
	else if(reason == "This video is for subscriber only."){		
	htmlOutput = '\
		<table width="320" height="240" border="0" cellpadding="0" cellspacing="0" background="' + skinFolder + '/images/video_blank.gif">\
		  <tr>\
			<td width="65" height="50">&nbsp;</td>\
			<td width="177">&nbsp;</td>\
			<td width="78">&nbsp;</td>\
		  </tr>\
		  <tr>\
			<td height="115"></td>\
			<td valign="top"><span class="style19" align="justify">Sorry. You are only allowed to view this video or channel if you are also a subscriber to the corresponding Astro package. <br><br>Please visit Astro.com.my or call our customer service to upgrade.</td>\
			<td></td>\
		  </tr>\
		  <tr>\
			<td height="75"></td>\
			<td align="right" valign="top"><span class="style19"><a style="cursor:hand;" onclick="hideUserNotAuthorized()">close</a></span></td>\
			<td></td>\
		  </tr>\
		</table>\
			';			
	}	
	if ( document.getElementById("MediaPlayer")){
		document.getElementById("MediaPlayer").style.display = "none";
		//if ( document.getElementById("kProgressbarEmpty")){document.getElementById("kProgressbarEmpty").style.display = "block";}
		//if (document.getElementById("kProgressbar")){document.getElementById("kProgressbar").style.display = "none";};		
	}	
	if ( document.getElementById("videoStop") ){
		document.getElementById("videoStop").style.display = "none";
	}	
	if ( document.getElementById("divNotAuthorized").innerHTML == "" ){
		WriteLayer('divNotAuthorized',null,htmlOutput);	
	} 
	else{
		document.all.divNotAuthorized.style.display='block';	
	}	
}
function hideUserNotAuthorized(){
	document.getElementById("divNotAuthorized").style.display="none";
	if ( document.getElementById("videoStop") ){
		if ( global_state == "ended" ){
			document.getElementById("videoStop").style.display = "block";
		}
	}
	if ( (document.getElementById("MediaPlayer")) && ( (global_state == "playing") || (global_state == "paused") || (global_state == "stopped") ) ) {
		document.getElementById("MediaPlayer").style.display = "block";
		//if (document.getElementById("kProgressbar")){document.getElementById("kProgressbar").style.display = "block";}
		//if ( document.getElementById("kProgressbarEmpty")){document.getElementById("kProgressbarEmpty").style.display = "none";}
	}	
	if ( (document.getElementById("MediaPlayer")) && (global_state == "") ) {
		document.getElementById("MediaPlayer").style.display = "block";
		//if ( document.getElementById("kProgressbarEmpty")){document.getElementById("kProgressbarEmpty").style.display = "none";}
		//if (document.getElementById("kProgressbar")){document.getElementById("kProgressbar").style.display = "block";}
	}
	return;
}
function showPositionInfo(){
if ((document.MediaPlayer.currentMedia.durationString != undefined)&&(document.MediaPlayer.currentMedia.durationString != null)){
	var clipDuration = ' / ' + document.MediaPlayer.currentMedia.durationString;
	if ( document.MediaPlayer.controls.currentPositionString == "" ){
		clipDuration = "";
	}
	document.getElementById('timeElapsed').innerHTML = document.MediaPlayer.controls.currentPositionString + clipDuration;
	var currentSliderPos = getNaturalTime(document.MediaPlayer.controls.currentPositionString);
	//window.status = getNaturalTime(document.MediaPlayer.controls.currentPositionString);
	//alert(currentSliderPos);
	if (document.getElementById("MediaPlayer").style.display != "none"){
		if (document.getElementById("kProgressbarEmpty")){document.getElementById("kProgressbarEmpty").style.display = "none";}
		if (document.getElementById("kProgressbar")){document.getElementById("kProgressbar").style.display = "block";}
	}else{
		if (document.getElementById("kProgressbarEmpty")){document.getElementById("kProgressbarEmpty").style.display = "block";}
		if (document.getElementById("kProgressbar")){document.getElementById("kProgressbar").style.display = "none";};
	}
	setSliderValue(slider1,currentSliderPos);
}
}

// change the clip position
function changeClipPosition(markerPosition) {
	// get full media length
	var clipDuration = document.MediaPlayer.currentMedia.duration;
	var newPosition = markerPosition * clipDuration;
	// change the current position
	document.MediaPlayer.controls.currentPosition = newPosition;
	document.getElementById("divPauseBtn").style.display = "block";
	document.getElementById("divPlayBtn").style.display = "none";
}

// convert hh:mm:ss or mm:ss to seconds
function getNaturalTime(myTime) {
	
	
	var naturalTime;
	var natHour;
	var natMinute;
	var natSec;
	var tempArray = myTime.split(":");
	
	// check element
	if ( tempArray.length == "3" ) {
		
		// contains hh:mm:ss
		natHour = parseInt(tempArray[0],10)*60*60;
		natMinute = parseInt(tempArray[1],10)*60;
		natSec = parseInt(tempArray[2],10);

		naturalTime = natHour + natMinute + natSec;
		
	} else if ( tempArray.length == "2" ) {
		// contains mm:ss
		natMinute = parseInt(tempArray[0],10)*60;
		natSec = parseInt(tempArray[1],10);
		naturalTime = natMinute + natSec;
		
	}
	
	return naturalTime;
}

// update the slider position
function setSliderValue(slider, value) {
	if (value == '') return;
	
	if (isNaN(value)) {
		slider.setValue(0);
	} else {
		//slider.setValue(value/100);
		slider.setValue(value/document.MediaPlayer.currentMedia.duration);
	}
}

// change volume position
function changeVolumePosition(markerPosition) {
	// get full media length
	var newMarkerPosition = (markerPosition*100).toFixed();
	// change the current position
	document.MediaPlayer.settings.volume = newMarkerPosition;
}

// update the slider position
function setVolumeSliderValue(slider, value) {
	if (value == '') return;
	
	if (isNaN(value)) {
		slider.setValue(0);
	} else {
		slider.setValue(value/100);
	}
}
/*
 * Title	: window onload events functions for all browsers
 * Date		: 26/12/2007
 * Author	: Mohd Remi Asmuni (remiglobal@gmail.com)
 * Notes	: million thanks to Dean Edwards/Matthias Miller/John Resig
 */
function init() 
{	
  // quit if this function has already been called
  if (arguments.callee.done) return;
  // flag this function so we don't do the same thing twice
  arguments.callee.done = true;
  // kill the timer
  if (_timer) clearInterval(_timer);
  /* start of customized onload codes */
	//directPlay(); 	
   /* end of customized onload codes */
};
/* for Mozilla/Opera9 */
if (document.addEventListener) 
{
  document.addEventListener("DOMContentLoaded", init, false);
}
/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
  document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
  var script = document.getElementById("__ie_onload");
  script.onreadystatechange = function() {
    if (this.readyState == "complete") {
      init(); // call the onload handler
    }
  };
/*@end @*/
/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
  var _timer = setInterval(function() {
    if (/loaded|complete/.test(document.readyState)) {
      init(); // call the onload handler
    }
  }, 10);
}
/* for other browsers */
window.onload = init;