   var http_request = false;
   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('mycommentspan').innerHTML = result;
         } else {
            //alert('There was a problem with the request.');
			document.getElementById('mycommentspan').innerHTML = 'There was a problem with the request. Please contact us and report this problem!';
         }
      }
   }
   
   function get(obj) {
	   
	  var poststr;
	  if(document.getElementById("user_id").value == 0)
	  {
		 poststr = "comment_txt=" + encodeURI( document.getElementById("comment_txt").value ) +
                    "&vid=" + encodeURI( document.getElementById("vid").value ) +
					"&user_id=" + encodeURI( document.getElementById("user_id").value ) +
					"&username=" + encodeURI( document.getElementById("username").value ) +
					"&captcha=" + encodeURI( document.getElementById("captcha").value );
	  }
	  else {
		 poststr = "comment_txt=" + encodeURI( document.getElementById("comment_txt").value ) +
		 			"&user_id=" + encodeURI( document.getElementById("user_id").value ) +
                    "&vid=" + encodeURI( document.getElementById("vid").value );
	  }
	  
      makePOSTRequest(''+MELODYURL+'/comment.php', poststr);
   }

function submitonce(theform){
//if IE 4+ or NS 6+
	if(document.getElementById("user_id").value != 0)
	{
		if(document.getElementById("comment_txt").value == '' || document.getElementById("comment_txt").value == "test"){
			//alert('You need to write a comment first!');
		}
		else{
			if (document.all||document.getElementById){
				//screen thru every element in the form, and hunt down "submit" and "reset"
				for (i=0;i<theform.length;i++){
					var tempobj=theform.elements[i]
					if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
					//disable em
					tempobj.disabled=true;
				}
				//theform.style.display='none';
				$(theform).slideUp('normal');
			}
		}
	}
	else
	{
		//	guest comment
		var alert_msg = '';
		if(document.getElementById("comment_txt").value == ''){
			//alert('You need to write a comment first!');
			alert_msg = alert_msg+'You need to write a comment first!\n';
		}
		if(document.getElementById("username").value == '' || document.getElementById("captcha").value == ''){
			alert_msg = alert_msg+'Please fill in the required fields.\n';
		}
		
		if(alert_msg != '') {
			//alert(alert_msg);
		}
		else{
			if (document.all||document.getElementById){
				//screen thru every element in the form, and hunt down "submit"
				for (i=0;i<theform.length;i++){
					var tempobj=theform.elements[i]
					if(tempobj.type.toLowerCase()=="submit")
					//disable em
					tempobj.disabled=false;
				}
				//theform.style.display='none';
				$(theform).slideUp('normal');
			}
		}	
	}
	
}

function validateSearch(b_on_submit){
    if(document.forms['search'].keywords.value == '' || document.forms['search'].keywords.value == 'search'){
        alert('You did not enter a search term. Please try again.');
        if(b_on_submit == 'true')
            return false;
    }
    else{
        document.forms['search'].submit();
    }
}
function lookup(inputString) {
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$('#suggestions').hide();
	} else if(inputString.length > 2) {
		$.post(MELODYURL2+'/ajax_search.php', {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
				$('#suggestions').show();
				$('#autoSuggestionsList').html(data);
			}
		});
	}
} // lookup
	
function catlist()
{
	$("#ul_categories li").hoverIntent(
	 function(){
			var ul_subs = $(this).find('ul');
			
			if(ul_subs.hasClass("hidden_li"))
			{	
				ul_subs.removeClass();
				ul_subs.slideDown(80);
				ul_subs.addClass('visible_li')
			}
	 }, 
	 function(){
			var ul_subs = $(this).find('ul');
			
			if(ul_subs.hasClass("visible_li"))
			{
				ul_subs.addClass("hidden_li");	
				ul_subs.slideUp(150);
				ul_subs.removeClass('visible_li');
			}
	 });

}

function fill(thisValue) {
	$('#inputString').val(thisValue);
	setTimeout("$('#suggestions').hide();", 200);
}

function ajax_request(page, extra_params, output_sel, type, show) {
	
	var ret = false;
	
	if (type.length == 0)
	{
		type = "html";	
	}

	if (output_sel.length > 0)
	{
		$(output_sel).html('<img src="'+TemplateP+'/images/ajax-loading.gif" alt="Loading" id="loading" />Loading...').fadeIn('normal');	
	}
	$.ajax({
		   type: "GET",
		   url: MELODYURL2 + "/ajax.php", 
		   //cache: false, 
		   data: "p=" + page + "&" + extra_params,
		   dataType: type,
		   success: function(data) {
						if (output_sel.length > 0)
						{
							$(output_sel).html(data);
							
							if (show == true)
							{
								$(output_sel).show();
							}
						}
						ret = true;
					}
		   });
	
	return ret;
}

