﻿// JScript File
 var javascriptVersion1_1 = false;
javascriptVersion1_1 = true;

	 function getSearchChannels()
	 {
	    var obj;
	    obj = document.getElementById('txtsearch');
	     if(obj.value=='')
	    {
	    alert("Please enter your text");
	    }
	    if(obj.value!='')
		{
		getChannels('channels.aspx',obj.value,'search');
		
		}    
		
	  }
	  
	  
	    function getkey(e)
		{
		if (window.event){
		   if(window.event.keyCode==13)
				getSearchChannels();
		}
		else if (e)
		{
		   if(e.which==13)
			getSearchChannels();
		}
		else
		   return null;
		}
		
		
		
			 function showplugin(frmt)
	 {

		if(canDetectPlugins())
		{
				var ctlDiv = document.getElementById("LoginMsg")
				if(frmt=='RM') 
				if(!detectReal())
				{
					ctlDiv.innerHTML="<a href='http://www.download.com/RealPlayer/3000-2139_4-10255189.html' target='_blank'>Realplayer Plug-in is not installed<br>Click here to download and install Realplayer plug-in</a><br><a href='https://globalstore.real.com/rn/1019/en/gb?pcode=viewmytv&src=viewmytv&rsrc=viewmytv'>Or get the advanced RealPlayer Plus</a>"
					return false;
				}

				if(frmt=='WMV') 
				if(!detectWindowsMedia())
				{
					ctlDiv.innerHTML="<a href='http://www.microsoft.com/windows/windowsmedia/download/' target='_blank'>Windows Media Player Plug-in is not installed<br>Do you want to download Windows Media Player plug-in</a>"
					return false;
				}

				if(frmt=='FLASH') 
				if(!detectFlash())
				{
					ctlDiv.innerHTML="<a herf='http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'  target='_blank'>Flash Player Plug-in is not installed<br>Do you want to download Flash Player plug-in</a>"
					return false;
				}

				if(frmt=='QT') 
				if(!detectQuickTime())
				{
					ctlDiv.innerHTML="<a href='http://www.apple.com/quicktime/download/'  target='_blank'>QuickTime Player Plug-in is not installed<br>Do you want to download QuickTime Player plug-in</a>"
					return false;
				}

			return true;
		}
		return true;
		
		
	 }
	 
	 
	 
	 function sendComments(v,cid,userID)
	 {
        
		serverSideURL="ajax_comments.aspx?chid="  + cid
		if(v==6)
		{   
			var varName = document.getElementById("AnnName")
			var varEmail = document.getElementById("Com_Email")
			var varToadd = document.getElementById("Com_toadd")
			
			if (varName.value=='')
			{
				alert("Pleas enter your Name");
				return false;
			}
		    if (varEmail.value=='')
			{
				alert("Pleas enter your Email");
				return false;
			}
			
			if (varToadd.value=='')
			{
				alert("Pleas enter your Comments");
				return false;
			}
			var re= /<\S[^><]*>/g
			re = /\$|,|@|#|~|`|\%|\*|\^|\&|\=|\[|\]|\[|\}|\{|\;|\'|\"|\<|\>|\?/g;
            varToadd.value=varToadd.value.replace(re, "")
            if (varToadd.value.length>150)
			{
				alert("Please enter at most 150 characters");
				return false;
			}
			var serverSideURL , oK = 1
			serverSideURL="ajax_comments.aspx?chid="  + cid + "&send=7&Email=" + varEmail.value + "&AnnName=" + varName.value+ "&toadd=" + varToadd.value		
		    if(userID>0)
		    {serverSideURL="ajax_comments.aspx?chid="  + cid + "&send=7&Email=" + varEmail.value + "&AnnName=" + varName.value+ "&toadd=" + varToadd.value+ "&userID=" +userID	
		    }
		
		
		}

		if(v==1)
		{ 
			var varToadd = document.getElementById("Com_toadd")
			var varEmail ='test'; 
			//document.getElementById("Com_Email")
			
			if (varToadd.value=='')
			{
				alert("Pleas enter your comment");
				return false;
			}
		
			
			var re= /<\S[^><]*>/g
			re = /\$|,|@|#|~|`|\%|\*|\^|\&|\=|\[|\]|\[|\}|\{|\;|\'|\"|\<|\>|\?/g;
            varToadd.value=varToadd.value.replace(re, "")
            if (varToadd.value.length>150)
			{
				alert("Please enter at most 150 characters");
				return false;
			}
			//var serverSideURL , oK = 1
			//serverSideURL="ajax_comments.aspx?chid="  + cid + "&send=1&Email=" + varEmail.value + "&toadd=" + varToadd.value	
		
		    var serverSideURL , oK = 1
			serverSideURL="ajax_comments.aspx?chid="  + cid + "&send=1&Email=" + varEmail.value + "&toadd=" + varToadd.value	
		    if(userID>0)
		    {serverSideURL="ajax_comments.aspx?chid="  + cid + "&send=1&Email=" + varEmail.value +  "&toadd=" + varToadd.value+ "&userID=" +userID	
		    }
		
		
		
		}

		if (v==2)
		{
			//var un;
			//un='<%=session("username")%>';
			serverSideURL="ajax_comments.aspx?chid="  + cid + "&send=2"
            if(userID>0)
			{serverSideURL="ajax_comments.aspx?chid="  + cid + "&send=2&userID="+userID
			}
		
		}
		if(v==3)
			{ 
			serverSideURL="ajax_comments.aspx?chid="  + cid + "&send=3"
			
			}
			if(v==4)
			{
			var varToadd_br = document.getElementById("Com_toadd_br")
			var varEmail_br = document.getElementById("Com_Email_br")
			if (varToadd_br.value=='')
			{
				alert("Pleas enter your description");
				return false;
			}
			if (varEmail_br.value=='')
			{
				alert("Please enter your Email");
				return false;
			}
		   var re1= /<\S[^><]*>/g
			re1 = /\$|,|@|#|~|`|\%|\*|\^|\&|\=|\[|\]|\[|\}|\{|\;|\'|\"|\<|\>|\?/g;
            varToadd_br.value=varToadd_br.value.replace(re1, "")
            if (varToadd_br.value.length>150)
			{
				alert("Please enter at most 150 characters");
				return false;
			}
			var serverSideURL , oK = 1
			serverSideURL="ajax_comments.aspx?chid="  + cid + "&send=5&Email=" + varEmail_br.value + "&toadd=" + varToadd_br.value	
			
			}
			
			var ctlDiv = document.getElementById("divEmailFriend")
			getContent(serverSideURL,ctlDiv)
			
            if(v==1 || v==4 || v==6)
			{      setTimeout("getComm(" + cid + ")",3000*1);
				  setTimeout("showClipLinks(0," + cid + ")",10000*1);
			}
		
	 }
	 
	 function EditDesc(vid)
	 {
	    window.open("editdesc.aspx?id="+vid,"_blank","height=275,width=325,status=no,toolbar=no,menubar=no,scrollbars=no");
	 }
     

     function submitSearch()
     {
          document.search.submit();
     }


         function openchat(vid)
     {
     <!--
        var u='<%=Session("username")%>';
        //alert(u);
        if(u!='')
          window.open("CuteSoft_Client/CuteChat/CH_MainForm.aspx?Location=Lobby&LocationId=1","mywin","resizable=1,width=600,top=150,left=400,height=510")
        else
        showClipLinksnl(vid);
        -->
     }


         
       function showClipLinksnl(cid)
    {
        
       // alert("hi");
        var ctlDiv = document.getElementById("divEmailFriend")
        var strbody;
        
          //strbody = "<table width='100%'' border='0' cellspacing='0' cellpadding='0'>"
          //strbody += "<tr>"
          strbody = "<font color='red'><a href='online-tv-watch-registration.aspx'><b>To send comments you need to be a registered user.</b></a></font>"
          //strbody += "<td align='center'><font color=""red""><a href='online-tv-watch-registration.aspx'><b>To send comments you need to be a registered user.</b></a></font>"
          //strbody += "</td>"
          //strbody += "</tr>"
          //strbody += "</table>"
         // alert(strbody);
          ctlDiv.innerHTML =strbody ;
          
          setTimeout("showClipLinks(0," + cid + ")",10000*1);
    }   
     
     
    function showClipLinks(v,cid,uid)
    {
        var ctlDiv = document.getElementById("divEmailFriend")
        var strbody;
        
          strbody = "<table width='100%'' border='0' cellspacing='0' cellpadding='0'>"
          strbody += "<tr>"
          strbody += "<td align='center'>"
          strbody += "<a href='javascript:void(0);' OnMouseover=\"window.status='Email this Channel to a friend';return true;\" onclick=\"javascript:sendEmail(2,'" + cid + "');\">email to friend</a>"
          strbody += "&nbsp;|&nbsp;"
          
          if(uid>0)
          {
          strbody += "<a href='javascript:void(0);' OnMouseover=\"window.status='comment on channel';return true;\" onclick=\"javascript:EditDesc('" + cid + "');\">edit description</a>"
          strbody += "&nbsp;|&nbsp;"
          }
          strbody += "<a href='javascript:void(0);' OnMouseover=\"window.status='broken on channel';return true;\" onclick=\"javascript:sendComments(3,'" + cid + "');\">broken channel</a>"
          strbody += "</td>"
          strbody += "</tr>"
          strbody += "</table>"
         // alert(strbody);
          ctlDiv.innerHTML =strbody ;
    }			

