   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.addClass('visible_li')
           }
       }, function () {
           var ul_subs = $(this).find('ul');
           if (ul_subs.hasClass("visible_li")) {
               ul_subs.addClass("hidden_li");
               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="Cargando" id="loading" />Cargando...').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");
   }

   function dis() {
       if (document.forms[0].perfil[0].checked == true) {
           document.forms[0].favorite[1].disabled = false;
           document.forms[0].favorite[0].disabled = false;
       } else if (document.forms[0].perfil[1].checked == true) {
           document.forms[0].favorite[1].disabled = true;
           document.forms[0].favorite[0].disabled = true;
       }
   }
   //Ocultar/Mostrar Div's
OCULTO = "none";
VISIBLE = "block";

function mostrar(blo, veroff, veron) {
    document.getElementById(blo).style.display = VISIBLE;
    document.getElementById(veroff).style.display = VISIBLE;
    document.getElementById(veron).style.display = OCULTO;
}

function ocultar(blo, veroff, veron) {
    document.getElementById(blo).style.display = OCULTO;
    document.getElementById(veroff).style.display = OCULTO;
    document.getElementById(veron).style.display = VISIBLE;
}
function abrirepi() {
	document.getElementById('panel').style.display=VISIBLE;
	document.getElementById('episode').style.display=OCULTO;
	document.getElementById('episode1').style.display=VISIBLE;
	$(document).ready( function () 
	{
		$("#tabs_related").show();
		$("#tabs_sameartist").hide();
		$("#tabs_other").hide();
		$("#tabs_mirrors").hide();
		$("#tabs_trailer").hide();
		$(".shadetabs").find("li").removeClass("selected");
		$("#tabs_select_related").addClass("selected");		
	})
}

function abrirmirror() {
	document.getElementById('panel').style.display=VISIBLE;
	document.getElementById('episode').style.display=OCULTO;
	document.getElementById('episode1').style.display=VISIBLE;
	$(document).ready( function () 
	{
		$("#tabs_mirrors").show();
		$("#tabs_related").hide();
		$("#tabs_sameartist").hide();
		$("#tabs_trailer").hide();
		$("#tabs_other").hide();
		$(".shadetabs").find("li").removeClass("selected");
		$("#tabs_select_mirrors").addClass("selected");		
	})
}

function abrirtrailer() {
	document.getElementById('panel').style.display=VISIBLE;
	document.getElementById('episode').style.display=OCULTO;
	document.getElementById('episode1').style.display=VISIBLE;
	$(document).ready( function () 
	{
		$("#tabs_mirrors").hide();
		$("#tabs_related").hide();
		$("#tabs_sameartist").hide();
		$("#tabs_other").hide();
		$("#tabs_trailer").show();
		$(".shadetabs").find("li").removeClass("selected");
		$("#tabs_select_trailer").addClass("selected");		
	})
}

function cerrarepi() {
	document.getElementById('panel').style.display=OCULTO;
	document.getElementById('episode').style.display=VISIBLE;
    document.getElementById('episode1').style.display=OCULTO;
}
