var searchParam = new Array();
function loadIpclSearchResult(sUrl,sId,sId2,iTabIndex,sFormID)
{
	
	$('div.show_listing').append('<span class="icpl_loading">loading..</span>');
	var str = $("form#"+sFormID).serialize();
	var	sUrl = sUrl + '&'+str;
	//onclick="alert(searchParam[\'searchStr\'])"
	searchParam['searchStr']	= str;
	
	$.get(sUrl, { time: Math.random(),tabIndex:iTabIndex},
    function(data){
		
   		var data_arr	= data.split('^^^^||||^^^^');
	    $('#'+sId2).html(data_arr[0]);
	    if(data_arr.length==3)
	    {
	    	$('#'+sId).html(data_arr[2]);
	    	$('#video_paginationLink').html(data_arr[1]);	    	
	    }
   });
}

function loadIpclPlaylistResult(sUrl,sId,sId2,iTabIndex,sFormID)
{
		
	var str = $("form#"+sFormID).serialize();
	var	sUrl = sUrl + '&'+str;
	//onclick="alert(searchParam[\'searchStr\'])"
	searchParam['searchStr']	= str;
	
	$.get(sUrl, { time: Math.random(),tabIndex:iTabIndex},
    function(data){
		
   		var data_arr	= data.split('^^^^||||^^^^');
	    $('#'+sId2).html(data_arr[0]);
	    if(data_arr.length==3)
	    {
	    	$('#'+sId).html(data_arr[2]);
	    	$('#video_paginationLink').html(data_arr[1]);	    	
	    }
   });
}




function loadIpclSearchResultOnTabClick(sId,sId2,iTabIndex,sParam)
{
   
	$('div.show_listing').append('<span class="icpl_loading">loading..</span>');
	var str	= searchParam['searchStr'];
	
	var sUrl	= "videoajax.php"
	sUrl		= sUrl+ '?sAction=tabsSearch&stingval='+iTabIndex+'&'+str;
	
	$.get(sUrl, { time: Math.random(),tabIndex:iTabIndex,extraParam:sParam},
    function(data){
   		var data_arr	= data.split('^^^^||||^^^^');
   		
	    //document.getElementById(sId2).innerHTML=data_arr[0];
	    $('#'+sId2).html(data_arr[0]);
	    if(data_arr.length==3)
	    {
	    	$('#'+sId).html(data_arr[2]);
	    	$('#video_paginationLink').html(data_arr[1]);
	    	
	    }
   });
}



function loadIpclSearchResultOnPaging(sId,sId2,iTabIndex,sParam,iPage,sOrderBy,type,selectedtab,code)
{
	selectAllTabAsUnSelected();
	$('#video_loding_msg').prepend('<span class="icpl_loading">loading..</span>');
	var str	= searchParam['searchStr'];
	
	var sUrl	= "videoajax.php"
	sUrl		= sUrl+ '?sAction=tabsSearch&stingval='+iTabIndex+'&type='+type+'&sortby='+sOrderBy+'&selectedtab='+selectedtab+'&code='+code+'&'+str;

	$.get(sUrl, { time: Math.random(),tabIndex:iTabIndex,extraParam:sParam,page:iPage,sortby:sOrderBy},
    function(data){
   		var data_arr	= data.split('^^^^||||^^^^');
	     $('#'+sId2).html(data_arr[0]);
	    if(data_arr.length==3)
	    {
	    	$('#'+sId).html(data_arr[2]);
	    	$('#video_paginationLink').html(data_arr[1]);
	    }
   });
}



function loadIpclListingOnPaging(sUrl,sId,sId2,iPage)
{
	$('div#'+sId).prepend('<span class="icpl_loading">loading..</span>');
	
	$.get(sUrl, { time: Math.random(),page:iPage},
    function(data){
   		var data_arr	= data.split('^^^^||||^^^^');
   		
	     $('#'+sId).html(data_arr[0]);
	    if(data_arr.length==2)
	    {
	    	$('#'+sId2).html(data_arr[1]);
	    }
   });
}


// Function Added For Blog Section


