//main menu 

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

function mopen(el_id){

	mcancelclosetime();
	
	ddmenuitem = document.getElementById(el_id);
	
	ddmenuitem.style.display = "";

}

function mclose()
{
	if(ddmenuitem) ddmenuitem.style.display = 'none';
}

function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

function toggleSlide(id_name){
	$('#'+id_name).slideToggle();
}

function toggleReadMore(id_name,id_link){
	
	var el = document.getElementById(id_name);
	var el_link = document.getElementById(id_link);
	
	if(el.style.display=="none"){
		el.style.display="";
		el_link.innerHTML = "<a href=\"#\" onclick=\"toggleReadMore('"+id_name+"','"+id_link+"');return false;\">Hide</a>";
	}else{
		el.style.display="none";
		el_link.innerHTML = "<a href=\"#\" onclick=\"toggleReadMore('"+id_name+"','"+id_link+"');return false;\">Read More</a>";
	}
	
}

function toggleShowMore(id_name,id_link){
	
	
	var el = document.getElementById(id_name);
	var el_link = document.getElementById(id_link);
	
	if(el.style.display=="none"){
		el.style.display="";
		el_link.innerHTML = "<a href=\"#\" onclick=\"toggleShowMore('"+id_name+"','"+id_link+"');return false;\">Hide</a>";
	}else{
		el.style.display="none";
		el_link.innerHTML = "<a href=\"#\" onclick=\"toggleShowMore('"+id_name+"','"+id_link+"');return false;\">Show More</a>";
	}							  
}

var curContent;
var sliderOut=false;

function togglePlayerContent(content_num){
	var el_slider = document.getElementById("playerslider");
	foundItem = false;

	for(i=1;i<=2;i++){

		var el = document.getElementById('playercon'+i);
		if(i==content_num && curContent!=i){
			el.style.display="";
			foundItem = true;
		}else{
			el.style.display="none";
		}
	
	}
	
	curContent = content_num;
	
	if(foundItem && !sliderOut){ 
		$('#playerslider').slideDown('fast');
		//Effect.SlideDown(el_slider, {duration:.5}); 
		sliderOut=true; 
	}
	if(!foundItem && sliderOut){ 
		$('#playerslider').slideUp('fast');
		//Effect.SlideUp(el_slider, {duration:.5}); 
		sliderOut=false; 
		curContent=0; 
	} 
	
}

var curContentNW;
var sliderOutNW=false;

function toggleNewsContent(content_num){
	
	var el_slider = document.getElementById("nwslider");
	foundItem = false;

	for(i=1;i<=3;i++){

		var el = document.getElementById('nwcon'+i);
		if(i==content_num && curContentNW!=i){
			el.style.display="";
			foundItem = true;
		}else{
			el.style.display="none";
		}
	
	}
	
	curContentNW = content_num;
	
	if(foundItem && !sliderOutNW){ Effect.SlideDown(el_slider, {duration:.5}); sliderOutNW=true; }
	if(!foundItem && sliderOutNW){ Effect.SlideUp(el_slider, {duration:.5}); sliderOutNW=false; curContentNW=0; } 
	
}

function toggleArtistContent(content_num){
	
	var el_slider = document.getElementById("playerslider");
	foundItem = false;

	for(i=1;i<=3;i++){

		var el = document.getElementById('playercon'+i);
		if(i==content_num && curContent!=i){
			el.style.display="";
			foundItem = true;
		}else{
			el.style.display="none";
		}
	
	}
	
	curContent = content_num;
	
	if(foundItem && !sliderOut){ Effect.SlideDown(el_slider, {duration:.5}); sliderOut=true; }
	if(!foundItem && sliderOut){ Effect.SlideUp(el_slider, {duration:.5}); sliderOut=false; curContent=0; } 
	
}

var toggled = false;
function expandAllListing(classname){
	
	if(toggled == false){
		var els = getElementsByClassName(classname);
		for(var i=0;i<els.length;i++){
			els[i].style.display = "";	
		}
		toggled = true;
		$('#expand').hide();
		$('#collapse').show();
	}else if(toggled == true){
		var els = getElementsByClassName(classname);
		for(var i=0;i<els.length;i++){
			els[i].style.display = "none";	
		}
		toggled = false;
		$('#expand').show();
		$('#collapse').hide();
	}
	
}