function onpage_delete_comment(comment_id, video_id, selector) {

	var confirm_msg = "You are about to delete this comment. Click 'Cancel' to stop, 'OK' to delete";
	var response = false;
	
	if (confirm(confirm_msg)) 
	{
		if (selector.length > 0) 
		{
			ajax_request("comments", "do=onpage_delete_comment&cid=" + comment_id + "&vid=" + video_id, "", "", false);
			$(selector).fadeOut('normal');
		}
	}
}

function onpage_delete_favorite(video_id, selector) {

	var response = false;

		if (selector.length > 0) 
		{
			ajax_request("favorites", "do=onpage_delete_favorite&vid=" + video_id, "", "", false);
			$(selector).fadeOut("slow");
		}
}

var arPlayer = null;
var arDone = false;
function reportNotFound(uid) {
	if (uid.length > 0 && !arDone) {
		ajax_request("video", "do=report&vid=" + uid, "", "", false);
		arDone = true;
	}
}
function onStreamNotFound(clip) {
	reportNotFound(clip.name);	
}
function triggerPlayerError(obj) {
	reportNotFound(arPlayer.id);
}
function playerReady(obj) {
	arPlayer = document.getElementById(obj['id']);
	arPlayer.addModelListener("ERROR", "triggerPlayerError");
}


this.screenshotPreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "CLIP MIZIK TV";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='screenshot'>  <embed height='262' src='http://www.clip-mizik.tv/fpembed-"+ this.rel +".swf' width='329' wmode='transparent'></embed>"+ c +"</p>");
		
										 
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

// starting the script on page load
$(document).ready(function(){
	screenshotPreview();
});




$(document).ready(function(){
	
	$(".accordion2 h3").eq(2).addClass("active");
	$(".accordion2 p").eq(2).show();

	
	$(".accordion2 h3").click(function(){
		$(this).next("p").slideToggle("slow")
		.siblings("p:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
		
	});
});
$(document).ready(function(){
	
	$(".accordion3 h3").eq(2).addClass("active");
	$(".accordion3 p").eq(2).show();

	
	$(".accordion3 h3").click(function(){
		$(this).next("p").slideToggle("slow")
		.siblings("p:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
		
	});
});

 //SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;
var popupStatus2 = 0;
var popupStatus3 = 0;
var popupStatus4 = 0;
//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");
		popupStatus = 1;
	}
}
function loadPopup2(){
	//loads popup only if it is disabled
	if(popupStatus2==0){
		$("#backgroundPopup2").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup2").fadeIn("slow");
		$("#popupContact2").fadeIn("slow");
		popupStatus2 = 1;
	}
}
function loadPopup3(){
	//loads popup only if it is disabled
	if(popupStatus3==0){
		$("#backgroundPopup3").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup3").fadeIn("slow");
		$("#popupContact3").fadeIn("slow");
		popupStatus3 = 1;
	}
}
function loadPopup4(){
	//loads popup only if it is disabled
	if(popupStatus4==0){
		$("#backgroundPopup4").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup4").fadeIn("slow");
		$("#popupContact4").fadeIn("slow");
		popupStatus4 = 1;
	}
}
//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}
//disabling popup with jQuery magic!
function disablePopup2(){
	//disables popup only if it is enabled
	if(popupStatus2==1){
		$("#backgroundPopup2").fadeOut("slow");
		$("#popupContact2").fadeOut("slow");
		popupStatus2 = 0;
	}
}
//disabling popup with jQuery magic!
function disablePopup3(){
	//disables popup only if it is enabled
	if(popupStatus3==1){
		$("#backgroundPopup3").fadeOut("slow");
		$("#popupContact3").fadeOut("slow");
		popupStatus3 = 0;
	}
}
//disabling popup with jQuery magic!
function disablePopup4(){
	//disables popup only if it is enabled
	if(popupStatus4==1){
		$("#backgroundPopup4").fadeOut("slow");
		$("#popupContact4").fadeOut("slow");
		popupStatus4 = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact").height();
	var popupWidth = $("#popupContact").width();
	//centering
	$("#popupContact").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}
//centering popup
function centerPopup2(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact2").height();
	var popupWidth = $("#popupContact2").width();
	//centering
	$("#popupContact2").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}
//centering popup
function centerPopup3(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact3").height();
	var popupWidth = $("#popupContact3").width();
	//centering
	$("#popupContact3").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}
//centering popup
function centerPopup4(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact4").height();
	var popupWidth = $("#popupContact4").width();
	//centering
	$("#popupContact4").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#button2").click(function(){
		//centering with css
		centerPopup2();
		//load popup
		loadPopup2();
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose2").click(function(){
		disablePopup2();
	});
	//Click out event!
	$("#backgroundPopup2").click(function(){
		disablePopup2();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus2==1){
			disablePopup2();
		}
	});

});
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#button3").click(function(){
		//centering with css
		centerPopup3();
		//load popup
		loadPopup3();
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose3").click(function(){
		disablePopup3();
	});
	//Click out event!
	$("#backgroundPopup3").click(function(){
		disablePopup3();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus3==1){
			disablePopup3();
		}
	});

});
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#button4").click(function(){
		//centering with css
		centerPopup4();
		//load popup
		loadPopup4();
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose4").click(function(){
		disablePopup4();
	});
	//Click out event!
	$("#backgroundPopup4").click(function(){
		disablePopup4();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus4==1){
			disablePopup4();
		}
	});

});
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#button").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose").click(function(){
		disablePopup();
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});
// Simple JavaScript Rotating Banner Using jQuery
// www.mclelun.com
var jqb_vCurrent = 0;
var jqb_vTotal = 0;
var jqb_vDuration = 5000;
var jqb_intInterval = 0;
var jqb_vGo = 1;
var jqb_vIsPause = false;
var jqb_tmp = 20;
var jqb_title;
var jqb_imgW = 396;
var jqb_imgH = 129;