function ratingmusic(iMusicId , iRatingPoint)
		  {
			  
	         	  xmlHttp=GetXmlHttpObject()
				  if (xmlHttp==null)
				   {
				      alert ("Browser does not support HTTP Request")
				      return
				   }
					 var url="videoajax.php"
					 url=url+"?iMusicId="+iMusicId+"&sAction=rating"
					 url=url+"&iRatingPoint="+iRatingPoint
					 url=url+"&sid="+Math.random()					 
					 xmlHttp.onreadystatechange=stateChangedRating 
					 xmlHttp.open("POST",url,true)
					 xmlHttp.send(null)
	     }

		 function stateChangedRating() 
	      { 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			  { 
				
				 if(xmlHttp.responseText != 1)
				  {	
					document.getElementById("rating").innerHTML=xmlHttp.responseText;
				  }else{	
			 		showItemEditForm("login_div"); 
					$("#login_div").show().load( 'member.php?action=show_login_form&relocate=' + encodeURIComponent( window.location ) );	
				  }
			  } 
	 
	     }


		 



function loadIpclDynamicBlock(id,sUrl,iBlockID,pageid)
{

 
  $.get(sUrl, { time: Math.random(),pageBlock:iBlockID,divID:id},
   function(data){
   		var data_arr	= data.split('^^^^||||^^^^');
   		
	    $('div#'+id).html(data_arr[0]);
    	if(data_arr.length==2)
     	{
     		$('div#'+pageid).html(data_arr[1]);
     	}
   });
	return false;
}



function SaveMyPlayList(){

	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	}

	 if(document.getElementById('videoplaylistname').value=='' && document.getElementById('videoplaylistbox').value==''){
		alert('Please select a playlist or enter new playlist for video');
		return
     }else if(document.getElementById('videoplaylistname').value!='' && document.getElementById('videoplaylistbox').value!=''){
		 alert('Either enter playlist name or select a playlist');
		 return
     }
	
	    var playlistval=document.getElementById("videoplaylistname").value;
        var videoplaylistbox=document.getElementById("videoplaylistbox").value;		
	    var url="videoajax.php"		
		url=url+"?sAction=saveMyPlayList&listname="+playlistval+"&listbox="+videoplaylistbox			
	    url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=Saveplaylistcontent 
	    xmlHttp.open("POST",url,true)
	    xmlHttp.send(null)
	 }

function Saveplaylistcontent() 
   { 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 

	if(xmlHttp.responseText != 1)
		{				 
        alert(xmlHttp.responseText);
		ShowMyVideoPlayList();
//if( document.getElementById("savevideolistbutton").style.display='block'){
//  document.getElementById("savevideolistbutton").style.display='none';
//}
      }else{	
			showItemEditForm("login_div"); 
			$("#login_div").show().load( 'member.php?action=show_login_form&relocate=' + encodeURIComponent( window.location ) );	
		}
    } 
   }



function SaveMyPlayListListPage(){

	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	}

	 if(document.getElementById('videoplaylistname').value=='' && document.getElementById('videoplaylistbox').value==''){
		alert('Please select Playlist Name or input new playlist name');
		return
     }else if(document.getElementById('videoplaylistname').value!='' && document.getElementById('videoplaylistbox').value!=''){
		 alert('Either input playlist name or select list name from drop down');
		 return
     }
	
	    var playlistval=document.getElementById("videoplaylistname").value;
        var videoplaylistbox=document.getElementById("videoplaylistbox").value;		
	    var url="videoajax.php"		
		url=url+"?sAction=saveMyPlayList&listname="+playlistval+"&listbox="+videoplaylistbox			
	    url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=SaveplaylistcontentListpage 
	    xmlHttp.open("POST",url,true)
	    xmlHttp.send(null)
	 }

function SaveplaylistcontentListpage() 
   { 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 

	if(xmlHttp.responseText != 1)
		{				 
        alert(xmlHttp.responseText);
		loadIpclPlaylistResult("videoajax.php?sAction=showListpagePlayList",'','videolistpagecontent','0','');
      }else{	
			showItemEditForm("login_div"); 
			$("#login_div").show().load( 'member.php?action=show_login_form&relocate=' + encodeURIComponent( window.location ) );	
		}
    } 
   }