function launchSendToFriend(filename, width){
		var args = "filename="+filename;
		window.open("/sendtofriend.html?mode=video&"+args+"", 'Photo_Popup', 'width='+width+', height=400, top=125, screenY=125, left=150, screenX=150, menubar=no, toolbar=no, location=no, directories=no, scrollbars=yes, resizable=yes');

}

function launchSendPicToFriend(filename, width){
		var args = "filename="+filename;
		window.open("/sendtofriend.html?mode=photo&"+args+"", 'Photo_Popup', 'width='+width+', height=400, top=125, screenY=125, left=150, screenX=150, menubar=no, toolbar=no, location=no, directories=no, scrollbars=yes, resizable=yes');

}

function launchSendPlaylistToFriend(filename, width){
		var args = "filename="+filename;
		window.open("/sendtofriend.html?mode=playlist&"+args+"", 'Photo_Popup', 'width='+width+', height=400, top=125, screenY=125, left=150, screenX=150, menubar=no, toolbar=no, location=no, directories=no, scrollbars=yes, resizable=yes');

}

function launchContestTerms(contest){
	window.open("/contest_terms.html?contest_name="+contest+"", 'Contest_Terms', 'width=500, height=400, top=125, screenY=125, left=150, screenX=150, menubar=no, toolbar=no, location=no, directories=no, scrollbars=yes, resizable=yes');
	
}

function launchSendArticleToFriend(filename, width){
		var args = "filename="+filename;
		window.open("/sendtofriend.html?mode=article&"+args+"", 'Photo_Popup', 'width='+width+', height=450, top=125, screenY=125, left=150, screenX=150, menubar=no, toolbar=no, location=no, directories=no, scrollbars=yes, resizable=yes');

}

function getElementsByClassName(classname) {

node = document.getElementsByTagName("body")[0];

var a = [];

var re = new RegExp('\\b' + classname + '\\b');

var els = node.getElementsByTagName("*");

for(var i=0,j=els.length; i<j; i++)

if(re.test(els[i].className))a.push(els[i]);

return a;

}

function add_member_group(user_ID, serie){
	$.ajax({
	   type: "GET",
	   url: "/ajax_artiste.php",
	   data: 'action=add&user_ID='+user_ID+'&serie='+serie,
	   success: function(data){
		   	$('#becomefan').hide();
			$('#notfan').hide();
			$('#fan').show();
	
			var numfans = $('#numfans');
			var num = numfans.html();
			num = parseInt(num.replace(/\,/, ''));
			$('#numfans').text(addCommas(num+1));
	   }
	 });
}


function remove_member_group(user_ID, serie, id){
	$.ajax({
	   type: "GET",
	   url: "/ajax_artiste.php",
	   data: 'action=delete&user_ID='+user_ID+'&serie='+serie+'&id='+id,
		success: function(data){
			$("div[id='fanserie_"+id+"']").fadeOut();
		}
	 });
}

function add_member_group2(user_ID, serie){
	$.ajax({
	   type: "GET",
	   url: "/ajax_artiste.php",
	   data: 'action=add&user_ID='+user_ID+'&serie='+serie,
	   success: function(data){
			$('#notfan').hide();
			$('#fan').show();
	   }
	 });
}

function newsletter_add(){
	var email = $('#form_text').val();
	//alert(filename + ' ' + type + ' ' + userID);
	if(email == ""){
		alert('Vous devez entrer un e-mail!');
	}else{
		$.ajax({
			type: "GET",
			url: "/ajax_newsletter.php",
			data: 'email='+encodeURIComponent(email),
			success: function(data){
				$('#newsletter_successmessage').show();
				$('#newsletter_errormessage').text("Merci pour votre abonnement ! Vous allez recevoir un email de confirmation");
				$('#footerboxnewsletter').hide();
			}
		});
	}
}