jQuery(document).ready(function() {	
	jqb_vTotal = $(".jqb_slides").children().size() -1;
	$(".jqb_info").text($(".jqb_slide").attr("title"));	
	jqb_intInterval = setInterval(jqb_fnLoop, jqb_vDuration);
			
	//Horizontal
	$("#jqb_object").find(".jqb_slide").each(function(i) { 
		jqb_tmp = ((i - 1)*jqb_imgW) - ((jqb_vCurrent -1)*jqb_imgW);
		$(this).animate({"left": jqb_tmp+"px"}, 400);
	});
	
	/*
	//Vertical
	$("#jqb_object").find(".jqb_slide").each(function(i) { 
		jqb_tmp = ((i - 1)*jqb_imgH) - ((jqb_vCurrent -1)*jqb_imgH);
		$(this).animate({"top": jqb_tmp+"px"}, 500);
	});
	*/
	
	$("#btn_pauseplay").click(function() {
		if(jqb_vIsPause){
			jqb_fnChange();
			jqb_vIsPause = false;
			$("#btn_pauseplay").removeClass("jqb_btn_play");
			$("#btn_pauseplay").addClass("jqb_btn_pause");
		} else {
			clearInterval(jqb_intInterval);
			jqb_vIsPause = true;
			$("#btn_pauseplay").removeClass("jqb_btn_pause");
			$("#btn_pauseplay").addClass("jqb_btn_play");
		}
	});
	$("#btn_prev").click(function() {
		jqb_vGo = -1;
		jqb_fnChange();
	});
		
	$("#btn_next").click(function() {
		jqb_vGo = 1;
		jqb_fnChange();
	});
});

function jqb_fnChange(){
	clearInterval(jqb_intInterval);
	jqb_intInterval = setInterval(jqb_fnLoop, jqb_vDuration);
	jqb_fnLoop();
}

function jqb_fnLoop(){
	if(jqb_vGo == 1){
		jqb_vCurrent == jqb_vTotal ? jqb_vCurrent = 0 : jqb_vCurrent++;
	} else {
		jqb_vCurrent == 0 ? jqb_vCurrent = jqb_vTotal : jqb_vCurrent--;
	}
	
			
	$("#jqb_object").find(".jqb_slide").each(function(i) { 
		if(i == jqb_vCurrent){
			jqb_title = $(this).attr("title");
			$(".jqb_info").animate({ opacity: 'hide', "left": "-50px"}, 129,function(){
				$(".jqb_info").text(jqb_title).animate({ opacity: 'show', "left": "0px"}, 400);
			});
		} 
			
			
		//Horizontal Scrolling
		jqb_tmp = ((i - 1)*jqb_imgW) - ((jqb_vCurrent -1)*jqb_imgW);
		$(this).animate({"left": jqb_tmp+"px"}, 400);
		
		
		/*
		//Vertical Scrolling
		jqb_tmp = ((i - 1)*jqb_imgH) - ((jqb_vCurrent -1)*jqb_imgH);
		$(this).animate({"top": jqb_tmp+"px"}, 500);
		*/
		
		/*
		//Fade In & Fade Out
		if(i == jqb_vCurrent){
			$(".jqb_info").text($(this).attr("title"));
			$(this).animate({ opacity: 'show', height: 'show' }, 500);
		} else {
			$(this).animate({ opacity: 'hide', height: 'hide' }, 500);
		}
		*/
		
	});


}