function ImportContact()
{
    window.open("uploadcsv.aspx","_blank","height=150,width=300,status=no,toolbar=no,menubar=no,scrollbars=no");
}
	function sendEmail(v,cid)
	 {        
		serverSideURL="emailtofriend.aspx?chid="  + cid
		if(v==1)
		{
			var varToadd = document.getElementById("toadd")
			var varEmail = document.getElementById("Email")
			var varMsg = document.getElementById("txtmsg")
			
			var re= /<\S[^><]*>/g
			re = /\$|,|@|#|~|`|\%|\*|\^|\&|\=|\[|\]|\[|\}|\{|\;|\'|\"|\<|\>|\?/g;
            varMsg.value=varMsg.value.replace(re, "")
                       
			
			if (varToadd.value=='')
			{
				alert("No Email address to invite");
				return false;
			}
			var serverSideURL , oK = 1
			serverSideURL="emailtofriend.aspx?chid="  + cid + "&send=1&Email=" + varEmail.value + "&toadd=" + varToadd.value + "&Msg=" + varMsg.value;	
		}

		if (v==2)
		{

			//var un;
			//un='<%=session("username")%>';
			serverSideURL="emailtofriend.aspx?chid="  + cid + "&send=2";

		
		}

			var ctlDiv = document.getElementById("divEmailFriend")
			//alert(serverSideURL)
			getContentwithfocus(serverSideURL,ctlDiv,'toadd')
			if(v==1)
			{
			    
				setTimeout("showClipLinks(0," + cid + ")",10000*1);
			}
		
	 }
	 
	  function getComm(c)
	  {
	   frames[0].getcomments(c,1);
	 }
	function confirmsave(id)
	{
	    var serverSideURL = "ajaxaddtomytv.aspx?channelid=" + id;	    
	    var ctlDiv=document.getElementById('LoginMsg');
	    getContent(serverSideURL,ctlDiv)
	    intShow=setInterval("hideMessage()",8000)
	  }
	 
	  
	 function hideMessage()
	{
	  
	  var x  = document.getElementById("LoginMsg");
	  x.innerHTML = "";
	  clearInterval(intShow)  
	}
	
	
		function channeldel(cid)
		{
			
			var serverSideURL = "mychannels.aspx?did=" + cid; 
			var ctlDiv = document.getElementById("showChannels")
			getContent(serverSideURL,ctlDiv)
		}


	function showSavedVideos(v,usid,vid)
		  {
			document.getElementById('IfEdit').height=0;
			var serverSideURL = "ajaxbookmarks.aspx?userid=" + usid;
			
			if(v==1)
			{
			   var vid = document.getElementById("videourl");
			   var videourl = vid.value;
			   if ( vid.value == "" ){ 
				 alert("Please enter video url");
				 return true;}
			   else
			   {
				 while (videourl.indexOf("&")!=-1)
					 videourl = videourl.replace("&","***");
				 
			   }
				var serverSideURL = "ajaxbookmarks.aspx?userid=" + usid + "&video=" + videourl;	   
			}


           if(v==6)
           {
           var vid=document.getElementById("myintrest");
           var str_interst="";
           var total=""
           for(var i=0; i < document.frmmytv.myintrest.length; i++){
           if(document.frmmytv.myintrest[i].checked)
           total +=document.frmmytv.myintrest[i].value + ","
           }
           var serverSideURL = "ajaxbookmarks.aspx?save=true&userid=" + usid + "&total=" + total;
           //alert(serverSideURL)
           }
           
           
           
			if(v==2)
			{
				var serverSideURL = "ajaxbookmarks.aspx?userid=" + usid + "&did=" + vid;	   
			}
			
			var ctlDiv = document.getElementById("tab01")
			getContent(serverSideURL,ctlDiv)
			
			if (v==6)
		    {	
			setTimeout("showSavedVideos(0,0)",5000);
		    }
		

		  }
		  
		function showSavedGroups_new(v)
		{
		var ctlDiv = document.getElementById("tab01")
		ctlDiv.innerHTML="";
		document.getElementById('IfEdit').height=400;
		document.getElementById('IfEdit').src ="ajax_groups.aspx";
		if(v==2)
		{
		document.getElementById('IfEdit').src ="ajax_groups_display.aspx";
		}
		if(v==3)
		{
		document.getElementById('IfEdit').src ="user_mygroups.aspx";
		}
		if(v==4)
		{
		document.getElementById('IfEdit').src ="user_friends.aspx";
		}
		if(v==5)
		{
		document.getElementById('IfEdit').src ="user_Inbox.aspx";
		}
		if(v==6)
		{
		document.getElementById('IfEdit').src ="user_outbox.aspx";
		}
		
		}	  
		  
	function getSharedData(v)
	{
		var serverSideURL="ajaxedit.aspx"
		var ctlDiv = document.getElementById("tab01")
		ctlDiv.innerHTML="";
		document.getElementById('IfEdit').height=370;
		
		document.getElementById('IfEdit').src ="ajaxedit.aspx";
		return true;
		
		
		//alert(serverSideURL);
		if (v==1)
		{
			var welcome = document.getElementById("welcome_text")
			serverSideURL="ajaxedit.aspx?action=save&welcomemsg=" + welcome.value;
			
		}
		//alert(serverSideURL);
		var ctlDiv = document.getElementById("tab01")
		getContent(serverSideURL,ctlDiv)
		if (v==1)
		{	
			setTimeout("getSharedData(0)",5000);
		}
		
	}

	
	function ShowRssReader()
	{
	    window.open("rssreader.aspx","_blank","height=300,width=250,status=no,toolbar=no,menubar=no,scrollbars=no");
	}


	 function sendInvite(v)
	 {

		var varToadd = document.getElementById("toadd")
		var varEmail = document.getElementById("Email")
		serverSideURL="ajaxinvite.aspx"
		document.getElementById('IfEdit').height=0;
		if(v==1)
		{
			
			if (varToadd.value=='')
			{
				alert("No Email address to invite");
				return false;
			}

			var serverSideURL , oK = 1
			serverSideURL="ajaxinvite.aspx?send=1&Email=" + varEmail.value + "&toadd=" + varToadd.value	
			//alert(serverSideURL);	
		}

			var ctlDiv = document.getElementById("tab01")
			//alert(serverSideURL)	
			getContentwithfocus(serverSideURL,ctlDiv,'toadd')
		
	 }





function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}