function SavePersonalPlayList(){

	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	}

	 if(document.getElementById('videoplaylistname').value=='' && document.getElementById('videoplaylistbox').value==''){
		alert('Please select Playlist Name or input new playlist name');
		return
     }else if(document.getElementById('videoplaylistname').value!='' && document.getElementById('videoplaylistbox').value!=''){
		 alert('Either input playlist name or select list name from drop down');
		 return
     }
	
	    var playlistval=document.getElementById("videoplaylistname").value;
        var videoplaylistbox=document.getElementById("videoplaylistbox").value;
		var videoidval=document.getElementById("videoidval").value;		
	    var url="videoajax.php"		
		url=url+"?sAction=saveMyPlayList&listname="+playlistval+"&listbox="+videoplaylistbox+"&videoid="+videoidval			
	    url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=SavePersonalplaylistcontent 
	    xmlHttp.open("POST",url,true)
	    xmlHttp.send(null)
	 }

function SavePersonalplaylistcontent() 
   { 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 		
	if(xmlHttp.responseText != 1)
		{				 
        alert(xmlHttp.responseText);
		ShowMyVideoPlayList();
      }else{	
			showItemEditForm("login_div"); 
			$("#login_div").show().load( 'member.php?action=show_login_form&relocate=' + encodeURIComponent( window.location ) );	
		}
    } 
   }





   function AddToPlayList(divid, videoid){ 
	document.getElementById(divid).innerHTML = 'Adding..'
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	}
	    var url="videoajax.php"		
		url=url+"?sAction=getPlayList&Videoid="+videoid+"&Divid="+divid		
	    url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=GetResponse 
	    xmlHttp.open("POST",url,true)
	    xmlHttp.send(null)
	 }

function GetResponse() 
   { 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
	
  var data_arr	= xmlHttp.responseText.split('|');
  document.getElementById(data_arr[1]).innerHTML=data_arr[0] 
  loadIpclPlaylistResult("videoajax.php?sAction=showListpagePlayList",'','videolistpagecontent','0','');
    } 
   }


    function DeletePlayList(videoid){ 
		if(!confirm('Are you sure to delete this video from playlist!'))
			return;

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	}
	    var url="videoajax.php"		
		url=url+"?sAction=deletePlayList&Videoid="+videoid		
	    url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=GetDeleteResponse 
	    xmlHttp.open("POST",url,true)
	    xmlHttp.send(null)
	 }

function GetDeleteResponse() 
   { 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 

	loadIpclPlaylistResult("videoajax.php?sAction=showListpagePlayList",'','videolistpagecontent','0','');

    } 
   }


   function DeleteListpagePlayList(videoid){ 
	if(!confirm('Are you sure to delete this video from playlist!'))
	return;

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	}
	    var url="videoajax.php"		
		url=url+"?sAction=deleteListpagePlayList&Videoid="+videoid
	    url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=GetlistpageDeleteResponse 
	    xmlHttp.open("POST",url,true)
	    xmlHttp.send(null)
	 }

function GetlistpageDeleteResponse() 
   { 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {	
	 ShowMyVideoPlayList();
    } 
   }


//Added on  6 oct 08

   function showVideoPlayer(filename)
		  {
	document.getElementById('musicplayer').innerHTML='<span style="background:#FF0000;color:#fff;padding:2px;">Processing..</span>';
	         	  xmlHttp=GetXmlHttpObject()
				  if (xmlHttp==null)
				   {
				      alert ("Browser does not support HTTP Request")
				      return
				   }
					 var url="videoajax.php"
					 url=url+"?sAction=videoplayer&file="+filename				
					 url=url+"&sid="+Math.random()					 
					 xmlHttp.onreadystatechange=showVideo 
					 xmlHttp.open("POST",url,true)
					 xmlHttp.send(null)
	     }

		 function showVideo() 
	      { 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			  { 		
				 	
					document.getElementById("musicplayer").innerHTML=xmlHttp.responseText;
				 
			  } 
	 
	     }


function ShowVideoContent(type,Catid){

	showLoaderImg('showLoader1');
	var sUrl = 'videoajax.php?sAction=getCatContent&catid='+Catid+'&type='+type;
    $.get(sUrl, {
		time: Math.random()
    }, function(data){
		document.getElementById('displayCategoryVideoListing').innerHTML = data;
		hideLoaderImg('showLoader1');
    });
/*
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	}
	    var url="videoajax.php"		
		url=url+"?type="+type+"&sAction=getVIdeoContent&catid="+Catid		
	    url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=GetTheVideoContentValue 
	    xmlHttp.open("POST",url,true)
	    xmlHttp.send(null)*/
}