//comment2

$(document).ready(function()
{
$(".comment_button").click(function(){

var element = $(this);
var I = element.attr("id");

$("#slidepanel"+I).slideToggle(300);
$(this).toggleClass("active"); 

return false;
});
});
//comment jquery
	var http_request2 = false;		
   function makePOSTRequest2(url, parameters) {
      http_request2 = false;
      if (window.XMLHttpRequest2) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest2();
         if (http_request2.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request2.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request2 = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request2 = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request2) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request2.onreadystatechange = alertContents;
      http_request2.open('POST', url, true);
      http_request2.setRequest2Header("Content-type", "application/x-www-form-urlencoded");
      http_request2.setRequest2Header("Content-length", parameters.length);
      http_request2.setRequest2Header("Connection", "close");
      http_request2.send(parameters);
   }	
   
   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('mycommentspan').innerHTML = result;
         } else {
            //alert('There was a problem with the request.');
			document.getElementById('mycommentspan').innerHTML = 'There was a problem with the request. Please contact us and report this problem!';
         }
      }
   }
  		
			   function get(obj) {
	   
	  var poststr;
	  if(document.getElementById("user_id2").value == 0)
	  {
		 poststr = "comment_txt=" + encodeURI( document.getElementById("comment_txt").value ) +
                    "&vid=" + encodeURI( document.getElementById("vid").value ) +
					"&user_id=" + encodeURI( document.getElementById("user_id").value ) +
					"&username=" + encodeURI( document.getElementById("username").value ) +
					"&captcha=" + encodeURI( document.getElementById("captcha").value );
	  }
	  else {
		 poststr = "vid2=" + encodeURI( document.getElementById("vid2").value ) +	
		           "&vid2=" + encodeURI( document.getElementById("vid2").value ) +	           
		 			"&user_id2=" + encodeURI( document.getElementById("user_id2").value ) ;                    
					"&comment_txt2=" + encodeURI( document.getElementById("comment_txt2").value ); 
	  }
	  
      makePOSTRequest2(''+MELODYURL+'/commentm.php', poststr);
   }

function submitonce(theform){
//if IE 4+ or NS 6+
	if(document.getElementById("user_id2").value != 0)
	{
		if(document.getElementById("comment_txt2").value == '' || document.getElementById("comment_txt2").value == "test"){
			//alert('You need to write a comment first!');
		}
		else{
			if (document.all||document.getElementById){
				//screen thru every element in the form, and hunt down "submit" and "reset"
				for (i=0;i<theform.length;i++){
					var tempobj=theform.elements[i]
					if(tempobj.type.toLowerCase()=="submit2"||tempobj.type.toLowerCase()=="reset")
					//disable em
					tempobj.disabled=true;
				}
				//theform.style.display='none';
				$(theform).slideUp('normal');
			}
		}
	}
	else
	{
		//	guest comment
		var alert_msg = '';
		if(document.getElementById("comment_txt2").value == ''){
			//alert('You need to write a comment first!');
			alert_msg = alert_msg+'You need to write a comment first!\n';
		}
		if(document.getElementById("username").value == '' || document.getElementById("captcha").value == ''){
			alert_msg = alert_msg+'Please fill in the required fields.\n';
		}
		
		if(alert_msg != '') {
			//alert(alert_msg);
		}
		else{
			if (document.all||document.getElementById){
				//screen thru every element in the form, and hunt down "submit"
				for (i=0;i<theform.length;i++){
					var tempobj=theform.elements[i]
					if(tempobj.type.toLowerCase()=="submit2")
					//disable em
					tempobj.disabled=false;
				}
				//theform.style.display='none';
				$(theform).slideUp('normal');
			}
		}	
	}
	
}
/*! Copyright (c) 2008 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Version: 1.0.3
 * Requires jQuery 1.1.3+
 * Docs: http://docs.jquery.com/Plugins/livequery
 */

