var searchAssetArray,tmpsearchString,tmprecordLimit,tmpmediaLanguageCode,tmpsortBy,tmpAsc,retrygetSearchAssets=5;
function getSearchAssets(searchString,recordLimit,mediaLanguageCode,sortBy,Asc){	
	document.getElementById("searchTerm").innerHTML = "";
	tmpsearchString = searchString;
	tmprecordLimit = recordLimit;
	tmpmediaLanguageCode = mediaLanguageCode;
	tmpsortBy = sortBy;
	tmpAsc = Asc;
	searchAssetArray = new Array();
    var soapMessage;	
	myXMLSearch = new ActiveXObject("Microsoft.XMLHTTP");	
	var WsUrl = addrWebServices;      
	var webMethod="searchAsset"; 	
	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 += "	<searchString>"+ searchString +"</searchString>";
	soapMessage += "	<recordLimit>"+ recordLimit +"</recordLimit>";
	soapMessage += "	<mediaLanguageCode>"+ mediaLanguageCode +"</mediaLanguageCode>";
	soapMessage += "	<sortBy>"+ sortBy +"</sortBy>";	
	soapMessage += "	<Asc>"+ Asc +"</Asc>";		
	soapMessage += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";
	myXMLSearch.onreadystatechange = getSearchAssetsCallback;
	myXMLSearch.Open("POST",WsUrl, true);        
	myXMLSearch.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	myXMLSearch.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	myXMLSearch.send(soapMessage);}
function getSearchAssetsCallback(){
	if(myXMLSearch.readyState == 4){
		var htmlOutput = "";
		if(myXMLSearch.status == 200){    
			var x = myXMLSearch.responseXML;
			var xx = x.childNodes[1].xml;
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");
			var root = xmlObject.getElementsByTagName('assets')[0];
			var assets = root.getElementsByTagName("asset");
			if((root==null)||(assets.length==0)){
				htmlOutput = "<span class=\"style33\"><br>&nbsp;&nbsp;&nbsp;Sorry, your search did not match any videos.</span>";
				WriteLayer('displayAllAssetsSearch',null,htmlOutput);
				WriteLayer('allTrailSearch',null,'');
				WriteLayer('previousNextSearch',null,'');
				return;}
			var assetId, assetImage, assetVideo, assetTitle, assetLengthMinutes, assetSynopsis, assetTags, assetViewed, assetRating, assetLevel,  programmeId, assetGenre;			
			for (var i = 0 ; i < assets.length ; i++){
				asset = assets[i];
				assetId =  asset.getAttribute("assetId");
				assetImage =  asset.getElementsByTagName("assetImage")[0].firstChild.nodeValue;
				assetVideo =  asset.getElementsByTagName("assetVideo")[0].firstChild.nodeValue;					
				if( asset.getElementsByTagName("assetTitle")[0].firstChild){
					assetTitle =  asset.getElementsByTagName("assetTitle")[0].firstChild.nodeValue;} 
				else{assetTitle = "";}				
				assetLengthMinutes =  asset.getElementsByTagName("assetLengthMinutes")[0].firstChild.nodeValue;											
				if(asset.getElementsByTagName("assetSynopsis")[0]){
					assetSynopsis =  asset.getElementsByTagName("assetSynopsis")[0].firstChild.nodeValue;} 
				else{assetSynopsis = "";}
				if(asset.getElementsByTagName("assetTags")[0]){
					assetTags =  asset.getElementsByTagName("assetTags")[0].firstChild.nodeValue;}
				else{assetTags = "";}
				assetViewed =  asset.getElementsByTagName("assetViewed")[0].firstChild.nodeValue;
				if(asset.getElementsByTagName("assetRating")[0].firstChild){
					assetRating =  asset.getElementsByTagName("assetRating")[0].firstChild.nodeValue;} 
				else{assetRating = "";}
				if(asset.getElementsByTagName("assetViewerCategory")[0]){
					assetLevel =  asset.getElementsByTagName("assetViewerCategory")[0].firstChild.nodeValue;}
				else{assetLevel = "0";}
				programmeId = asset.getElementsByTagName("assetProgrammeId")[0].firstChild.nodeValue;
				if(asset.getElementsByTagName("assetGenre")[0]){
					assetGenre =  asset.getElementsByTagName("assetGenre")[0].firstChild.nodeValue;} 
				else{assetGenre = "Watch Video";}			
				global_tab = "search";
				addSearchAsset( assetId, assetImage, assetVideo, assetTitle, assetLengthMinutes, assetSynopsis, assetTags, assetViewed, assetRating, assetLevel, programmeId, assetGenre);}
  			displaySearch('allTrailSearch','displayAllAssetsSearch','searchAssetArray','8','0');} 
		else{
			if (retrygetSearchAssets >0){
				retrygetSearchAssets -= 1;
				getSearchAssets( tmpsearchString, tmprecordLimit, tmpmediaLanguageCode, tmpsortBy, tmpAsc );}
			else{
				tmpsearchString = "";
				tmprecordLimit = "";
				tmpmediaLanguageCode = "";
				tmpsortBy = "";
				tmpAsc = "";
				retrygetSearchAssets = 5;
				htmlOutput = "<span class=\"style33\"><br>&nbsp;&nbsp;&nbsp;Error loading your search results, please try again later...</span>";
				WriteLayer('displayAllAssetsSearch',null,htmlOutput);}}}}
function searchNow(){	
	pageScroll('550');
	MM_showHideLayers('tabprogram','','hide','tabsearch','','show','apDiv3','','show','apDiv4','','hide');
	WriteLayer('displayAllAssetsSearch',null,"");		
	WriteLayer('previousNextSearch',null,"");		
	WriteLayer('allTrailSearch',null,"");	
	var searchInput0 = document.getElementById("searchInput0").value;
	if ( searchInput0.length < 3 ){
		alert("You must enter at least 3 characters");
		document.getElementById("searchInput0").focus();
		return;
	}	
	var searchLang = "all";
	var searchLimit = "500";
	getSearchAssets( searchInput0, searchLimit, searchLang,'date','false');
	htmlOutput = "<span class=\"style33\"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"" + skinFolder + "/images/load.gif\" width=\"10\" height=\"10\" align=\"absmiddle\">&nbsp;Loading results...</span>";
	WriteLayer('displayAllAssetsSearch',null,htmlOutput);	
	document.getElementById("searchInput1").value = searchInput0;
	document.getElementById("searchInput1").focus();
}
function searchNow2(searctTag){
	pageScroll('550');
	MM_showHideLayers('tabprogram','','hide','tabsearch','','show','apDiv3','','show','apDiv4','','hide');
	htmlOutput = "<span class=\"style33\"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"" + skinFolder + "/images/load.gif\" width=\"10\" height=\"10\" align=\"absmiddle\">&nbsp;Loading search results...</span>";	
	WriteLayer('displayAllAssetsSearch',null,htmlOutput);		
	WriteLayer('previousNextSearch',null,"");		
	WriteLayer('allTrailSearch',null,"");			
	document.getElementById("searchInput1").value = searctTag;
	document.getElementById("searchInput1").focus();	
}
function getSearchResults(){
	var searchInput = document.getElementById("searchInput1").value;
	var searchLang = document.getElementById("searchLang").value;	
	if ( searchInput.length < 3 ){
		alert("You must enter at least 3 characters");
		return;
	}	
	WriteLayer('displayAllAssetsSearch',null,"");		
	WriteLayer('previousNextSearch',null,"");		
	WriteLayer('allTrailSearch',null,"");			
	var searchLimit = "500";
	getSearchAssets( searchInput, searchLimit, searchLang,'date','false');
	htmlOutput = "<span class=\"style33\"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"" + skinFolder + "/images/load.gif\" width=\"10\" height=\"10\" align=\"absmiddle\">&nbsp;Loading results...</span>";
	WriteLayer('displayAllAssetsSearch',null,htmlOutput);
}
function sortByDate(){
	tmpsortBy = "date";	
	tmpAsc = "false";
	getSearchAssets( tmpsearchString, tmprecordLimit, tmpmediaLanguageCode, tmpsortBy, tmpAsc );
	htmlOutput = "<span class=\"style33\"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"" + skinFolder + "/images/load.gif\" width=\"10\" height=\"10\" align=\"absmiddle\">&nbsp;Loading results...</span>";
	WriteLayer('displayAllAssetsSearch',null,htmlOutput);
}
function sortByRating(){
	tmpsortBy = "rating";	
	tmpAsc = "false";
	getSearchAssets( tmpsearchString, tmprecordLimit, tmpmediaLanguageCode, tmpsortBy, tmpAsc );
	htmlOutput = "<span class=\"style33\"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"" + skinFolder + "/images/load.gif\" width=\"10\" height=\"10\" align=\"absmiddle\">&nbsp;Loading results...</span>";
	WriteLayer('displayAllAssetsSearch',null,htmlOutput);	
}
function sortByViews(){
	tmpsortBy = "view";
	tmpAsc = "false";
	getSearchAssets( tmpsearchString, tmprecordLimit, tmpmediaLanguageCode, tmpsortBy, tmpAsc );
	htmlOutput = "<span class=\"style33\"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"" + skinFolder + "/images/load.gif\" width=\"10\" height=\"10\" align=\"absmiddle\">&nbsp;Loading results...</span>";
	WriteLayer('displayAllAssetsSearch',null,htmlOutput);
}
var cpanelState = "close";
function displayControlPanel(){
	if(cpanelState == "close"){
		cpanelState = "open";
		openControlPanel();} 
	else{
		cpanelState = "close";		
		closeControlPanel();}}
function openControlPanel(){
	if(global_state == "playing"){
		pauseMediaPlayer();
		document.all.MediaPlayer.style.display = 'none';}
		else if(global_state == "paused"){
		document.all.MediaPlayer.style.display = 'none';} 
		else if(global_state == "stopped"){
		document.all.MediaPlayer.style.display = 'none';}
	if(getCookie("loginid")==""){ 
		document.all.cpanelLoginPrompt.style.visibility = 'visible';} 
	else{
		document.all.cpanelLoginPrompt.style.visibility = 'hidden';
		document.getElementById('comments').style.visibility = 'visible';
		document.getElementById('comments-centered').style.visibility = 'visible';}}
function closeControlPanel(){
	if(globalPage != "home"){
		if(global_state == "playing"){
			resumeMediaPlayer();
			document.all.MediaPlayer.style.display = 'block';} 
		else if(global_state == "paused"){
			document.all.MediaPlayer.style.display = 'block';			
			resumeMediaPlayer();}
		else if(global_state == "stopped"){
			document.all.MediaPlayer.style.display = 'block';}}	
	document.all.cpanelLoginPrompt.style.visibility = 'hidden';	
	document.getElementById('comments').style.visibility = "hidden";
	document.getElementById('comments-centered').style.visibility = "hidden";}
function subscribeNewsletter(){
	var name = getCookie("loginid");
	var email = getCookie("email");	
	//var remoteURL = "http://www.epass.com.my/cgi-bin/epass/v4/email/inc_astrotv_newsletter.asp";
	var remoteURL = "asp/newsletter.asp"
	var auth = "1";
	var postr = "loginid='"+ loginid + "'&email='" + email +"'&auth='"+auth+"'";
	postNewsletterRequest(remoteURL,postr);}