function getPlayerVideoDetails(videoId)
{
	showLoaderImg('showLoader2');
	var sUrl = 'videoajax.php?sAction=getVideoDetails&videoId='+videoId;
    $.get(sUrl, {
		time: Math.random()
    }, function(data){
		document.getElementById('displayVideoDetails').innerHTML = data; 
		hideLoaderImg('showLoader2');
    });
}
function GetTheVideoContentValue() 
   { 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {  
  document.getElementById("videocontentvalue").innerHTML=xmlHttp.responseText 
    } 
   }


function ShowTabVideo(catid,catval, obj){
	var navLinks = document.getElementById('videoCatTabs').getElementsByTagName('a');
	for(i=0; i< navLinks.length; i++)
	{
		if(obj == navLinks[i])
		{
			navLinks[i].className = 'activecatgylink';
		}else
		{
			navLinks[i].className = 'catgylink';
		}
	}
	showLoaderImg('showLoader1');
	var sUrl = 'videoajax.php?sAction=getCatContent&catid='+catid+'&catval='+catval;
    $.get(sUrl, {
		time: Math.random()
    }, function(data){
		document.getElementById('displayCategoryVideoListing').innerHTML = data; 
		hideLoaderImg('showLoader1');
    });
}

function GetTheVideoValue() 
   { 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
// if( document.getElementById("savevideolistbutton").style.display='block'){
 // document.getElementById("savevideolistbutton").style.display='none';
//}
  document.getElementById("displayVideoContent").innerHTML=xmlHttp.responseText;
    } 
   }



function ShowMyVideoPlayList(){
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	}
	    var url="videoajax.php"		
		url=url+"?sAction=getMyPlayList"	
	    url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=GetVideoplaylistcontent 
	    xmlHttp.open("POST",url,true)
	    xmlHttp.send(null)
	 }

function GetVideoplaylistcontent() 
   { 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {

var playlistresponse	= xmlHttp.responseText.split('^^^^||||^^^^');
if(playlistresponse[1]!=1){
//if( document.getElementById("savevideolistbutton").style.display='none'){
//  document.getElementById("savevideolistbutton").style.display='block';  
//}
}
document.getElementById("videocontentvalue").innerHTML=playlistresponse[0];   
    } 
   }

function LoginBoxVideoDisplay(memberid) {

if(memberid==''){
	showItemEditForm("login_div"); 
	$("#login_div").show().load( 'member.php?action=show_login_form&relocate=' + encodeURIComponent( "icplvideo.php?action=add_video" ) );
	return false;
}else{
document.CreateVideoForm.submit();

}
}

function ratingvideo(iMusicId , iRatingPoint)
		  {
			  
	         	  xmlHttp=GetXmlHttpObject()
				  if (xmlHttp==null)
				   {
				      alert ("Browser does not support HTTP Request")
				      return
				   }
					 var url="videoajax.php"
					 url=url+"?iVideoId="+iMusicId+"&sAction=rating"
					 url=url+"&iRatingPoint="+iRatingPoint
					 url=url+"&sid="+Math.random()					 
					 xmlHttp.onreadystatechange=stateChangedVideoRating 
					 xmlHttp.open("POST",url,true)
					 xmlHttp.send(null)
	     }

		 function stateChangedVideoRating() 
	      { 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			  { 
				
				 if(xmlHttp.responseText != 1)
				  {	
					document.getElementById("videorating").innerHTML=xmlHttp.responseText;
				  }else{	
			 		showItemEditForm("login_div"); 
					$("#login_div").show().load( 'member.php?action=show_login_form&relocate=' + encodeURIComponent( window.location ) );	
				  }
			  } 
	 
	     }