(function($) {
	
$.extend($.fn, {
	livequery: function(type, fn, fn2) {
		var self = this, q;
		
		// Handle different call patterns
		if ($.isFunction(type))
			fn2 = fn, fn = type, type = undefined;
			
		// See if Live Query already exists
		$.each( $.livequery.queries, function(i, query) {
			if ( self.selector == query.selector && self.context == query.context &&
				type == query.type && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) )
					// Found the query, exit the each loop
					return (q = query) && false;
		});
		
		// Create new Live Query if it wasn't found
		q = q || new $.livequery(this.selector, this.context, type, fn, fn2);
		
		// Make sure it is running
		q.stopped = false;
		
		// Run it immediately for the first time
		q.run();
		
		// Contnue the chain
		return this;
	},
	
	expire: function(type, fn, fn2) {
		var self = this;
		
		// Handle different call patterns
		if ($.isFunction(type))
			fn2 = fn, fn = type, type = undefined;
			
		// Find the Live Query based on arguments and stop it
		$.each( $.livequery.queries, function(i, query) {
			if ( self.selector == query.selector && self.context == query.context && 
				(!type || type == query.type) && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !this.stopped )
					$.livequery.stop(query.id);
		});
		
		// Continue the chain
		return this;
	}
});

$.livequery = function(selector, context, type, fn, fn2) {
	this.selector = selector;
	this.context  = context || document;
	this.type     = type;
	this.fn       = fn;
	this.fn2      = fn2;
	this.elements = [];
	this.stopped  = false;
	
	// The id is the index of the Live Query in $.livequery.queries
	this.id = $.livequery.queries.push(this)-1;
	
	// Mark the functions for matching later on
	fn.$lqguid = fn.$lqguid || $.livequery.guid++;
	if (fn2) fn2.$lqguid = fn2.$lqguid || $.livequery.guid++;
	
	// Return the Live Query
	return this;
};

$.livequery.prototype = {
	stop: function() {
		var query = this;
		
		if ( this.type )
			// Unbind all bound events
			this.elements.unbind(this.type, this.fn);
		else if (this.fn2)
			// Call the second function for all matched elements
			this.elements.each(function(i, el) {
				query.fn2.apply(el);
			});
			
		// Clear out matched elements
		this.elements = [];
		
		// Stop the Live Query from running until restarted
		this.stopped = true;
	},
	
	run: function() {
		// Short-circuit if stopped
		if ( this.stopped ) return;
		var query = this;
		
		var oEls = this.elements,
			els  = $(this.selector, this.context),
			nEls = els.not(oEls);
		
		// Set elements to the latest set of matched elements
		this.elements = els;
		
		if (this.type) {
			// Bind events to newly matched elements
			nEls.bind(this.type, this.fn);
			
			// Unbind events to elements no longer matched
			if (oEls.length > 0)
				$.each(oEls, function(i, el) {
					if ( $.inArray(el, els) < 0 )
						$.event.remove(el, query.type, query.fn);
				});
		}
		else {
			// Call the first function for newly matched elements
			nEls.each(function() {
				query.fn.apply(this);
			});
			
			// Call the second function for elements no longer matched
			if ( this.fn2 && oEls.length > 0 )
				$.each(oEls, function(i, el) {
					if ( $.inArray(el, els) < 0 )
						query.fn2.apply(el);
				});
		}
	}
};

$.extend($.livequery, {
	guid: 0,
	queries: [],
	queue: [],
	running: false,
	timeout: null,
	
	checkQueue: function() {
		if ( $.livequery.running && $.livequery.queue.length ) {
			var length = $.livequery.queue.length;
			// Run each Live Query currently in the queue
			while ( length-- )
				$.livequery.queries[ $.livequery.queue.shift() ].run();
		}
	},
	
	pause: function() {
		// Don't run anymore Live Queries until restarted
		$.livequery.running = false;
	},
	
	play: function() {
		// Restart Live Queries
		$.livequery.running = true;
		// Request a run of the Live Queries
		$.livequery.run();
	},
	
	registerPlugin: function() {
		$.each( arguments, function(i,n) {
			// Short-circuit if the method doesn't exist
			if (!$.fn[n]) return;
			
			// Save a reference to the original method
			var old = $.fn[n];
			
			// Create a new method
			$.fn[n] = function() {
				// Call the original method
				var r = old.apply(this, arguments);
				
				// Request a run of the Live Queries
				$.livequery.run();
				
				// Return the original methods result
				return r;
			}
		});
	},
	
	run: function(id) {
		if (id != undefined) {
			// Put the particular Live Query in the queue if it doesn't already exist
			if ( $.inArray(id, $.livequery.queue) < 0 )
				$.livequery.queue.push( id );
		}
		else
			// Put each Live Query in the queue if it doesn't already exist
			$.each( $.livequery.queries, function(id) {
				if ( $.inArray(id, $.livequery.queue) < 0 )
					$.livequery.queue.push( id );
			});
		
		// Clear timeout if it already exists
		if ($.livequery.timeout) clearTimeout($.livequery.timeout);
		// Create a timeout to check the queue and actually run the Live Queries
		$.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
	},
	
	stop: function(id) {
		if (id != undefined)
			// Stop are particular Live Query
			$.livequery.queries[ id ].stop();
		else
			// Stop all Live Queries
			$.each( $.livequery.queries, function(id) {
				$.livequery.queries[ id ].stop();
			});
	}
});

// Register core DOM manipulation methods
$.livequery.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'empty', 'remove');