function postNewsletterRequest(remoteURL,postr){
	postNewsletterReq = new ActiveXObject("Microsoft.XMLHTTP");
	postNewsletterReq.Open("POST",remoteURL, true);    	
	postNewsletterReq.onreadystatechange = postNewsletterReqCallback;
	postNewsletterReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	postNewsletterReq.setRequestHeader("Content-length", postr.length);
	postNewsletterReq.setRequestHeader("Connection", "close");
	postNewsletterReq.send(postr);}
function postNewsletterReqCallback(){
	if (postNewsletterReq.readyState == 4){
		var htmlOutput = "";
		if (postNewsletterReq.status == 200){ 
			var newsletterResponse = postNewsletterReq.responseText;  
			if (newsletterResponse == "cun"){}}
		else{}}}
function postFeedback(feedback){
	var name = getCookie("name");
	var email = getCookie("email");	
	//var remoteURL = "http://www.ampradio.net/cgi-bin/astrotv/feedback/inc_submit.asp";
	var remoteURL = "asp/feedback.asp";
	var postr = "name='" + encodeURIComponent(name) + "'&email='"+encodeURIComponent(email)+"'&feedback='"+encodeURIComponent(feedback)+"'";
	postFeedbackRequest( remoteURL, postr );}
function postFeedbackRequest(remoteURL, postr ){
	postFeedbackReq = new ActiveXObject("Microsoft.XMLHTTP");
	postFeedbackReq.Open("POST",remoteURL, true);  	 	
	postFeedbackReq.onreadystatechange = postFeedbackReqCallback;
	postFeedbackReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	postFeedbackReq.setRequestHeader("Content-length", postr.length);
	postFeedbackReq.setRequestHeader("Connection", "close"); 	  
	postFeedbackReq.send(postr);}
function postFeedbackReqCallback(){
	if (postFeedbackReq.readyState == 4){
		var htmlOutput = "";
		if (postFeedbackReq.status == 200){  
			var feedbackResponse = postFeedbackReq.responseText;  
			if ( feedbackResponse == "cun"){} 
			else{}}}}
var arryUserPlaylist=new Array(), arryUserPlaylistAsset=new Array(), arryActivePlaylist = new Array(), arryActivePlaylistAsset = new Array();
var totalPlaylist = 0, saveAs = false, retrySubmit = 0, retryloadAllUserPlaylistFromWS = 5, retrygetActiveUserPlayList = 5;
var retrysubmitUpdatePlaylist = 0;
function Playlist(playlistId, playListName, playListDesc){
	this.playlistId = playlistId;
	this.playListName = playListName;	
	this.playListDesc = playListDesc;}
function loadAllUserPlaylistFromWS(){
	loginid = getCookie("loginid");	
	if (document.getElementById('divUserPlaylistCount')){ 
		document.getElementById('divUserPlaylistCount').innerHTML = '&nbsp;<img src="default/images/load.gif" width="10" height="10" align="absmiddle">';}
	if (document.getElementById('divUserPlaylistCount2')){ 
		document.getElementById('divUserPlaylistCount2').innerHTML = '&nbsp;<img src="default/images/load.gif" width="10" height="10" align="absmiddle">';}	
	XMLplLoad = false;
	XMLplLoad = new ActiveXObject("Microsoft.XMLHTTP");
	var soapMessage, webMethod;
	webMethod="getUserPlayListByUserId"; 
	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 += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";	
	XMLplLoad.onreadystatechange = loadUserPlaylistCB;
	XMLplLoad.Open("POST",addrWebServices, true);
	XMLplLoad.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	XMLplLoad.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	XMLplLoad.send(soapMessage);}
function loadUserPlaylistCB(){
	if(XMLplLoad.readyState==4){
		if(XMLplLoad.status==200){	
			arryUserPlaylist = new Array(); 
			arryUserPlaylistAsset = new Array();			
			var x = XMLplLoad.responseXML;
			var xx = x.childNodes[1].xml;			
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");
			var rootPl = xmlObject.getElementsByTagName('playlists')[0];
			var playlists = rootPl.getElementsByTagName("playlist");			
			for(var k = 0 ; k < playlists.length ; k++){				
				var playlistId = playlists[k].getAttribute("id");						
				var playlistName = playlists[k].getElementsByTagName("playlistName")[0].firstChild.nodeValue;
				var playlistDesc = playlists[k].getElementsByTagName("playlistDesc")[0].firstChild.nodeValue;
				arryUserPlaylist.push(new Playlist(playlistId,playlistName,playlistDesc));
				arryUserPlaylistAsset[k]=new Array();				
				var root = playlists[k].getElementsByTagName('assets')[0];
				var assets = root.getElementsByTagName("asset");
				var assetId, assetImage, assetVideo, assetTitle, assetLengthMinutes, assetSynopsis, assetTags, assetViewed, assetRating, assetLevel, assetGenre, programmeId;				
				for(var i = 0 ; i < assets.length ; i++){
					asset = assets[i];
					assetId =  asset.getAttribute("assetId");
					assetImage =  asset.getElementsByTagName("assetImage")[0].firstChild.nodeValue;
					assetVideo =  asset.getElementsByTagName("assetVideo")[0].firstChild.nodeValue;					
					assetTitle =  asset.getElementsByTagName("assetTitle")[0].firstChild.nodeValue;
					assetLengthMinutes =  asset.getElementsByTagName("assetLengthMinutes")[0].firstChild.nodeValue;
					if(asset.getElementsByTagName("assetSynopsis")[0]){
						assetSynopsis =  asset.getElementsByTagName("assetSynopsis")[0].firstChild.nodeValue;} 
					else{assetSynopsis = "";}					
					assetTags =  asset.getElementsByTagName("assetTags")[0].firstChild.nodeValue;
					assetViewed =  asset.getElementsByTagName("assetViewed")[0].firstChild.nodeValue;
					if(asset.getElementsByTagName("assetRating")[0].firstChild){
						assetRating =  asset.getElementsByTagName("assetRating")[0].firstChild.nodeValue;} 
					else{assetRating = "";}
					if(asset.getElementsByTagName("assetViewerCategory")[0]){
						assetLevel =  asset.getElementsByTagName("assetViewerCategory")[0].firstChild.nodeValue;} 
					else{assetLevel = "0";}
					if(asset.getElementsByTagName("assetGenre")[0].firstChild){					
						assetGenre =  asset.getElementsByTagName("assetGenre")[0].firstChild.nodeValue;} 
					else{assetGenre = "";}				
					programmeId = asset.getElementsByTagName("assetProgrammeId")[0].firstChild.nodeValue;					
					arryUserPlaylistAsset[k].push( new simpleAsset(assetId,assetImage,assetVideo,assetTitle,assetLengthMinutes, assetSynopsis,assetTags,assetViewed,assetRating,assetLevel,programmeId,assetGenre));}}
			if(arryActivePlaylistAsset !== undefined){
				if(arryActivePlaylistAsset.length == 0){ 					
					getActiveUserPlayList();}}}
		else{			
			if(retryloadAllUserPlaylistFromWS > 0){
				retryloadAllUserPlaylistFromWS -= 1;
				loadAllUserPlaylistFromWS();}
			else{
				retryloadAllUserPlaylistFromWS = 5;}}}}
function getActiveUserPlayList(){
	XMLplGetActive = false;
	XMLplGetActive = new ActiveXObject("Microsoft.XMLHTTP");
	var soapMessage, webMethod;
	webMethod = "getActiveUserPlayList"; 
	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 += "</" + webMethod + ">";
	soapMessage += "</soap:Body>";
	soapMessage += "</soap:Envelope>";
	XMLplGetActive.onreadystatechange = getActiveUserPlayListCB;
	XMLplGetActive.Open("POST",addrWebServices,true);
	XMLplGetActive.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	XMLplGetActive.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	XMLplGetActive.send(soapMessage);}
function getActiveUserPlayListCB(){
	if (XMLplGetActive.readyState == 4){
		if (XMLplGetActive.status == 200){
			var x = XMLplGetActive.responseXML;
			var xx = x.childNodes[1].xml;			
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");			
			var activePlaylistId = xmlObject.getElementsByTagName('id')[0].firstChild.nodeValue;			
			if(activePlaylistId != 0){
				for (var k = 0 ; k < arryUserPlaylist.length ; k++){
					if (arryUserPlaylist[k].playlistId == activePlaylistId){						
						arryActivePlaylistAsset = arryUserPlaylistAsset[k];
						arryActivePlaylist = arryUserPlaylist[k];}}
				displayActivePlaylistAsset();}}
		else{			
			if(retrygetActiveUserPlayList >0){
				retrygetActiveUserPlayList -= 1;
				getActiveUserPlayList();}
			else{
				retrygetActiveUserPlayList = 5;}}}}