function SaveVideoPlayList(videoid){

	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	}

	 if(document.getElementById('videoplaylistname').value=='' && document.getElementById('videoplaylistbox').value==''){
		alert('Please select Playlist Name or input new playlist name');
		return
     }else if(document.getElementById('videoplaylistname').value!='' && document.getElementById('videoplaylistbox').value!=''){
		 alert('Either input playlist name or select list name from drop down');
		 return
     }
	
	    var playlistval=document.getElementById("videoplaylistname").value;
        var videoplaylistbox=document.getElementById("videoplaylistbox").value;		
	    var url="videoajax.php"		
		url=url+"?sAction=saveVideoPlayList&listname="+playlistval+"&listbox="+videoplaylistbox+"&videoid="+videoid			
	    url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=SaveVideoListcontent 
	    xmlHttp.open("POST",url,true)
	    xmlHttp.send(null)
	 }

function SaveVideoListcontent() 
   { 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {		 
     alert(xmlHttp.responseText);
    } 
  }


function postVideoComment(iVideoId){

	   var sCommentTextValue          = $('#commentText').val();
	   var sCommentTextLength         = sCommentTextValue.length;
	   var sCommentText               = document.getElementById("commentText");
		var params = "sCommentTextValue="+sCommentTextValue+"&icplvideoId="+iVideoId ;				  
		if ( sCommentTextLength == 0 )   {
				     document.getElementById("commentText").focus();
					 $('#sMsgCounter').html('<font color = "red">Please enter text for Comment</font>');
				     return false;
			 	  }else{
                  ReverseContentDisplay('post_video_comment');
	         	  xmlHttp=GetXmlHttpObject()
				
				  if (xmlHttp==null)
				   {
				      alert ("Browser does not support HTTP Request")
				      return false;
				   }
					  var url= "videoajax.php?sAction=PostComments"
					  xmlHttp.open("POST",url,true)
					  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
					  xmlHttp.setRequestHeader("Content-length", sCommentTextValue.length);
					  xmlHttp.setRequestHeader("Connection", "close");
					  xmlHttp.onreadystatechange=PostVideoCommentMsg 
					  xmlHttp.send(params);
					  document.getElementById("commentText").value=''
}
}


function PostVideoCommentMsg() 
	      { 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			  { 
				 
				
				var outputmesgmusic	= xmlHttp.responseText.split('|');				
				document.getElementById("commentMsg").innerHTML=outputmesgmusic[0];
				//alert("Your comment successfully added.");
				document.getElementById("NoOfComments").innerHTML='['+outputmesgmusic[1]+']';
				loadIpclSearchResult("videoajax.php?sAction=viewcomments&videoid="+outputmesgmusic[2],'','viewcomments','0','');
				 
				}
				  
		} 





function loadIpclSearchResultOnComments(sId2,sParam,iPage,videoid)
{

	
	var str	= searchParam['searchStr'];
	
	var sUrl	= "videoajax.php"
	sUrl		= sUrl+ '?sAction=viewcomments&videoid='+videoid+'&'+str;

	$.get(sUrl, { time: Math.random(),extraParam:sParam,page:iPage},
    function(data){
   		var data_arr	= data.split('^^^^||||^^^^');
	     $('#'+sId2).html(data_arr[0]);
	    if(data_arr.length==3)
	    {
	    	
	    	$('#video_paginationLink').html(data_arr[1]);
	    }
   });
}



/************* function added by pramod   *********************************/

$(document).ready(function()
{
	$("#search_video_all").click(function()				
	{
		var checked_status = this.checked;
		$("input[@class=ipcl_srh_chkbx]").each(function()
		{
			this.checked = checked_status;
		});
	});

	$("#ipcl_video_search_button").click(function()				
	{
		var n = $("input:checked").length;
		if(n==0)
		{
			
			$("input[@class=ipcl_srh_chkbx]").each(function()
			{
				this.checked = true;
			});
		}
		document.getElementById('VideoSearch').submit();
	});

	$(".ipcl_video_popular_tags").click(function()				
	{
		$("input[@name=videoSearchField]").val(this.innerHTML);
		
		$("input[@class=ipcl_srh_chkbx]").each(function()
		{
			this.checked = true;
		});
		document.getElementById('VideoSearch').submit();
	});


});

function submitVideoPopularSearch(fieldVal)
{
	document.getElementById('videoSearchField').value = fieldVal;
	$("input[@class=ipcl_srh_chkbx]").each(function()
	{
		this.checked = true;
	});
	//return false;
	document.getElementById('VideoSearch').submit();
	
}