// Run Live Queries when the Document is ready
$(function() { $.livequery.play(); });


// Save a reference to the original init method
var init = $.prototype.init;

// Create a new init method that exposes two new properties: selector and context
$.prototype.init = function(a,c) {
	// Call the original init and save the result
	var r = init.apply(this, arguments);
	
	// Copy over properties if they exist already
	if (a && a.selector)
		r.context = a.context, r.selector = a.selector;
		
	// Set properties
	if ( typeof a == 'string' )
		r.context = c || document, r.selector = a;
	
	// Return the result
	return r;
};

// Give the init function the jQuery prototype for later instantiation (needed after Rev 4091)
$.prototype.init.prototype = $.prototype;
	
})(jQuery);
//deleteComment
$('a.c_delete').livequery("click", function(e){
 
	if(confirm('Are you sure you want to delete this comment?')==false)
	return false;
	e.preventDefault();
	var parent  = $(this).parent();
	var c_id =  $(this).attr('id').replace('CID-','');
	$.ajax({
		type: 'get',
		url: 'delete_comment.php?c_id='+ c_id,
		data: '',
		beforeSend: function(){
		},
		success: function(){
			parent.fadeOut(200,function(){
				parent.remove();
			});
		}
	});
});

// autre
 function getfav(obj) {
  var poststr = "video_id=" + encodeURI( document.getElementById("video_id").value ) +
				"&user_id=" + encodeURI( document.getElementById("user_id").value );
  makePOSTRequest(''+MELODYURL+'/ajax_favorite.php', poststr);
}

 
function report(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=yes,width=450,height=300,left = 100,top = 50');");
}

function reportPopup(ID, vid)
{
this.id=ID
this.vid=vid
window.open(''+MELODYURL+'/report.php?vid='+this.vid+'&do='+this.id, 'report','toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=yes,width=450,height=300,left=100,top=50');
}
function sharePopup(vid)
{
this.vid=vid
window.open(''+MELODYURL+'/share.php?vid='+this.vid, 'share','toolbar=0,scrollbars=no,location=0,statusbar=0,menubar=0,resizable=no,width=450,height=300,left=100,top=50');
}
function makeFavorite(vid)
{
this.vid=vid
window.open(''+MELODYURL+'/favorites.php?a=add&vid='+this.vid, 'share','toolbar=0,scrollbars=no,location=0,statusbar=0,menubar=0,resizable=no,width=450,height=150,left=100,top=50');
}

function addmyspacePopup(vid)
{
this.vid=vid
window.open(''+MELODYURL+'/share_code.php?vid='+this.vid+'&social=myspace', 'share','toolbar=0,scrollbars=no,location=0,statusbar=0,menubar=0,resizable=no,width=450,height=300,left=100,top=50');
}

function textLimit(field, maxlen) {
if (field.value.length > maxlen + 1)
alert('Your comment is too long!');
if (field.value.length > maxlen)
field.value = field.value.substring(0, maxlen);
} 
function SelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}
// Shows PM notification for errors, news and such
function show_pm_note(title, description, url_image) {

var unique_id = $.gritter.add({
		// (string | mandatory) the heading of the notification
		title: title,
		// (string | mandatory) the text inside the notification
		text: description,
		// (string | optional) the image to display on the left
		image: url_image,
		// (bool | optional) if you want it to fade out on its own or just sit there
		sticky: true, 
		// (int | optional) the time you want it to be alive for before fading out
		time: '' 
	});
}