function displayActivePlaylistAsset(){
	if(arryActivePlaylist.playListName){
		document.getElementById('divActivePlaylistName').innerHTML = "&nbsp;<strong>" + arryActivePlaylist.playListName + "</strong>";} 
	else{
		document.getElementById('divActivePlaylistName').innerHTML = "";}
	document.getElementById('divAssetCount').innerHTML = "Videos: " + arryActivePlaylistAsset.length;	
	var ni = document.getElementById('divPlaylistAsset');
	ni.innerHTML = "";	
	for(var i=0; i < arryActivePlaylistAsset.length; i++){			
		var dispLock = "";		
		if((arryActivePlaylistAsset[i].assetLevel == "3" ) || (arryActivePlaylistAsset[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)\">";
		}
		var content = "\
		<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\
  <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=\"playNowFromPlaylist('user','"+arryActivePlaylistAsset[i].assetId+"','arryActivePlaylistAsset');\" src="+arryActivePlaylistAsset[i].assetImage+" width=\"80\" height=\"60\"></td>\
	<td></td>\
	<td colspan=\"6\" valign=\"top\"><span class=\"style1\"><a style=\"cursor:pointer;\" onMouseover=\"Tip('"+arryActivePlaylistAsset[i].assetTitle+"',LEFT,true)\" onClick=\"playNowFromPlaylist('user','"+arryActivePlaylistAsset[i].assetId+"','arryActivePlaylistAsset');\">"+(arryActivePlaylistAsset[i].assetTitle).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\">"+(arryActivePlaylistAsset[i].assetGenre).substr(0,17)+"&nbsp;"+dispLock+"</span></td>\
	<td>&nbsp;</td>\
	<td colspan=\"2\" valign=\"top\">"+displayStarRating(arryActivePlaylistAsset[i].assetRating)+"</td>\
	<td></td>\
  </tr>\
  \
  <tr>\
	<td height=\"4\"></td>\
	<td></td>\
	<td rowspan=\"3\" valign=\"top\"><a style=\"cursor:pointer;\" onClick=\"playNowFromPlaylist('user','"+arryActivePlaylistAsset[i].assetId+"','arryActivePlaylistAsset');\"><img src=\"" + skinFolder + "/images/buttons/btn_playvideo.gif\" alt=\"play video\" width=\"23\" height=\"20\" /></a><a style=\"cursor:pointer;\" onClick=\"removeFromPlaylist('" + i + "');\"><img src=\"" + skinFolder + "/images/button_remove.gif\" alt=\"add to playlist\" width=\"24\" height=\"20\" /></a><a style=\"cursor:pointer;\" onClick=\"shareNow('"+arryActivePlaylistAsset[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 colspan=\"5\" valign=\"top\" align=\"right\"><span class=\"style2\" >"+arryActivePlaylistAsset[i].assetLengthMinutes+" min(s) | views: "+arryActivePlaylistAsset[i].assetViewed+"</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>";
	
		var newdiv = document.createElement('div');
		var divIdName = 'playlistAsset' + i;
		newdiv.setAttribute('id',divIdName);		
		newdiv.style.backgroundImage = "url('" + skinFolder + "/images/listing_bg.gif')";	
		newdiv.innerHTML = content;
		ni.appendChild(newdiv);}		
	if(arryActivePlaylistAsset.length != 0  && document.getElementById('divPlaylistAsset').style.display != "none" ){ 
		document.getElementById('divPlaylistControl').style.display = "";}}
function savePlaylist(){
	if (loginid=="" || loginid=== undefined){
		document.getElementById('divPlaylistControl').style.display="none";
		document.getElementById('msgboxPlaylist').innerHTML = '&nbsp;&nbsp;&nbsp;Please login or register to save/edit playlist.';
		new Effect.Appear(document.getElementById('msgboxPlaylist'));
		setTimeout("new Effect.Fade(document.getElementById('msgboxPlaylist'))",4000);
		setTimeout("new Effect.Appear(document.getElementById('divPlaylistControl'))",5000);}
	else{
		if (arryActivePlaylist.playlistId !== undefined){
			document.getElementById('plName').value = arryActivePlaylist.playListName;
			document.getElementById('plDesc').value = arryActivePlaylist.playListDesc;}		
		document.getElementById('divPlaylistControl').style.display="none";
		document.getElementById('divPlaylistSave').style.display="";
		document.getElementById('divCloseSave').style.display="";}}
function goSubmitSavePlaylist(){
	if (saveAs == true || arryActivePlaylist.playlistId === undefined){
		saveAs = false;
		submitAddPlaylist();}
	else{
		submitUpdatePlaylist();}}
function savePlaylistDirect(){
	if (arryActivePlaylist.playlistId === undefined){
		savePlaylist();}
	else{
		submitUpdatePlaylist();}}
function submitAddPlaylist(){
	document.getElementById('divPlaylistControl').style.display='none';
	document.getElementById('divPlaylistMsg1txt').innerHTML = "Saving, please wait...";
	document.getElementById('divPlaylistMsg1').style.display = "";
	document.getElementById('divPlaylistSave').style.display='none';	
	var plname = document.getElementById('plName').value;
	var pldesc = document.getElementById('plDesc').value;	
	var assetIdArray = new Array(); 
	for (i=0; i < arryActivePlaylistAsset.length ; ++i){ 
  		assetIdArray.push(arryActivePlaylistAsset[i].assetId);}
	XMLplSave = false;
	XMLplSave = new ActiveXObject("Microsoft.XMLHTTP");	
	var soapMessage, webMethod;
	webMethod="createUserPlayList"; 
	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 += "	<name>"+ plname +"</name>";
	soapMessage += "	<description>"+ pldesc +"</description>";
	soapMessage += "	<isActive>1</isActive>";
	soapMessage += "	<strAssetIdArray>"+ assetIdArray.toString() +"</strAssetIdArray>";	
	soapMessage += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";
	XMLplSave.onreadystatechange = submitAddPlaylistCB;
	XMLplSave.Open("POST",addrWebServices, true);        
	XMLplSave.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	XMLplSave.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	XMLplSave.send(soapMessage);}
function submitAddPlaylistCB(){
	if (XMLplSave.readyState == 4){
		if (XMLplSave.status == 200){
			arryActivePlaylist = new Array();
			arryActivePlaylistAsset = new Array();			
			loadAllUserPlaylistFromWS();			
			document.getElementById('divPlaylistSave').style.display='none';
			document.getElementById('divPlaylistMsg1txt').innerHTML = "Playlist saved!";
			document.getElementById('divCloseSave').style.display="none";
			setTimeout("document.getElementById('divPlaylistMsg1').style.display='none'",4000);
			document.getElementById('divPlaylistControl').style.display='';}
		else{
			if (arryUserPlaylist.length == 10){
				document.getElementById('divPlaylistMsg1txt').innerHTML = "Error saving playlist. <br>You have reached your maximum playlist numbers (10).";}
			else{
				if (retrySubmit < 5){
					retrySubmit += 1;
					submitAddPlaylist();}
				else{
					retrySubmit = 0;
					document.getElementById('divPlaylistMsg1txt').innerHTML = "Error saving playlist. <br>Please try again later.";}}			
			document.getElementById('divPlaylistSave').style.display='none';
			document.getElementById('divCloseSave').style.display="none";			
			setTimeout("document.getElementById('divPlaylistControl').style.display=''",5000);
			setTimeout("document.getElementById('divPlaylistMsg1').style.display='none'",3000);}}}
function closeSavePlaylist(){
	document.getElementById('divCloseSave').style.display='none';
	document.getElementById('divPlaylistSave').style.display='none';
	document.getElementById('divPlaylistControl').style.display="";}
function submitUpdatePlaylist(){
	if (arryActivePlaylist.playlistId == 0){ 
		submitAddPlaylist();}
	else{
		document.getElementById('divPlaylistControl').style.display='none';
		document.getElementById('divPlaylistMsg1txt').innerHTML = "Saving, please wait...";
		document.getElementById('divPlaylistMsg1').style.display = "";
		document.getElementById('divPlaylistSave').style.display='none';
		var plname = document.getElementById('plName').value;
		var pldesc = document.getElementById('plDesc').value;		
		var assetIdArray = new Array(); 
		for (i=0; i < arryActivePlaylistAsset.length ; ++i){ 
			assetIdArray.push(arryActivePlaylistAsset[i].assetId);}		
		XMLplSave = false;
		XMLplSave = new ActiveXObject("Microsoft.XMLHTTP");
		var soapMessage, webMethod;
		webMethod="updateUserPlayList"; 
		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 += "	<userPlayListId>"+ arryActivePlaylist.playlistId +"</userPlayListId>";	
		soapMessage += "	<name>"+ plname +"</name>";
		soapMessage += "	<description>"+ pldesc +"</description>";
		soapMessage += "	<isActive>1</isActive>";
		soapMessage += "	<strAssetIdArray>"+ assetIdArray.toString() +"</strAssetIdArray>";	
		soapMessage += "    </" + webMethod + ">";
		soapMessage += "  </soap:Body>";
		soapMessage += "</soap:Envelope>";
		XMLplSave.onreadystatechange = submitUpdatePlaylistCB;
		XMLplSave.Open("POST",addrWebServices, true);        
		XMLplSave.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
		XMLplSave.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
		XMLplSave.send(soapMessage);}}
function submitUpdatePlaylistCB(){
	if (XMLplSave.readyState == 4){
		if (XMLplSave.status == 200){			
			arryActivePlaylist = new Array();
			arryActivePlaylistAsset = new Array();			
			loadAllUserPlaylistFromWS();		
			document.getElementById('divPlaylistSave').style.display='none';
			document.getElementById('divPlaylistMsg1txt').innerHTML = "Playlist updated!";
			document.getElementById('divCloseSave').style.display="none";
			setTimeout("document.getElementById('divPlaylistMsg1').style.display='none'",3000);
			document.getElementById('divPlaylistControl').style.display='';}
		else{			
			if(retrysubmitUpdatePlaylist < 5){
				retrysubmitUpdatePlaylist += 1;
				submitUpdatePlaylist();}
			else{
				retrysubmitUpdatePlaylist = 0;
				document.getElementById('divPlaylistMsg1txt').innerHTML = "Error saving playlist. <br>Please try again later.";
				document.getElementById('divPlaylistSave').style.display='none';
				document.getElementById('divCloseSave').style.display="none";
				setTimeout("document.getElementById('divPlaylistControl').style.display=''",4000);
				setTimeout("new Effect.Fade(document.getElementById('divPlaylistMsg1'));",3000);}}}}
function showPlaylist(){
	document.getElementById('divPlaylistAsset').style.display = "";
	document.getElementById('divPlaylistAssetHead').style.display = "";
	document.getElementById('divCloseSavePlaylistlist').style.display='none';
	document.getElementById('divPlaylistList').style.display='none';
	document.getElementById('divPlaylistListHead').style.display='none';	
	document.getElementById('divPlaylistControl').style.display = "";}
function addToPlaylist(theId, theArray){
	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";}	
	var tempArray = eval(theArray);
//	if(globalPage == 'previews') 
//	{
//		loadPage('auto','previews');			
//	}	
	showPlaylist();
	var alreadyHaveAssetInarryActivePlaylistAsset = false;
	for(i=0; i < arryActivePlaylistAsset.length ; ++i){
		if(theId == arryActivePlaylistAsset[i].assetId){ 
			alreadyHaveAssetInarryActivePlaylistAsset = true;}}
	if(alreadyHaveAssetInarryActivePlaylistAsset == false){
		if (arryActivePlaylistAsset.length != 20){
			for (var i=0; i < tempArray.length; i++){
				if (tempArray[i].assetId == theId){	
					arryActivePlaylistAsset.push(new simpleAsset(tempArray[i].assetId,tempArray[i].assetImage,tempArray[i].assetVideo,tempArray[i].assetTitle,tempArray[i].assetLengthMinutes,tempArray[i].assetSynopsis,tempArray[i].assetTags,tempArray[i].assetViewed,tempArray[i].assetRating,tempArray[i].assetLevel,tempArray[i].programmeId,tempArray[i].assetGenre));
					var theIndex = parseInt(arryActivePlaylistAsset.length - 1);
					var dispLock = "";					
					if(( tempArray[i].assetLevel == "3" ) || ( tempArray[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)\">";      		}
		
					var content = "\
		<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" >\
  <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=\"playNowFromPlaylist('user','"+tempArray[i].assetId+"','arryActivePlaylistAsset');\" src="+tempArray[i].assetImage+" width=\"80\" height=\"60\"></td>\
	<td></td>\
	<td colspan=\"6\" valign=\"top\"><span class=\"style1\"><a style=\"cursor:pointer;\" onMouseover=\"Tip('"+tempArray[i].assetTitle+"',LEFT,true)\" onClick=\"playNowFromPlaylist('user','"+tempArray[i].assetId+"','arryActivePlaylistAsset');\">"+(tempArray[i].assetTitle).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\">"+(tempArray[i].assetGenre).substr(0,17)+"&nbsp;"+dispLock+"</span></td>\
	<td>&nbsp;</td>\
	<td colspan=\"2\" valign=\"top\">"+displayStarRating(tempArray[i].assetRating)+"</td>\
	<td></td>\
  </tr>\
  \
  <tr>\
	<td height=\"4\"></td>\
	<td></td>\
	<td rowspan=\"3\" valign=\"top\"><a style=\"cursor:pointer;\" onClick=\"playNowFromPlaylist('user','"+tempArray[i].assetId+"','arryActivePlaylistAsset');\"><img src=\"" + skinFolder + "/images/buttons/btn_playvideo.gif\" alt=\"play video\" width=\"23\" height=\"20\" /></a><a style=\"cursor:pointer;\" onClick=\"removeFromPlaylist('" + i + "');\"><img src=\"" + skinFolder + "/images/button_remove.gif\" alt=\"remove from playlist\" width=\"24\" height=\"20\" /></a><a style=\"cursor:pointer;\" onClick=\"shareNow('"+tempArray[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 colspan=\"5\" valign=\"top\" align=\"right\"><span class=\"style2\" >"+tempArray[i].assetLengthMinutes+" min(s) | views: "+tempArray[i].assetViewed+"</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>";
				
					var ni = document.getElementById('divPlaylistAsset');
					var newdiv = document.createElement('div');
					var divIdName = 'playlistAsset' + theIndex;
					newdiv.setAttribute('id',divIdName);
					newdiv.style.display = "none";
					newdiv.style.backgroundImage = "url('" + skinFolder + "/images/listing_bg.gif')";				
					newdiv.innerHTML = content;
					ni.appendChild(newdiv);					
					new Effect.Appear(newdiv);
					setTimeout("document.getElementById('divPlaylistAsset').scrollTop = document.getElementById('divPlaylistAsset').scrollHeight",300);
					document.getElementById('divAssetCount').innerHTML = "Videos: " + arryActivePlaylistAsset.length;
					break;}}}
		else{
			document.getElementById('divPlaylistMsg1txt').innerHTML = 'Playlist full.';
			document.getElementById('divPlaylistMsg1').style.display = "";
			setTimeout("document.getElementById('divPlaylistMsg1').style.display='none'",4000);}}
	else{
		document.getElementById('divPlaylistMsg1txt').innerHTML = 'Video already in playlist.';
		document.getElementById('divPlaylistMsg1').style.display = "";
		setTimeout("document.getElementById('divPlaylistMsg1').style.display='none'",3000);}}
function removeFromPlaylist(theIndex){
	theLayer = "playlistAsset" + theIndex;
	new Effect.Fade(document.getElementById(theLayer));	
	arryActivePlaylistAsset.splice(theIndex,1); 
	setTimeout("removeFromPlaylist2('" + theLayer + "')",1000);
	document.getElementById('divAssetCount').innerHTML = "Videos: " + arryActivePlaylistAsset.length;}
function removeFromPlaylist2(theLayer){
	displayActivePlaylistAsset();}
function clearPlaylist(){
	document.getElementById('divPlaylistControl').style.display = "none";
	document.getElementById('divPlaylistMsg1txt').innerHTML = 'Confirm create new playlist without saving existing?<br><br><span class="pl_menu"><strong><a style="cursor:pointer" onClick="clearPlaylistYes();">Yes</a></strong></span><span class="style24">&nbsp;|&nbsp;</span><span class="pl_menu"><strong><a style="cursor:pointer" onClick="clearPlaylistNo();">No</a></strong></span>';
	document.getElementById('divPlaylistMsg1').style.display = "";}
function clearPlaylistYes(){
	arryUserPlaylist=new Array(); 
	arryUserPlaylistAsset=new Array(); 
	document.getElementById('divPlaylistAsset').innerHTML = '';
	document.getElementById('divActivePlaylistName').innerHTML = "&nbsp;<strong>New Playlist</strong>"	
	arryActivePlaylist = new Array();
	arryActivePlaylistAsset = new Array();
	document.getElementById('divActivePlaylistName').innerHTML = "";
	document.getElementById('divAssetCount').innerHTML = "Videos: 0";
	document.getElementById('plName').value = "";
	document.getElementById('plDesc').value = "";	
	document.getElementById('divPlaylistControl').style.display = "";
	document.getElementById('divPlaylistMsg1txt').innerHTML = "New Playlist.";
	setTimeout("document.getElementById('divPlaylistMsg1').style.display = 'none'",2000);}
function clearPlaylistNo(){
	document.getElementById('divPlaylistControl').style.display = "block";
	document.getElementById('divPlaylistMsg1txt').innerHTML = "";
	document.getElementById('divPlaylistMsg1').style.display = "none";}
function emptyPlaylist(){
	document.getElementById('divPlaylistAsset').innerHTML = "";
	arryActivePlaylistAsset = new Array();
	document.getElementById('divAssetCount').innerHTML = "Videos: " + arryActivePlaylistAsset.length;}
//Playlist Control - End
//Playlist select - Start
function loadPlaylistList(){
	loginid = getCookie("loginid");	
	if ((loginid=="") || (loginid === undefined)){
		document.getElementById('divPlaylistControl').style.display="none";
		document.getElementById('msgboxPlaylist').innerHTML = '&nbsp;&nbsp;&nbsp;Please login or register to load playlist.';
		new Effect.Appear(document.getElementById('msgboxPlaylist'));
		setTimeout("new Effect.Fade(document.getElementById('msgboxPlaylist'))",4000);
		setTimeout("new Effect.Appear(document.getElementById('divPlaylistControl'))",5000);}
	else{
		displayAllUserPlaylist();}}
function displayAllUserPlaylist(){
	var ni = document.getElementById('divPlaylistList');
	ni.innerHTML = "";	
	for (var k = 0 ; k < arryUserPlaylist.length ; k++){ 
		if (arryActivePlaylist.playlistId == arryUserPlaylist[k].playlistId){
			var bgImg = skinFolder + "/images/listing_bg_02.gif";}
		else{
			var bgImg = skinFolder + "/images/listing_bg.gif";}
		var theContent = '<table width="280" border="0" cellpadding="7" cellspacing="0">';
		theContent += '<tr>' +
			'<td><table width="100%" border="0" cellspacing="0" cellpadding="1">' +
			  '<tr>' +
				'<td class="style28">' + arryUserPlaylist[k].playListName + '</td>' +
			  '</tr>' +
			  '<tr>' +
				'<td width="95%" class="style24">' + arryUserPlaylist[k].playListDesc + '</td>' +
			  '</tr>' +
			  '<tr>';						
		if(arryActivePlaylist.playlistId == arryUserPlaylist[k].playlistId){
			theContent +='<td class="pl_menu2"><a style="cursor:pointer" onClick="loadThisPlaylist(\'' + arryUserPlaylist[k].playlistId + '\',\'' + k + '\');">Load</a> | <a style="cursor:pointer" onClick="delThisPlaylist(\'' + arryUserPlaylist[k].playlistId + '\',\'' + k + '\');">Delete</a></td>';
		}
		else{
			theContent += '<td class="pl_menu2"><a style="cursor:pointer" onClick="loadThisPlaylist(\'' + arryUserPlaylist[k].playlistId + '\',\'' + k + '\');">Load</a> | <a style="cursor:pointer" onClick="delThisPlaylist(\'' + arryUserPlaylist[k].playlistId + '\',\'' + k + '\');">Delete</a> </td>';					
		}
		theContent += '</tr>' +
			'</table></td>' +
		  '</tr>' +
		'</table>';
		
		var newdiv = document.createElement('div');
		var divIdName = 'playlistList' + k;
		newdiv.setAttribute('id',divIdName);
		newdiv.style.backgroundImage = "url('" + bgImg + "')";
		newdiv.innerHTML = theContent;
		ni.appendChild(newdiv);}	
	document.getElementById('divPlaylistList').style.display='';
	document.getElementById('divPlaylistListHead').style.display='';
	document.getElementById('divPlaylistControl').style.display='none';
	document.getElementById('divCloseSavePlaylistlist').style.display='';}
function delThisPlaylist(theId, theIndex){
	document.getElementById('divPlaylistMsg1txt').innerHTML = 'Confirm delete playlist?<br><br><span class="pl_menu"><strong><a style="cursor:pointer" onClick="delThisPlaylistYes(\'' + theId + '\',\'' + theIndex + '\');">Yes</a></strong></span><span class="style24">&nbsp;|&nbsp;</span><span class="pl_menu"><strong><a style="cursor:pointer" onClick="delThisPlaylistNo();">No</a></strong></span>';
	document.getElementById('divPlaylistMsg1').style.display = "";
	document.getElementById('divCloseSavePlaylistlist').style.display='none';}
function delThisPlaylistNo(){
	document.getElementById('divPlaylistMsg1').style.display = "none";
	document.getElementById('divCloseSavePlaylistlist').style.display='';}
function delThisPlaylistYes(theId, theIndex){
	document.getElementById('divPlaylistMsg1').style.display = "none";
	var theLayer = "playlistList" + theIndex;
	new Effect.Fade(document.getElementById(theLayer));	
	arryUserPlaylist.splice(theIndex,1);
	arryUserPlaylistAsset.splice(theIndex,1);
	XMLDelPlaylist = false;
	XMLDelPlaylist = new ActiveXObject("Microsoft.XMLHTTP");
	var soapMessage, webMethod;
	var webMethod="deleteUserPlayList"; 
	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 += "	<playListId>"+ theId +"</playListId>";	
	soapMessage += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";
	XMLDelPlaylist.onreadystatechange = delThisPlaylistInvokeCB;
	XMLDelPlaylist.Open("POST",addrWebServices, true);
	XMLDelPlaylist.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	XMLDelPlaylist.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	XMLDelPlaylist.send(soapMessage);}
function delThisPlaylistInvokeCB(){
	if (XMLDelPlaylist.readyState == 4){
		if (XMLDelPlaylist.status == 200){
			displayAllUserPlaylist();}
		else{
			displayAllUserPlaylist();}}}
function closePlaylistList(){
	document.getElementById('divCloseSavePlaylistlist').style.display='none';
	document.getElementById('divPlaylistControl').style.display='';
	document.getElementById('divPlaylistList').style.display='none';
	document.getElementById('divPlaylistListHead').style.display='none';}
function loadThisPlaylist(theId, theIndex){
	arryActivePlaylist = arryUserPlaylist[theIndex];
	arryActivePlaylistAsset = arryUserPlaylistAsset[theIndex];	
	document.getElementById('divPlaylistList').style.display='none';
	document.getElementById('divPlaylistListHead').style.display='none';
	document.getElementById('divCloseSavePlaylistlist').style.display='none';	
	document.getElementById('divPlaylistControl').style.display='';
	setActivePlaylist();
	displayActivePlaylistAsset();
	document.getElementById('divActivePlaylistName').innerHTML = "&nbsp;<strong>" + arryUserPlaylist[theIndex].playListName + "</strong>";}
function setActivePlaylist(){		
		var assetIdArray = new Array(); 
		for (i=0; i < arryActivePlaylistAsset.length ; ++i){ 
			assetIdArray.push(arryActivePlaylistAsset[i].assetId);}		
		XMLplSave = false;
		XMLplSave = new ActiveXObject("Microsoft.XMLHTTP");
		var soapMessage, webMethod;
		webMethod="updateUserPlayList"; 
		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 += "	<userPlayListId>"+ arryActivePlaylist.playlistId +"</userPlayListId>";	
		soapMessage += "	<name>"+ arryActivePlaylist.playListName +"</name>";
		soapMessage += "	<description>"+ arryActivePlaylist.playListDesc +"</description>";
		soapMessage += "	<isActive>1</isActive>";
		soapMessage += "	<strAssetIdArray>"+ assetIdArray.toString() +"</strAssetIdArray>";	
		soapMessage += "    </" + webMethod + ">";
		soapMessage += "  </soap:Body>";
		soapMessage += "</soap:Envelope>";
		//alert(soapMessage);
		XMLplSave.onreadystatechange = setActivePlaylistCB;
		XMLplSave.Open("POST",addrWebServices, true);        
		XMLplSave.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
		XMLplSave.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
		XMLplSave.send(soapMessage);}
function setActivePlaylistCB(){
	if (XMLplSave.readyState == 4){
		if (XMLplSave.status == 200){}
		else{			
			if (retrySubmit < 5){
				retrySubmit += 1;
				setActivePlaylist();}
			else{
				retrySubmit = 0;}}}}
function textLimit(){
	var theElement = document.getElementById('plDesc');
	var maxlimit = 50;
	if(theElement.value.length > maxlimit) { theElement.value = theElement.value.substring(0, maxlimit);}}
function loadPlaylistPanel(){
	htmlOutput = "<table width=\"298\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\
		<tr>\
		<td height=\"287\" colspan=\"2\" valign=\"top\" background=\"" + skinFolder + "/images/listing_default.gif\">\
		<div id=\"divPlaylistAssetHead\" style=\"position:absolute; height:10; width:298; z-index:8; display:none\"><table width=298 height=32 border=0 cellpadding=3 cellspacing=0 background='" + skinFolder + "/images/listing_top.gif'><tr><td class=pl_menu><div id='divActivePlaylistName'></div></td><td width=53 align=right class=pl_menu><div id=divAssetCount>Videos: 0</div></td><td width=4><span class=\"style24\">|</span></td><td width=39 align=left class=pl_menu><a style='cursor:pointer;' onclick='playAll(arryActivePlaylistAsset);'>Play All</a>&nbsp;</td></tr></table></div>\
		<div id=\"divPlaylistAsset\" style=\"position:absolute; top=30; overflow:auto; height:260; width:298; z-index:5;display:none; background-image:url('" + skinFolder + "/images/listing_bg_long.gif'); scrollbar-track-color:#333333; scrollbar-face-color:#333333; scrollbar-shadow-color:#000000; scrollbar-3dlight-color:#666666; scrollbar-highlight-color:#666666;\"></div>\
		<div id=\"divPlaylistListHead\" style=\"position:absolute; height:260; width:298; z-index:8; display:none\" valign=\"top\"><table width=298 height=32 border=0 cellpadding=7 cellspacing=0 background=\"" + skinFolder + "/images/listing_top.gif\"><tr><td class=pl_menu>Please select playlist to load:</td></tr></table></div>\
		<div id=\"divPlaylistList\" style=\"position:absolute; top=30; overflow:auto; height:260; width:298; z-index:7;  background-image:url('" + skinFolder + "/images/listing_default.gif'); display:none\"></div>\
		<div id=\"divPlaylistSave\" style=\"position:absolute; display:none; height:290; width:298; z-index:11; background-image:url('" + skinFolder + "/images/listing_default.gif')\">\
		  <table width=\"100%\" height=\"29\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"" + skinFolder + "/images/listing_top.gif\">\
			<tr>\
			  <td class=\"style19\">&nbsp;&nbsp;&nbsp;&nbsp;Saving / Edit Playlist </td>\
			</tr>\
		  </table>\
		  <table border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\" class=\"pl_menu\">\
			<tr>\
			  <td align=\"left\" height=\"20\" valign=\"top\">&nbsp;</td>\
			  <td align=\"left\" valign=\"top\">\
			</tr>\
			<tr>\
			  <td align=\"left\" valign=\"top\">Playlist name:</td>\
			  <td align=\"left\" valign=\"top\">\
				<input name=\"plName\" type=\"text\" id=\"plName\" size=\"30\" maxlength=27></td>\
			</tr>\
			<tr>\
			  <td align=\"left\" valign=\"top\">Description:</td>\
			  <td align=\"left\" valign=\"top\"><textarea name=\"plDesc\" id=\"plDesc\" cols=\"23\" rows=\"5\" onKeyDown=\"textLimit();\" onKeyUp=\"textLimit();\"></textarea></td>\
			</tr>\
			<tr>\
			  <td colspan=\"2\" valign=\"top\" align=\"center\">\
				<span class=\"style9\"><a style=\"cursor:pointer\" onClick=\"goSubmitSavePlaylist();\"><img src=\"" + skinFolder + "/images/button_save.gif\" alt=\"save playlist\" width=\"81\" height=\"23\" border=\"0\" /></a></span>\
			  </td>\
			</tr>\
		  </table>\
		</div>\
		<div id=\"divPlaylistMsg1\" style=\"position:absolute; height:290; width:298; display:none; z-index:19; background-image:url('" + skinFolder + "/images/listing_default.gif');\">\
			<table width=\"100%\" height=\"260\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">\
			  <tr>\
				<td align=\"center\"><div id=\"divPlaylistMsg1txt\" class=\"style9\"></div></td>\
			  </tr>\
			</table>\
		</div>\
		</td>\
	  </tr>\
	  <tr>\
		<td colspan=\"2\">\
		<table width=\"100%\" height=\"31\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"" + skinFolder + "/images/listing_top.gif\">\
		  <tr>\
			<td height=\"31\">\
				<div id=\"divPlaylistControl\" style=\"display:none\">\
					<table width=\"100%\" border=0 cellspacing=0 cellpadding=0><tr><td><table  border=0 cellspacing=0 cellpadding=0><tr><td><span class=\"pl_menu\">\
					&nbsp;&nbsp;&nbsp;<a style=\"cursor:pointer\" onClick=\"loadPlaylistList();\">Load Playlist</a></span></td><td></td></tr></table></td>\
					<td align=right>\
					  <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\
						<tr>\
							<td valign=top><span class=\"pl_menu\"><a style=\"cursor:pointer\" onClick=\"clearPlaylist();\">New</a></span></td>\
							<td valign=top><span class=\"style24\">&nbsp;|&nbsp;</span></td>\
							<td valign=top><span class=\"pl_menu\"><a style=\"cursor:pointer\" onClick=\"savePlaylist();\">Edit</a></span></td>\
							<td valign=top><span class=\"style24\">&nbsp;|&nbsp;</span></td>\
							<td valign=top><span class=\"pl_menu\"><a style=\"cursor:pointer\" onClick=\"savePlaylistDirect();\">Save</a></span></td>\
							<td valign=top><span class=\"style24\">&nbsp;|&nbsp;</span></td>\
							<td valign=top><span class=\"pl_menu\"><a style=\"cursor:pointer\" onClick=\"saveAs=true; savePlaylist();\">Save As</a></span></td>\
							<td valign=top><span class=\"style24\">&nbsp;|&nbsp;</span></td>\
							<td valign=top><span class=\"pl_menu\"><a style=\"cursor:pointer\" onClick=\"saveAs=true; emptyPlaylist();\">Clear</a>&nbsp;&nbsp;</span></td>\
						</tr>\
					  </table>\
					</td>\
					</tr></table>\
				</div>\
				<div id=\"msgboxPlaylist\" style=\"display:none\" class=\"pl_notify\"></div>\
				<div id=\"divCloseSave\" style=\"display:none\">&nbsp;&nbsp;&nbsp;<span class=\"pl_menu\"><a style=\"cursor:pointer\" onClick=\"closeSavePlaylist();\">Close</a></span></div>\
				<div id=\"divCloseSavePlaylistlist\" style=\"display:none\">&nbsp;&nbsp;&nbsp;<span class=\"pl_menu\"><a style=\"cursor:pointer\" onClick=\"closePlaylistList();\">Close</a></span></div>\
			</td>\
		  </tr>\
		</table>\
		</td>\
	  </tr>\
	</table>";
	WriteLayer('list2',null,htmlOutput);}
var cpanelIsActive;
function shareNow( assetId ){
	if ( document.getElementById("MediaPlayer") ){

		if (  global_state == "playing" ){
			pauseMediaPlayer();
			document.all.MediaPlayer.style.display = 'none';
		} 
		else if( document.all.MediaPlayer.style.display == 'block' ){
			document.all.MediaPlayer.style.display = 'none';			
		}		
	}		
	if ( document.getElementById('comments').style.visibility == 'visible' ){
		document.getElementById('comments').style.visibility = 'hidden';
		document.getElementById('comments-centered').style.visibility = 'hidden';
		cpanelIsActive = true;
	}	
	if ( document.getElementById("videoStop")){
		document.all.videoStop.style.display='none';
	}
	document.all.share.style.visibility = "visible";
	document.all.shareAssetId.value = assetId;
	if ( loginid != "" ){
		document.getElementById("senderName").value = getCookie("loginid");
		document.getElementById("senderEmail").value = getCookie("email");	
	} 
	else{
		document.getElementById("senderName").value = "";
		document.getElementById("senderEmail").value = "";	
	}
	document.getElementById("myrecipientEmail").value = "To send to multiple recipient, \
please separate the email address with comma like \
sharifahroslina@gmail.com,sharayfa@yahoo.com";	
	document.getElementById("mailMessage").value = "This is awesome! Check out this video.";
}
function closeShareNow(){
	if ( cpanelIsActive ){
		document.all.share.style.visibility = "hidden";	
		if ( globalPage != 'home' ){
			if ( document.getElementById("MediaPlayer") ) {
				document.all.MediaPlayer.style.display='block';	
			}
		}
		document.getElementById('comments').style.visibility = 'visible';
		document.getElementById('comments-centered').style.visibility = 'visible';
		document.getElementById("shareResponse").style.visibility="hidden";
		cpanelIsActive = false;		
	} 
	else{		
		if ( document.getElementById("shareResponse")){
			document.getElementById("shareResponse").style.visibility="hidden";
		}
		if ( document.getElementById("MediaPlayer")){
			if (  global_state == "paused" ){
				document.all.MediaPlayer.style.display = 'block';			
				resumeMediaPlayer();
			}		
		}
		document.all.share.style.visibility = "hidden";	
		if ( globalPage != 'home' ) {
			if ( document.getElementById("MediaPlayer") ) {
				document.all.MediaPlayer.style.display='block';	
			}
		}
		if ( global_state == "ended" ) {			
			if ( document.getElementById("videoStop")) {
				document.all.videoStop.style.display='block';
				document.all.MediaPlayer.style.display = 'none';				
			}
		}		
	} 
}
function postShareNow(){
	var senderName = document.all.senderName.value;
	var senderEmail = document.all.senderEmail.value;
	var recipientEmail = document.all.myrecipientEmail.value;
	var mailMessage = document.all.mailMessage.value;
	var assetId = document.all.shareAssetId.value;
	if ( loginid == "" ){
		epassLoginId = "0";
	} else {
		epassLoginId = loginid;
	}
	if (!verifyMultiEmail(senderEmail)) {
		alert("You have entered an invalid sender's email address");
		return;
	}	
	if (!verifyMultiEmail(recipientEmail)) {
		alert("You have entered one or more invalid recipient's email address");
		return;
	}	
	if ( ( senderName != "" ) && (senderEmail != "" ) && ( recipientEmail!="") && (mailMessage!="") && (assetId != "") ){
		sendShareInfo( epassLoginId, assetId, senderName, senderEmail, recipientEmail, mailMessage ) ;

	} else {
		alert("There are empty fields that you have not fill. Please enter all details accordingly.");
		return;
	}
}
function verifyMultiEmail(email_field){	
	var email = email_field.split(',');	
	for (var i = 0; i < email.length; i++){
		if (!validateEmail(email[i])) {
			return false;
		}
	}	
	return true;
}
function validateEmail(emailValue) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailValue)){
		return (true);
	} else {
		return (false);
	}
}
var tmpepassLoginId, tmpassetId, tmpsenderName, tmpsenderEmail, tmprecipientEmail, tmpmailMessage;
var retrysendShareInfo = 0;
function sendShareInfo( epassLoginId, assetId, senderName, senderEmail, recipientEmail, mailMessage ) {
	tmpepassLoginId = epassLoginId;
	tmpassetId = assetId;
	tmpsenderName = senderName;
	tmpsenderEmail = senderEmail;
	tmprecipientEmail = recipientEmail;
	tmpmailMessage = mailMessage;
    var soapMessage, WsUrl, webMethod;
	myXMLshare = new ActiveXObject("Microsoft.XMLHTTP");
    WsUrl = addrWebServices;
	webMethod="shareAsset"; 
	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>"+ epassLoginId +"</epassLoginId>";
	soapMessage += "	<assetId>"+ assetId +"</assetId>";
	soapMessage += "	<senderName>"+ senderName +"</senderName>";
	soapMessage += "	<senderEmail>"+ senderEmail +"</senderEmail>";
	soapMessage += "	<recipentEmail>"+ recipientEmail +"</recipentEmail>";	
	soapMessage += "	<mailMessage>"+ mailMessage +"</mailMessage>";	
	soapMessage += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";
	myXMLshare.onreadystatechange = sendShareInfoCallback;
	myXMLshare.Open("POST",WsUrl, true);        
	myXMLshare.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	myXMLshare.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	myXMLshare.send(soapMessage);
}
function sendShareInfoCallback(){	
	if (myXMLshare.readyState == 4){
		var htmlOutput = "";
		if (myXMLshare.status == 200){    
			var x = myXMLshare.responseXML;
			var xx = x.childNodes[1].xml;
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");
			var status = xmlObject.getElementsByTagName("status")[0].firstChild.nodeValue;
			document.getElementById("share").style.visibility = 'hidden';
			document.getElementById("shareResponse").style.visibility = 'visible';			
			if ( status == 1 ){
				document.all.shareResponseMsg.innerHTML = '<span class="style33"><br>You have succesfully shared the video with your friends. <br><br><a onClick="closeShareNow();" style="cursor:pointer;">CLOSE</a></span>';
			} 
			else{
				document.all.shareResponseMsg.innerHTML = '<span class="style33"><br>We are sorry. Currently the system cannot process your request. Please try back later.</span>';
			}			
		} 
		else{
			if (retrysendShareInfo < 5){
				retrysendShareInfo += 1;
				sendShareInfo( tmpepassLoginId, tmpassetId, tmpsenderName, tmpsenderEmail, tmprecipientEmail, tmpmailMessage ); 
			}
			else{
				tmpepassLoginId = "";
				tmpassetId = "";
				tmpsenderName = "";
				tmpsenderEmail = "";
				tmprecipientEmail = "";
				tmpmailMessage = "";
				retrysendShareInfo = 0;				
				document.getElementById("share").style.visibility = 'hidden';
				document.getElementById("shareResponse").style.visibility = 'visible';				
				document.all.shareResponseMsg.innerHTML  = "<span class=\"style33\"><br>Error sending the videos to your friend, please try again later...</span>";		
			}
		}
     }
}
var tmpassetId,tagSeeder,retrysendstatsMostClicks = 0;
function sendstatsMostTagClicks(tagSeeder){
	tmpassetId = tagSeeder;
	var seederDate = "0";	
	if (getCookie("seederDate") != "" || getCookie("seederDate") != undefined ){
		seederDate = getCookie("seederDate");
	}	
	var seederTime = "0";	
	if (getCookie("seederTime") != "" || getCookie("seederTime") != undefined ){
		seederTime = getCookie("seederTime");	
	}
    var soapMessage, WsUrl, webMethod;	
	statsMostClicksXML = new ActiveXObject("Microsoft.XMLHTTP");
	WsUrl = addrWebServices;
	webMethod="statsMostTagClicks"; 
	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 += "	<seederTag>"+ tagSeeder +"</seederTag>";
	soapMessage += "	<seederDate>"+ seederDate +"</seederDate>";
	soapMessage += "	<seederTime>"+ seederTime +"</seederTime>";
	soapMessage += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";
	statsMostClicksXML.onreadystatechange = sendstatsMostClicksCallback;
	statsMostClicksXML.Open("POST",WsUrl, true);        
	statsMostClicksXML.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	statsMostClicksXML.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	statsMostClicksXML.send(soapMessage);         
}
function sendstatsMostClicksCallback(){
	if (statsMostClicksXML.readyState == 4){
		if (statsMostClicksXML.status == 200){    
			var x = statsMostClicksXML.responseXML;
			var xx = x.childNodes[1].xml;
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");
			var root = xmlObject.getElementsByTagName('statsMostTagClicks')[0];			
			if ( root == null ){
				return;
			} 
			else{
				var statsResponse = root.firstChild.nodeValue;
				if ( statsResponse == 1 ){
				}
				return;
			}						
		} 
		else{
			if(retrysendstatsMostClicks < 5){
				retrysendstatsMostClicks += 1;
				sendstatsMostTagClicks(tmpassetId); 	
			}
			else{
				tmpassetId = "";
				retrysendstatsMostClicks = 0;
			}
		}
     }
}
var tmpepassLoginId, tmpprerollId;
var retrysendStatsPrerollClick = 0;
function sendStatsPrerollClick(epassLoginId, prerollId){
	tmpepassLoginId = epassLoginId;
	tmpprerollId = prerollId;
	var seederDate = "0";	
	if (getCookie("seederDate") != "" || getCookie("seederDate") != undefined ){
		seederDate = getCookie("seederDate");
	}	
	var seederTime = "0";	
	if (getCookie("seederTime") != "" || getCookie("seederTime") != undefined ){
		seederTime = getCookie("seederTime");	
	}	
    var soapMessage, WsUrl, webMethod;
	statsPrerollXML = new ActiveXObject("Microsoft.XMLHTTP");
	WsUrl = addrWebServices;
	webMethod="statsPrerollClick"; 
	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>"+ epassLoginId +"</epassLoginId>";
	soapMessage += "	<prerollId>"+ prerollId +"</prerollId>";
	soapMessage += "	<seederDate>"+ seederDate +"</seederDate>";
	soapMessage += "	<seederTime>"+ seederTime +"</seederTime>";
	soapMessage += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";
	statsPrerollXML.onreadystatechange = sendStatsPrerollClickCallback;
	statsPrerollXML.Open("POST",WsUrl, true);        
	statsPrerollXML.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	statsPrerollXML.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	statsPrerollXML.send(soapMessage);         
}
function sendStatsPrerollClickCallback(){
	if (statsPrerollXML.readyState == 4){
		if (statsPrerollXML.status == 200){    
			var x = statsPrerollXML.responseXML;
			var xx = x.childNodes[1].xml;
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");
			var root = xmlObject.getElementsByTagName('statsVideoPlayInPlaylist')[0];
			if ( root == null ){
				return;
			} 
			else{
				var statsResponse = root.firstChild.nodeValue;
				if ( statsResponse == 1 ) {
				}
				return;
			}						
		} 
		else{
			if (retrysendStatsPrerollClick < 5){
				retrysendStatsPrerollClick += 1;
				sendStatsPrerollClick( tmpepassLoginId, tmpprerollId); //retry	
			}
			else{
				tmpepassLoginId = "";
				tmpprerollId = "";
				retrysendStatsPrerollClick = 0;				
			}
		}
    }
}
var tmpepassLoginId, tmpprerollId;
var retrysendStatsPrerollView = 0;
function sendStatsPrerollView( epassLoginId, prerollId){
	tmpepassLoginId = epassLoginId;
	tmpprerollId = prerollId;
	var seederDate = "0";	
	if (getCookie("seederDate") != "" || getCookie("seederDate") != undefined ){
		seederDate = getCookie("seederDate");
	}	
	var seederTime = "0";	
	if (getCookie("seederTime") != "" || getCookie("seederTime") != undefined ){
		seederTime = getCookie("seederTime");	
	}
    var soapMessage, WsUrl, webMethod;
	statsPrerollViewXML = new ActiveXObject("Microsoft.XMLHTTP");
	WsUrl = addrWebServices;
	webMethod="statsPrerollView"; 
	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>"+ epassLoginId +"</epassLoginId>";
	soapMessage += "	<prerollId>"+ prerollId +"</prerollId>";
	soapMessage += "	<seederDate>"+ seederDate +"</seederDate>";
	soapMessage += "	<seederTime>"+ seederTime +"</seederTime>";
	soapMessage += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";
	statsPrerollViewXML.onreadystatechange = sendStatsPrerollViewCallback;
	statsPrerollViewXML.Open("POST",WsUrl, true);        
	statsPrerollViewXML.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	statsPrerollViewXML.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	statsPrerollViewXML.send(soapMessage);         
}
function sendStatsPrerollViewCallback(){
	if (statsPrerollViewXML.readyState == 4){
		if (statsPrerollViewXML.status == 200){    
			var x = statsPrerollViewXML.responseXML;
			var xx = x.childNodes[1].xml;
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");
			var root = xmlObject.getElementsByTagName('statsVideoPlayInPlaylist')[0];
			if ( root == null ){
				return;
			} 
			else{
				var statsResponse = root.firstChild.nodeValue;
				if ( statsResponse == 1 ){}
				return;
			}						
		} 
		else{
			if (retrysendStatsPrerollView < 5){
				retrysendStatsPrerollView += 1;
				sendStatsPrerollView( tmpepassLoginId, tmpprerollId); 	
			}
			else{
				tmpepassLoginId = "";
				tmpprerollId = "";
				retrysendStatsPrerollView = 0;
			}
		}
    }
}
var tmpepassLoginId, tmpassetId, tmpseederDate, tmpseederTime;
var retrysendStatsVideoPlayInPlaylist = 0;
function sendStatsVideoPlayInPlaylist( epassLoginId, assetId, seederDate, seederTime){
	tmpepassLoginId = epassLoginId;
	tmpassetId= assetId;
	tmpseederDate = seederDate;
	tmpseederTime = seederTime;
    var soapMessage, WsUrl, webMethod;
	statsVideoPlayInPlaylistXML = new ActiveXObject("Microsoft.XMLHTTP");
	WsUrl = addrWebServices;
	webMethod="statsVideoPlayInPlaylist"; 
	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>"+ epassLoginId +"</epassLoginId>";
	soapMessage += "	<assetId>"+ assetId+"</assetId>";
	soapMessage += "	<seederDate>"+ seederDate +"</seederDate>";
	soapMessage += "	<seederTime>"+ seederTime +"</seederTime>";
	soapMessage += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";
	statsVideoPlayInPlaylistXML.onreadystatechange = sendStatsVideoPlayInPlaylistCallback;
	statsVideoPlayInPlaylistXML.Open("POST",WsUrl, true);        
	statsVideoPlayInPlaylistXML.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	statsVideoPlayInPlaylistXML.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	statsVideoPlayInPlaylistXML.send(soapMessage);         
}
function sendStatsVideoPlayInPlaylistCallback(){
	if (statsVideoPlayInPlaylistXML.readyState == 4){
		if (statsVideoPlayInPlaylistXML.status == 200){    
			var x = statsVideoPlayInPlaylistXML.responseXML;
			var xx = x.childNodes[1].xml;
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");
			var root = xmlObject.getElementsByTagName('statsVideoPlayInPlaylist')[0];
			if ( root == null ){
				return;
			} 
			else{
				var statsResponse = root.firstChild.nodeValue;
				if ( statsResponse == 1 ) {
				}
				return;
			}						
		} 
		else{
			if (retrysendStatsVideoPlayInPlaylist < 5){
				retrysendStatsVideoPlayInPlaylist += 1;
				sendStatsVideoPlayInPlaylist( tmpepassLoginId, tmpassetId,tmpseederDate,tmpseederTime); 
			}
			else{
				tmpepassLoginId = "";
				tmpassetId= "";
				retrysendStatsVideoPlayInPlaylist = 0;
				tmpseederDate = "";
				tmpseederTime = "";
			}
		}
    }
}
var tmpepassLoginId;
var retrysendStatsShareContentRegister = 0;
function sendStatsShareContentRegister( epassLoginId ){
	tmpepassLoginId = epassLoginId;
	var seederDate = "0";	
	if ((getCookie("seederDate") != "") || (getCookie("seederDate") != undefined)){
		seederDate = getCookie("seederDate");
	}	
	var seederTime = "0";	
	if ((getCookie("seederTime") != "") || (getCookie("seederTime") != undefined)){
		seederTime = getCookie("seederTime");	
	}
    var soapMessage, WsUrl, webMethod;
	statsShareContentRegisterXML = new ActiveXObject("Microsoft.XMLHTTP");
	WsUrl = addrWebServices;
	webMethod="statsShareContentRegister"; 	
	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>"+ epassLoginId +"</epassLoginId>";
	soapMessage += "	<seederDate>"+ seederDate +"</seederDate>";
	soapMessage += "	<seederTime>"+ seederTime +"</seederTime>";
	soapMessage += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";
	statsShareContentRegisterXML.onreadystatechange = sendStatsShareContentRegisterCallback;
	statsShareContentRegisterXML.Open("POST",WsUrl, true);        
	statsShareContentRegisterXML.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	statsShareContentRegisterXML.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	statsShareContentRegisterXML.send(soapMessage);         
}
function sendStatsShareContentRegisterCallback(){
	if (statsShareContentRegisterXML.readyState == 4){
		if (statsShareContentRegisterXML.status == 200){    
			var x = statsShareContentRegisterXML.responseXML;
			var xx = x.childNodes[1].xml;
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");
			var root = xmlObject.getElementsByTagName('statsShareContentRegister')[0];
			if ( root == null ){
				return;
			} else {
				var statsResponse = root.firstChild.nodeValue;
				if ( statsResponse == 1 ) {
				}
				return;
			}						
		} 
		else{
			if (retrysendStatsShareContentRegister < 5){
				retrysendStatsShareContentRegister += 1;
				sendStatsShareContentRegister( tmpepassLoginId ); 	
			}
			else{
				tmpepassLoginId = "";
				retrysendStatsShareContentRegister = 0;
			}
		}
    }
}
var tmpepassLoginId, tmpassetId, tmpseederDate,tmpseederTime;
var retrysendStatsShareContentPlay = 0;
function sendStatsShareContentPlay( epassLoginId, assetId, seederDate, seederTime){
	tmpepassLoginId = epassLoginId;
	tmpassetId= assetId;	
	tmpseederDate = seederDate;
	tmpseederTime = seederTime;
    var soapMessage, WsUrl, webMethod;
	statsShareContentPlayXML = new ActiveXObject("Microsoft.XMLHTTP");
	WsUrl = addrWebServices;
	webMethod="statsShareContentPlay"; 
	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>"+ epassLoginId +"</epassLoginId>";
	soapMessage += "	<assetId>"+ assetId+"</assetId>";
	soapMessage += "	<seederDate>"+ seederDate +"</seederDate>";
	soapMessage += "	<seederTime>"+ seederTime +"</seederTime>";
	soapMessage += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";
	statsShareContentPlayXML.onreadystatechange = sendStatsShareContentPlayCallback;
	statsShareContentPlayXML.Open("POST",WsUrl, true);        
	statsShareContentPlayXML.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	statsShareContentPlayXML.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	statsShareContentPlayXML.send(soapMessage);         
}
function sendStatsShareContentPlayCallback(){
	if (statsShareContentPlayXML.readyState == 4){
		if (statsShareContentPlayXML.status == 200) {    
			var x = statsShareContentPlayXML.responseXML;
			var xx = x.childNodes[1].xml;
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");
			var root = xmlObject.getElementsByTagName('statsShareContentPlay')[0];
			if ( root == null ){
				return;
			} 
			else{
				var statsResponse = root.firstChild.nodeValue;
				if ( statsResponse == 1 ) {
				}
				return;
			}						
		} 
		else{
			if (retrysendStatsShareContentPlay < 5){
				retrysendStatsShareContentPlay += 1;
				sendStatsShareContentPlay( tmpepassLoginId, tmpassetId, tmpseederDate, tmpseederTime); 	
			}
			else{
				tmpepassLoginId = "";
				tmpassetId= "";
				retrysendStatsShareContentPlay = 0;				
				tmpseederDate = "";
				tmpseederTime = "";
			}
		}
    }
}
var tmpepassLoginId, tmpassetId, tmpseederDate, tmpseederTime;
var retrysendStatsShareContentReply = 0;
function sendStatsShareContentReply( epassLoginId, assetId, seederDate, seederTime){
	tmpepassLoginId = epassLoginId;
	tmpassetId= assetId;	
	tmpseederDate = seederDate;
	tmpseederTime = seederTime;
    var soapMessage, WsUrl, webMethod;
	statsShareContentReplyXML = new ActiveXObject("Microsoft.XMLHTTP");
	WsUrl = addrWebServices;
	webMethod="statsShareContentReply"; 
	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>"+ epassLoginId +"</epassLoginId>";
	soapMessage += "	<assetId>"+ assetId+"</assetId>";
	soapMessage += "	<seederDate>"+ seederDate +"</seederDate>";
	soapMessage += "	<seederTime>"+ seederTime +"</seederTime>";
	soapMessage += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";
	statsShareContentReplyXML.onreadystatechange = sendStatsShareContentReplyCallback;
	statsShareContentReplyXML.Open("POST",WsUrl, true);        
	statsShareContentReplyXML.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	statsShareContentReplyXML.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	statsShareContentReplyXML.send(soapMessage);         
}
function sendStatsShareContentReplyCallback(){
	if (statsShareContentReplyXML.readyState == 4){
		if (statsShareContentReplyXML.status == 200){    
			var x = statsShareContentReplyXML.responseXML;
			var xx = x.childNodes[1].xml;
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");
			var root = xmlObject.getElementsByTagName('statsShareContentReply')[0];
			if ( root == null ){
				return;
			} 
			else{
				var statsResponse = root.firstChild.nodeValue;
				if ( statsResponse == 1 ) {
				}
				return;
			}						
		} 
		else{
			if (retrysendStatsShareContentReply < 5){
				retrysendStatsShareContentReply += 1;
				sendStatsShareContentReply( tmpepassLoginId, tmpassetId, tmpseederDate, tmpseederTime); 
			}
			else{
				tmpepassLoginId = "";
				tmpassetId= "";
				retrysendStatsShareContentReply = 0;
				tmpseederDate = "";
				tmpseederTime = "";
			}
		}
    }
}
var tmpepassLoginId,tmpseederDate,tmpseederTime;
var retrysendStatsNewVisitorSession = 0;
function sendStatsNewVisitorSession(epassLoginId,seederDate,seederTime){
	tmpepassLoginId = epassLoginId;	
	tmpseederDate = seederDate;
	tmpseederTime = seederTime;	
    var soapMessage, soapData, WsUrl, webMethod;
	statsNewVisitorSessionXML = new ActiveXObject("Microsoft.XMLHTTP");
	WsUrl = addrWebServices;
	webMethod="statsNewVisitorSession"; 
	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>"+ epassLoginId +"</epassLoginId>";
	soapMessage += "	<seederDate>"+ seederDate +"</seederDate>";
	soapMessage += "	<seederTime>"+ seederTime +"</seederTime>";
	soapMessage += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";
	statsNewVisitorSessionXML.onreadystatechange = sendStatsNewVisitorSessionCallback;
	statsNewVisitorSessionXML.Open("POST",WsUrl, true);        
	statsNewVisitorSessionXML.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	statsNewVisitorSessionXML.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	statsNewVisitorSessionXML.send(soapMessage);         
}
function sendStatsNewVisitorSessionCallback(){
	if (statsNewVisitorSessionXML.readyState == 4){
		if (statsNewVisitorSessionXML.status == 200){  
			var x = statsNewVisitorSessionXML.responseXML;
			var xx = x.childNodes[1].xml;
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");
			var root = xmlObject.getElementsByTagName('statsNewVisitorSession')[0];
			if ( root == null ){		
				return;
			} 
			else{
				var statsResponse = root.firstChild.nodeValue;
				if ( statsResponse == 1 ){
				}
				return;
			}						
		} 
		else{
			if (retrysendStatsNewVisitorSession < 5){
				retrysendStatsNewVisitorSession += 1;
				sendStatsNewVisitorSession(tmpepassLoginId,tmpseederDate,tmpseederTime); //retry	
			}
			else{
				tmpepassLoginId = "";
				retrysendStatsNewVisitorSession = 0;
				tmpseederDate = "";
				tmpseederTime = "";
			}
		}
    }
}
var tmpepassLoginId, tmpassetId, tmpseederDate, tmpseederTime;
var retrysendstatsViewVideo = 0;
function sendstatsViewVideo( epassLoginId, assetId, seederDate,seederTime){
	tmpepassLoginId = epassLoginId;
	tmpassetId= assetId;	
	tmpseederDate = seederDate;
	tmpseederTime = seederTime;
    var soapMessage, soapData, WsUrl, webMethod;
	statsViewVideoXML = new ActiveXObject("Microsoft.XMLHTTP");
	WsUrl = addrWebServices;
	webMethod="statsViewVideo"; 
	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>"+ epassLoginId +"</epassLoginId>";
	soapMessage += "	<assetId>"+ assetId+"</assetId>";
	soapMessage += "	<seederDate>"+ seederDate +"</seederDate>";
	soapMessage += "	<seederTime>"+ seederTime +"</seederTime>";
	soapMessage += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";
	statsViewVideoXML.onreadystatechange = sendstatsViewVideoCallback;
	statsViewVideoXML.Open("POST",WsUrl, true);        
	statsViewVideoXML.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	statsViewVideoXML.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	statsViewVideoXML.send(soapMessage);         
}
function sendstatsViewVideoCallback(){
	if (statsViewVideoXML.readyState == 4){
		if (statsViewVideoXML.status == 200){    
			var x = statsViewVideoXML.responseXML;
			var xx = x.childNodes[1].xml;
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");
			var root = xmlObject.getElementsByTagName('statsViewVideo')[0];
			if ( root == null ){
				return;
			} 
			else{
				var statsResponse = root.firstChild.nodeValue;
				if ( statsResponse == 1 ){
				}
				return;
			}						
		} 
		else{
			if (retrysendstatsViewVideo < 5){
				retrysendstatsViewVideo += 1;
				sendstatsViewVideo( tmpepassLoginId, tmpassetId,tmpseederDate,tmpseederTime); //retry	
			}
			else{
				tmpepassLoginId = "";
				tmpassetId= "";
				retrysendstatsViewVideo = 0;
				tmpseederDate = "";
				tmpseederTime = "";
			}
		}
    }
}
var retrydispStarRated, starRatedtheId;
function dispStarRated(theId){
	var epassLoginId = getCookie("loginid");
	if(epassLoginId == ""){
		epassLoginId = "0";}	
	starRatedtheId = theId;
	XMLStarRated = false;
	XMLStarRated = new ActiveXObject("Microsoft.XMLHTTP");
	var soapMessage, webMethod;
	webMethod="findAssetVODById"; 
	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>"+ theId +"</assetId>";
	soapMessage += "    </" + webMethod + ">";
	soapMessage += "  </soap:Body>";
	soapMessage += "</soap:Envelope>";
	XMLStarRated.onreadystatechange = dispStarRatedCB;
	XMLStarRated.Open("POST",addrWebServices, true);
	XMLStarRated.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
	XMLStarRated.SetRequestHeader("SOAPAction","http://tempuri.org/" + webMethod);
	XMLStarRated.send(soapMessage);}
function dispStarRatedCB(){
	if (XMLStarRated.readyState == 4){
		if (XMLStarRated.status == 200){	
			var assetId,assetRating;
			var x = XMLStarRated.responseXML;
			var xx = x.childNodes[1].xml;
			xmlObject = (new DOMParser()).parseFromString(xx, "text/xml");
			var assetNode = xmlObject.getElementsByTagName("asset")[0];
			assetId =  assetNode.getAttribute("assetId");
			if(assetNode.getElementsByTagName("assetRating")[0].firstChild){
				assetRating =  assetNode.getElementsByTagName("assetRating")[0].firstChild.nodeValue;} 
			else{
				assetRating = "";}
			document.getElementById('divRateThisAsset3').style.display = "none";
			document.getElementById('divDisplayRatedAsset').style.display = "block";	
			document.getElementById("divDisplayRatedAsset").innerHTML = "New rating: "+displayStarRating( assetRating );}
		else{
			if (retrydispStarRated < 5){
				retrydispStarRated += 1;
				dispStarRated(starRatedtheId);}
			else{
				retrydispStarRated = 0;}}}}
// script.aculo.us slider.js v1.7.0, Fri Jan 19 19:16:36 CET 2007

// Copyright (c) 2005, 2006 Marty Haught, Thomas Fuchs 
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/

if(!Control) var Control = {};
Control.Slider = Class.create();

// options:
//  axis: 'vertical', or 'horizontal' (default)
//
// callbacks:
//  onChange(value)
//  onSlide(value)
Control.Slider.prototype = {
  initialize: function(handle, track, options) {
    var slider = this;
    
    if(handle instanceof Array) {
      this.handles = handle.collect( function(e) { return $(e) });
    } else {
      this.handles = [$(handle)];
    }
    
    this.track   = $(track);
    this.options = options || {};

    this.axis      = this.options.axis || 'horizontal';
    this.increment = this.options.increment || 1;
    this.step      = parseInt(this.options.step || '1');
    this.range     = this.options.range || $R(0,1);
    
    this.value     = 0; // assure backwards compat
    this.values    = this.handles.map( function() { return 0 });
    this.spans     = this.options.spans ? this.options.spans.map(function(s){ return $(s) }) : false;
    this.options.startSpan = $(this.options.startSpan || null);
    this.options.endSpan   = $(this.options.endSpan || null);

    this.restricted = this.options.restricted || false;

    this.maximum   = this.options.maximum || this.range.end;
    this.minimum   = this.options.minimum || this.range.start;

    // Will be used to align the handle onto the track, if necessary
    this.alignX = parseInt(this.options.alignX || '0');
    this.alignY = parseInt(this.options.alignY || '0');
    
    this.trackLength = this.maximumOffset() - this.minimumOffset();

    this.handleLength = this.isVertical() ? 
      (this.handles[0].offsetHeight != 0 ? 
        this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) : 
      (this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth : 
        this.handles[0].style.width.replace(/px$/,""));

    this.active   = false;
    this.dragging = false;
    this.disabled = false;

    if(this.options.disabled) this.setDisabled();

    // Allowed values array
    this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
    if(this.allowedValues) {
      this.minimum = this.allowedValues.min();
      this.maximum = this.allowedValues.max();
    }

    this.eventMouseDown = this.startDrag.bindAsEventListener(this);
    this.eventMouseUp   = this.endDrag.bindAsEventListener(this);
    this.eventMouseMove = this.update.bindAsEventListener(this);

    // Initialize handles in reverse (make sure first handle is active)
    this.handles.each( function(h,i) {
      i = slider.handles.length-1-i;
      slider.setValue(parseFloat(
        (slider.options.sliderValue instanceof Array ? 
          slider.options.sliderValue[i] : slider.options.sliderValue) || 
         slider.range.start), i);
      Element.makePositioned(h); // fix IE
      Event.observe(h, "mousedown", slider.eventMouseDown);
    });
    
    Event.observe(this.track, "mousedown", this.eventMouseDown);
    Event.observe(document, "mouseup", this.eventMouseUp);
    Event.observe(document, "mousemove", this.eventMouseMove);
    
    this.initialized = true;
  },
  dispose: function() {
    var slider = this;    
    Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
    Event.stopObserving(document, "mouseup", this.eventMouseUp);
    Event.stopObserving(document, "mousemove", this.eventMouseMove);
    this.handles.each( function(h) {
      Event.stopObserving(h, "mousedown", slider.eventMouseDown);
    });
  },
  setDisabled: function(){
    this.disabled = true;
  },
  setEnabled: function(){
    this.disabled = false;
  },  
  getNearestValue: function(value){
    if(this.allowedValues){
      if(value >= this.allowedValues.max()) return(this.allowedValues.max());
      if(value <= this.allowedValues.min()) return(this.allowedValues.min());
      
      var offset = Math.abs(this.allowedValues[0] - value);
      var newValue = this.allowedValues[0];
      this.allowedValues.each( function(v) {
        var currentOffset = Math.abs(v - value);
        if(currentOffset <= offset){
          newValue = v;
          offset = currentOffset;
        } 
      });
      return newValue;
    }
    if(value > this.range.end) return this.range.end;
    if(value < this.range.start) return this.range.start;
    return value;
  },
  setValue: function(sliderValue, handleIdx){
    if(!this.active) {
      this.activeHandleIdx = handleIdx || 0;
      this.activeHandle    = this.handles[this.activeHandleIdx];
      this.updateStyles();
    }
    handleIdx = handleIdx || this.activeHandleIdx || 0;
    if(this.initialized && this.restricted) {
      if((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
        sliderValue = this.values[handleIdx-1];
      if((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
        sliderValue = this.values[handleIdx+1];
    }
    sliderValue = this.getNearestValue(sliderValue);
    this.values[handleIdx] = sliderValue;
    this.value = this.values[0]; // assure backwards compat
    
    this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] = 
      this.translateToPx(sliderValue);
    
    this.drawSpans();
    if(!this.dragging || !this.event) this.updateFinished();
  },
  setValueBy: function(delta, handleIdx) {
    this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta, 
      handleIdx || this.activeHandleIdx || 0);
  },
  translateToPx: function(value) {
    return Math.round(
      ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) * 
      (value - this.range.start)) + "px";
  },
  translateToValue: function(offset) {
    return ((offset/(this.trackLength-this.handleLength) * 
      (this.range.end-this.range.start)) + this.range.start);
  },
  getRange: function(range) {
    var v = this.values.sortBy(Prototype.K); 
    range = range || 0;
    return $R(v[range],v[range+1]);
  },
  minimumOffset: function(){
    return(this.isVertical() ? this.alignY : this.alignX);
  },
  maximumOffset: function(){
    return(this.isVertical() ? 
      (this.track.offsetHeight != 0 ? this.track.offsetHeight :
        this.track.style.height.replace(/px$/,"")) - this.alignY : 
      (this.track.offsetWidth != 0 ? this.track.offsetWidth : 
        this.track.style.width.replace(/px$/,"")) - this.alignY);
  },  
  isVertical:  function(){
    return (this.axis == 'vertical');
  },
  drawSpans: function() {
    var slider = this;
    if(this.spans)
      $R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });
    if(this.options.startSpan)
      this.setSpan(this.options.startSpan,
        $R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
    if(this.options.endSpan)
      this.setSpan(this.options.endSpan, 
        $R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
  },
  setSpan: function(span, range) {
    if(this.isVertical()) {
      span.style.top = this.translateToPx(range.start);
      span.style.height = this.translateToPx(range.end - range.start + this.range.start);
    } else {
      span.style.left = this.translateToPx(range.start);
      span.style.width = this.translateToPx(range.end - range.start + this.range.start);
    }
  },
  updateStyles: function() {
    this.handles.each( function(h){ Element.removeClassName(h, 'selected') });
    Element.addClassName(this.activeHandle, 'selected');
  },
  startDrag: function(event) {
    if(Event.isLeftClick(event)) {
      if(!this.disabled){
        this.active = true;
        
        var handle = Event.element(event);
        var pointer  = [Event.pointerX(event), Event.pointerY(event)];
        var track = handle;
        if(track==this.track) {
          var offsets  = Position.cumulativeOffset(this.track); 
          this.event = event;
          this.setValue(this.translateToValue( 
           (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)
          ));
          var offsets  = Position.cumulativeOffset(this.activeHandle);
          this.offsetX = (pointer[0] - offsets[0]);
          this.offsetY = (pointer[1] - offsets[1]);
        } else {
          // find the handle (prevents issues with Safari)
          while((this.handles.indexOf(handle) == -1) && handle.parentNode) 
            handle = handle.parentNode;
            
          if(this.handles.indexOf(handle)!=-1) {
            this.activeHandle    = handle;
            this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
            this.updateStyles();
            
            var offsets  = Position.cumulativeOffset(this.activeHandle);
            this.offsetX = (pointer[0] - offsets[0]);
            this.offsetY = (pointer[1] - offsets[1]);
          }
        }
      }
      Event.stop(event);
    }
  },
  update: function(event) {
   if(this.active) {
      if(!this.dragging) this.dragging = true;
      this.draw(event);
      // fix AppleWebKit rendering
      if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
      Event.stop(event);
   }
  },
  draw: function(event) {
    var pointer = [Event.pointerX(event), Event.pointerY(event)];
    var offsets = Position.cumulativeOffset(this.track);
    pointer[0] -= this.offsetX + offsets[0];
    pointer[1] -= this.offsetY + offsets[1];
    this.event = event;
    this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
    if(this.initialized && this.options.onSlide)
      this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
  },
  endDrag: function(event) {
    if(this.active && this.dragging) {
      this.finishDrag(event, true);
      Event.stop(event);
    }
    this.active = false;
    this.dragging = false;
  },  
  finishDrag: function(event, success) {
    this.active = false;
    this.dragging = false;
    this.updateFinished();
  },
  updateFinished: function() {
    if(this.initialized && this.options.onChange) 
      this.options.onChange(this.values.length>1 ? this.values : this.value, this);
    this.event = null;
  }
}