function chkSearchBox (){
		var n = $("input:checked").length;
		if(n==0)
		{
			
			$("input[@class=ipcl_srh_chkbx]").each(function()
			{
				this.checked = true;
			});
		}
}
function searchCategoryVideo(catName){
	var listname= $("li.red-nav").text();
//	listname = ltrim(listname);
	window.location = "icplvideo.php?action=VideoSearch&videoSearchField="+catName+"&searchbox[]=genre";
}

function selectAllTabAsUnSelected(){

	for(var k=1; k<8; k++){
		if(k==1 && document.getElementById('resultTab' + k))
			document.getElementById('resultTab' + k).className = 'first_one';
		else if(k==2  && document.getElementById('resultTab' + k))
			document.getElementById('resultTab' + k).className = 'second_tab';
		else if(k==3 && document.getElementById('resultTab' + k))
			document.getElementById('resultTab' + k).className = 'third_tab';
		else if(k==4 && document.getElementById('resultTab' + k))
			document.getElementById('resultTab' + k).className = 'fourth_tab';
		else if(k==5 && document.getElementById('resultTab' + k))
			document.getElementById('resultTab' + k).className = 'fifth_tab';
		else if(k==6 && document.getElementById('resultTab' + k))
			document.getElementById('resultTab' + k).className = 'sixth_tab';
		else if(k==7 && document.getElementById('resultTab' + k))
			document.getElementById('resultTab' + k).className = 'seventh_tab';
		else
			continue;
	}

}

function limitCharsVideoComment(obj)
{   
	document.getElementById("sMsgCounter").innerHTML = '';
	var mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : 500;
	if (obj.getAttribute && obj.value.length > mlength)
	{
		obj.value=obj.value.substring(0,mlength);
	}
	var iLenght = (mlength - obj.value.length) ;
	document.getElementById("sMsgCounter").innerHTML = 'You have ' + iLenght + ' characters left.';
	
}

function displaytabVideos(sSearchString, searchboxvalues, selectedTab, sortBy, page)
{
	showLoaderImg('showLoader1');
	var sUrl = 'videoajax.php?sAction=showSearchTabVideos&sSearchString='+sSearchString+'&searchboxvalues='+searchboxvalues+'&selectedTab='+selectedTab+'&sortBy='+sortBy+'&page='+page;
    $.get(sUrl, {
		time: Math.random()
    }, function(data){
		document.getElementById('displayVideoList').innerHTML = data; 
		hideLoaderImg('showLoader1');
    });
}

function validateVideoForm()
{
	var addFlag = true;
	var el = document.getElementById("VideoCat");		
	var e2 = document.getElementById("VideoTitle");
	var e3 = document.getElementById("VideoDescription");
	var e6 = document.getElementById("VideoFile");
	var e4 = document.getElementById("VideoTags");
	var e5 = document.getElementById("terms");			
	if(document.getElementById("hidUpdate") && document.getElementById("hidUpdate").value == 'update' )
		addFlag = false;

	if( el.value == '') {
		alert("Please select a genre.");
		document.getElementById("VideoCat").focus();
		return false;
	} else if( e2.value == '') {
		alert("Please enter title.");
		document.getElementById("VideoTitle").focus();
		return false;
	}else if( e3.value == '') {
		alert("Please enter description.");
		document.getElementById("VideoDescription").focus();
		return false;
	}else if( e6.value == '' && addFlag) {
		alert("Please attach a video.");
		document.getElementById("VideoFile").focus();
		return false;
	}else if( e4.value == '') {
		alert("Please enter keywords.");
		document.getElementById("VideoTags").focus();
		return false;
	}else if( e5.checked == false) {
		alert("Please check term and condition and agree to them.");
		document.getElementById("terms").focus();
		return false;
	}else{
	 document.CreateVideoForm.submit();
	}
}

function displayOwnerVideos(userID, pageNo)
{
	showLoaderImg('showLoader1');
	var sUrl = 'videoajax.php?sAction=showOwnerVideos&userID='+userID+'&page='+pageNo;
    $.get(sUrl, {
		time: Math.random()
    }, function(data){
		document.getElementById('displayVideos').innerHTML = data; 
		hideLoaderImg('showLoader1');
    });
}

