function jqpost(form, url, update){
	
	var theelement = document.getElementById(update);
	
	$.post(url, $(form).serialize(),
		function(data){
			$(theelement).html(data);
		}													   
	);
	
	return false;
}

function get_player(id){
	
	$.ajax({
	  url: '/media/player/id/'+id,
	  success: function(data) {
		$('#player_container').html(data);
	  }
	});
}

function open_window(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function external_player(id, title){
	
	add = (title!="") ? "/" + title:""; 
	
	open_window("/media/player/external/"+id+add,'ff_ext_player','width=400,height=300');
}

function sort_it(id, where) {
	$('#'+id).sortable({
		update : function () {
			serial = $('#'+id).sortable('serialize');
			$.ajax({
				url: where,
				type: "post",
				data: serial,
				error: function(){
					alert("theres an error with AJAX");
				}
			});
		}
	});
}


//function searchable_select(class)
//(
//    /* Find all friendly UL's */
//    $('ul.'.class).each(function()
//    {
//      /* Hide list element */
//      $(this).css("display", "none");
//    
//      /* Create new ID for the select, use existent Id of UL but add the _Select prefix */
//      var ElementId = $(this).attr("id") + "_Select";
//      
//      /* Create new Select-element */
//      $(this).after("<select id='" + ElementId + "' class='"+class+"'></select>");
//      
//      /* Loop-through list and add children to select */
//      $(this).find("li").each(function()
//      {
//        /* Setup values */
//        var Anchor = $(this).find("a").eq(0), Value = (Anchor.length > 0 ? $(Anchor).attr("href") : '');
//        var SelectedElement = ($(this).hasClass("SelectedItem") ? ' selected' : '');
//        
//        /* Add child to select */
//        $("#"+ElementId).append("<option value='"+Value+"'"+SelectedElement+">"+$(this).html()+"</option>");
//      });
//    });
//    
//    /* Hook selects */
//    $("select."+class).change(function()
//    {
//      if(this.value.length > 0) window.location.href = this.value;
//    });
//)