function contact_add(){
	var email = $('#email').val();
	var sujet = $('#sujet').val();
	var msg = $('#msg').val();
	sujet = sujet.replace(//g, "htmleurosymbole");
	sujet = sujet.replace(//g, "htmloeligsymbole");
	msg = msg.replace(//g, "htmleurosymbole");
	msg = msg.replace(//g, "htmloeligsymbole");
	//alert('email='+encodeURIComponent(email)+'&sujet='+encodeURIComponent(sujet)+'&msg='+msg);
	if(email == ""){
		alert('Vous devez entrer votre e-mail !');
	}else{
		$.ajax({
			type: "POST",
			url: "/ajax_contact.php",
			data: 'email='+encodeURIComponent(email)+'&sujet='+encodeURIComponent(sujet)+'&msg='+encodeURIComponent(msg),
			success: function(data){
				$('#contact_successmessage').show();
				$('#contact_errormessage').text("Merci pour votre message !");
				$('#footerboxcontact').hide();
			}
		});
	}
}


function referencer_add(){
	var ser_titre = $('#titre').val();
	var ser_genre = $('#genre').val();
	var ser_site = $('#ser_site').val();
	var ser_flux = $('#ser_flux').val();
	var ser_first_dif = $('#ser_first_dif').val();
	var ser_synopsis = $('#synopsis').val();
	var ser_producteur = $('#producteur').val();
	var ser_realisateur = $('#realisateur').val();
	var ser_acteurs = $('#acteurs').val();
	var ser_photo = $('#ser_photo').val();
	ser_titre = ser_titre.replace(//g, "htmleurosymbole");
	ser_titre = ser_titre.replace(//g, "htmloeligsymbole");
	ser_synopsis = ser_synopsis.replace(//g, "htmleurosymbole");
	ser_synopsis = ser_synopsis.replace(//g, "htmloeligsymbole");
	ser_producteur = ser_producteur.replace(//g, "htmleurosymbole");
	ser_producteur = ser_producteur.replace(//g, "htmloeligsymbole");
	ser_realisateur = ser_realisateur.replace(//g, "htmleurosymbole");
	ser_realisateur = ser_realisateur.replace(//g, "htmloeligsymbole");
	ser_acteurs = ser_acteurs.replace(//g, "htmleurosymbole");
	ser_acteurs = ser_acteurs.replace(//g, "htmloeligsymbole");
	//alert('ser_titre='+encodeURIComponent(ser_titre)+'&ser_genre='+encodeURIComponent(ser_genre)+'&ser_site='+encodeURIComponent(ser_site)+'&ser_first_dif='+encodeURIComponent(ser_first_dif)+'&ser_flux='+encodeURIComponent(ser_flux)+'&ser_synopsis='+encodeURIComponent(ser_synopsis)+'&ser_producteur='+encodeURIComponent(ser_producteur)+'&ser_realisateur='+encodeURIComponent(ser_realisateur)+'&ser_acteurs='+encodeURIComponent(ser_acteurs));
	if(ser_titre == ""){
		alert('Vous devez ajouter le nom de la web-serie !');
	}else{
	if(ser_flux == ""){
		alert('Vous devez ajouter le lien des videos !');
	}else{
			$.ajax({
				type: "POST",
				url: "/ajax_referencer.php",
				data: 'ser_titre='+encodeURIComponent(ser_titre)+'&ser_genre='+encodeURIComponent(ser_genre)+'&ser_site='+encodeURIComponent(ser_site)+'&ser_first_dif='+encodeURIComponent(ser_first_dif)+'&ser_flux='+encodeURIComponent(ser_flux)+'&ser_synopsis='+encodeURIComponent(ser_synopsis)+'&ser_producteur='+encodeURIComponent(ser_producteur)+'&ser_realisateur='+encodeURIComponent(ser_realisateur)+'&ser_acteurs='+encodeURIComponent(ser_acteurs)+'&ser_photo='+encodeURIComponent(ser_photo),
				success: function(data){
					$('#contact_successmessage').show();
					$('#contact_errormessage').text("Merci !");
					$('#footerboxcontact').hide();
				}
			});
		}
	}
}



//Comments
function show_comment_block(block, num){
	var block = document.getElementById(block);
	block.style.display = 'block';
	
	var current_block_num = document.getElementById('current_block_num');
	 var current_block = document.getElementById('comment_block_'+current_block_num.value+'');
	 current_block.style.display = 'none';	
	 
	 current_block_num.value = num;
}

function show_comment_block2(block, num, start, end, total, comm_per_page, total_comms){
	var current_block_num = document.getElementById('current_block_num');
	if (num != current_block_num.value){
		//alert(current_block_num.value);
		//Set block to viewable
		 var block = document.getElementById(block);
		 block.style.display = 'block';
		 var current_block_num = document.getElementById('current_block_num');
		 var current_block = document.getElementById('comment_block_'+current_block_num.value+'');
		 current_block.style.display = 'none';	
		 current_block_num.value = num;
		 //return(true);
		 //update the showing text
		  
		 var start_comm = (comm_per_page * (num-1)) + 1;
		 
		 if (num == total){
		 	var end_comm = total_comms;
		 }else{
		 	var end_comm = (comm_per_page * num);
		 }
		 
		 var showing = 'De ' + start_comm + '-' + end_comm + ' sur ' + total_comms;
		 //alert(showing);

 		 var showing1 = document.getElementById('showing1');
		 var showing2 = document.getElementById('showing2');
		 
		 showing1.innerHTML = showing;
		 showing2.innerHTML = showing;
		 
		 //update the pagination
		 var pagination1 = document.getElementById('comment_pagination_1');
		 var pagination2 = document.getElementById('comment_pagination_2');
		 
		 
		 var max_links = (end - start) + 1;
		 
		 var pagination_text = '';
		 
		 for (x=start; x<=end; x=x+1){
		 
		 	if (x == num){
		 		pagination_text = pagination_text + '<li class="active">' + x;
		 	
		 	}else{
		 	
		 		if (x < Math.ceil(max_links/2)){
					var pstart = 1;
					var pend = max_links;
					
					//alert('ONE: ' + i + ' - ' + start + ' - ' + end);
				
				}else if(x > (total - (max_links/2))){
					var pend = total;
					var pstart = total - (max_links-1);
					
					//alert('TWO: ' + x + ' - ' + start + ' - ' + end);
				
				}else{
					//$start = $i - floor(($max_links-1)/2) + 1;
					//$end = $i + floor(($max_links-1)/2);
					var pstart = x - Math.floor((max_links-1)/2);
					var pend = x + Math.floor(max_links/2);
					
					//alert('THREE: ' + x + ' - ' + start + ' - ' + end);
				
				}
		 	
		 		pagination_text = pagination_text + '<li>';
		 		
		 		pagination_text = pagination_text + '<a href="" onclick="show_comment_block2(\'comment_block_' + x + '\', ' + x + ', ' + pstart + ', ' + pend + ', ' + total +', ' + comm_per_page + ',' + total_comms + '); return false;">' + x + '</a>';
		 	}

		 	if (x<end){
		 		pagination_text = pagination_text + '&nbsp;|&nbsp;';
		 	}
		 	pagination_text = pagination_text + '</li>';
		 
		 }
		 
		pagination_text = pagination_text + '<li> &nbsp; of ' + total + '</li>';
		
		//alert(pagination_text);
		
		pagination1.innerHTML = pagination_text;
		pagination2.innerHTML = pagination_text;
	
	} //end if num!=
}



function submit_comment(filename, type, userID){
	var comment = $('#comment-ta-sm').val();
	if(userID ==""){
		alert('Vous devez vous connecter pour poster un commentaire');
	}else{
		//alert(filename + ' ' + type + ' ' + userID);
		if(comment == ""){
			alert('Vous devez entrer un commentaire!');
		}else{
			if(userID > 0){
				$.ajax({
				   type: "GET",
				   url: "/ajax_commentaire.php",
				   data: 'userID='+encodeURIComponent(userID)+'&&comment='+encodeURIComponent(comment)+'&type='+encodeURIComponent(type)+'&filename='+encodeURIComponent(filename),
				   success: function(data){
					
					$('#commentform2').html(data)
					var commentnum = $('#commentnum');
					var num = commentnum.html();
					num = parseInt(num.replace(/\,/, ''));
					$('#commentnum').text(addCommas(num+1));
					updateComments(filename);
					updateCommentForm(filename);
				   }
				 });
			}else{
				alert('Vous devez entrer un commentaire.');
			}
		}
	}
}
//END Comments


//Stars

starsEnabled = true;
rated = false;

function starSet(num,showHover){
	if(starsEnabled){
		var hover_txt = document.getElementById('star_hover_text');
		
		if(!showHover){
			hover_txt.innerHTML = "";
		}else{
			switch(num){
			  case(1):
			  hover_txt.innerHTML = "Nul";
			  break;
			  case(2):
			  hover_txt.innerHTML = "Bof";
			  break;
			  case(3):
			  hover_txt.innerHTML = "Moyen";
			  break;
			  case(4):
			  hover_txt.innerHTML = "Bon";
			  hover_txt.innerHTML = "Bon";
			  break;
			  case(5):
			  hover_txt.innerHTML = "Le Top";
			  break;
		   }
		}
		
		for(i=1;i<=5;i++){
			
			var star = document.getElementById('star'+i);
			
			if(i<=num){
				star.className = "one_star";
			}else{
				star.className = "three_star";	
			}
		}
	}
	
}

function starSetLock(num){
		
		starsEnabled = false;
		
		for(i=1;i<=5;i++){
			
			var star = document.getElementById('star'+i);
			
			if(i<=num){
				star.className = "one_star_lock";
			}else{
				star.className = "three_star";	
			}
		}
	
}

function setStarRating(rating,filename,userID, type){
	if(type=='')type = 'video';
	starSetLock(rating)
	$.ajax({
  		   type: "POST",
		   url: "/ajax_vote.php",
		   data: 'filename='+filename+'&userID='+userID+'&rating='+rating+'&type='+type,
		   success: function(data){
				starRatingSet();
		   }
		 });
}

var starRatingSet = function(t) {
	var hover_txt = document.getElementById('star_hover_text');
	hover_txt.innerHTML = "Merci !";
	if(!$rating && rated!=true){
		rated=true;
		var num = $('#total_ratings').html();
		num = parseInt(num.replace(/\,/, ''));
		$('#total_ratings').text(addCommas(num+1));
	}
}

function convert(x)
{
  var _x=x.toString();
  var _len=_x.length;
  var _ret="";
  for(var i=_len;i>0;i--)
  {
    if(!((_len-i)%3))
    {
      _ret=","+_ret;
    }
    _ret=_x[i-1]+_ret;
  }
  _ret=_ret.substr(0,_ret.length-1);
  return _ret;
} 


function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}
//END Stars

function change_parent_url(url){
   document.location=url;
}	


//Watching Starts
function watching_refresh(){
	//alert('test');
	$.ajax({
   type: "GET",
   url: "/ajax_watchinglive.php",
   data: "",
   success: function(data){
     $('#watching').html(data);
	 $('#watchingmessage').css("display", "block");
	 $('#watchingmessage').effect('highlight', {}, 3000);
	 $('#watchingmessage').effect('clip');
	 restart_timer();
   }
 });
}


function reportProblem(){

	var requiredMajorVersion = 8;
	// Minor version of Flash required
	var requiredMinorVersion = 0;
	// Minor version of Flash required
	var requiredRevision = 0;

	var flashvar;
	flashvar = GetSwfVer();
	
	$.ajax({
	   type: "GET",
	   url: "/ajax_log_problem.php",
	   data: 'flashver='+flashvar+'&problem='+$('#playerdebugger').html(),
	   success: function(data){
			togglePlayerContent(6);
			//new Effect.Highlight(bugform, { startcolor: "#ff0000", duration: 2});
			$('#bugform').html('Merci! Nous sommes desol&eacute; de ce d&eacute;sagr&eacute;ment et nous ferons de notre mieux pour le r&eacute;soudre rapidement.');
			$('#bugform').effect('highlight', {}, 3000);
			setTimeout('redirect();', 3000);
	   }
	 });

}

							
function restart_timer(){
	setTimeout(watching_refresh, 10000);
}
//End Watching


//Start Favorites
function removeFavorite(user_ID, filename){

	$('#'+filename).fadeOut();
	$.ajax({
   type: "GET",
   url: "/ajax_favorites.php",
   data: 'action=remove&filename='+filename+'&user_ID='+user_ID,
   success: function(data){ }
	});
}

function addtoFavorites(user_ID, filename){
	if(user_ID < 0 || user_ID == ""){
		togglePlayerContent(2);
		$('favform').html('<span></span>');
	}else{
		$.ajax({
		   type: "POST",
		   url: "/ajax_favorites.php",
		   data: "action=add&user_ID=" + user_ID + "&filename=" + filename,
		   success: function(data){ 
			   favorites_added();
			   }
		   });
	}	
}

function favorites_added() {
	
	$('#favform').html('Clip ajoutι aux favoris !');
	$('#removefav').show();
	$('#addfav').hide();
			
	//urchinTracker("/favorites_added.html");
			
	var numfans = $('#favoritenum');
	var num = numfans.html();
	num = parseInt(num.replace(/\,/, ''));
	$('#favoritenum').text(addCommas(num+1)); 
	togglePlayerContent(2);
}

function removeFavorites(user_ID, filename){
	if(user_ID < 0){
		togglePlayerContent(2);
		$('favform').html('You must be logged in to add Favorites. <a href="/login/?redirect_to='+location.href+'" style="color:white">Login Here</a>');
	}else{
		$.ajax({
		   type: "POST",
		   url: "/ajax_favorites.php",
		   data: "action=remove&user_ID=" + user_ID + "&filename=" + filename,
		   success: function(data){ 
			   favorites_removed();
			   }
		   });
	}	
}

function favorites_removed() {
	
	$('#favform').html('Clip retirι des favoris !');
	$('#removefav').hide();
	$('#addfav').show();
			
	urchinTracker("/favorites_added.html");


	var numfans = $('#favoritenum');
	var num = numfans.html();
	num = parseInt(num.replace(/\,/, ''));
	$('#favoritenum').text(addCommas(num-1)); 
	
	togglePlayerContent(2);
}
//End Favorites


//Playlist
//Functions to add tags
function addPlaylist(filename, userID){
	playlist_id = $('#existingplaylist').val();

	if(userID > 0  && filename != ''){
		$.ajax({
		   type: "GET",
		   url: "/ajax_playlist.php",
		   data: 'action=add&playlist_id='+playlist_id+'&userID='+userID+'&filename='+filename,
		   success: function(data){
				playlistFormUpdate(data);
		   }
		 });
	}else{
		alert('You Must Login to Add a video to a playlist.');
		$('#playlistname').effect('highlight', "#ff0000", 10000);
		// startcolor: , duration: 10});
	}
}

function addtoNewPlaylist(filename, userID){
	var playlistname = $('#playlistname').val();
 	if(playlistname != ''){
		if(userID > 0  && filename != ''){
			$.ajax({
				type: "GET",
			   	url: "/ajax_playlist.php",
				data: 'action=addtonew&playlistname='+playlistname+'&userID='+userID+'&filename='+filename,
			   	success: function(data){
					playlistFormUpdate(data);
			   	}
			 });
		}else{
			alert('You Must Login to Add a video to a playlist.');
		}
	}else{
		alert('Playlist name cannot be blank.  Please enter a title.');
	}
}


//Need two functions because we can add suggested videos and artists videos from the player page and need to update similar code with same ids
function addPlaylist2(filename, userID){
	var playlist_id = $('#existingplaylist2').val();
	if(userID > 0  && filename != ''){
			$.ajax({
			   type: "GET",
			   url: "/ajax_playlist.php",
			   data: 'action=add&playlist_id='+playlist_id+'&userID='+userID+'&filename='+filename,
			   success: function(data){
					playlistFormUpdate2(data);
			   }
			 });
	}else{
		alert('You Must Login to Add a video to a playlist.');
	}
}

function addtoNewPlaylist2(filename, userID){
	
	var playlistname = $('#playlistname2').val();
	if(playlistname != ''){
		if(userID > 0  && filename != ''){
			$.ajax({
			   type: "GET",
			   url: "/ajax_playlist.php",
			   data: 'action=addtonew&playlistname='+playlistname+'&userID='+userID+'&filename='+filename,
			   success: function(data){
					playlistFormUpdate2(data);
			   }
			 });
		}else{
			alert('You Must Login to Add a video to a playlist.');
		}
	}else{
		alert('Playlist name cannot be blank.  Please enter a title.');
		$('plalylistname2').effect('highlight', {}, 10000);
		//new Effect.Highlight('playlistname2', { startcolor: '#ff0000', duration: 10});
	}
}


function removePlaylist(IDvideo, filename, userID, playlist_id, item_id){
	if(userID > 0 ){
			$.ajax({
			   type: "GET",
			   url: "/ajax_playlist.php",
			   data: 'action=remove&filename='+filename+'&userID='+userID+'&item_id='+item_id+'&playlist_id='+playlist_id,
			   success: function(data){
					$("li[name='"+IDvideo+"']").fadeOut();
			   }
			 });

	}else{
		alert('You Must Login to Remove a video from your playlist.');
	}
}

function deletePlaylist(userID, playlist_id){
	if(userID > 0 ){
		$.ajax({
		   type: "GET",
		   url: "/ajax_playlist.php",
		   data: 'action=delete&playlist_id='+playlist_id+'&userID='+userID,
		   success: function(data){
	   			$('#playlist_'+playlist_id).fadeOut(700);
		   }
		 });
	}else{
		alert('You Must Login to Remove a video from your playlist.');
	}

}

function playlistFormUpdate(data){
	$('#playlistform').hide();
	$('#playlistmessage').text(data);
	setTimeout("parent.$.fn.colorbox.close()", 1500);
}

function playlistFormUpdate2(data){
	$('#playlistform2').hide();
	$('#playlistmessage2').text(data);
	$('#playlistmessage2').effect('highlight', {}, 1500);
	setTimeout("parent.$.fn.colorbox.close()", 1500);
}
//End Playlist
