$().ajaxStop($.unblockUI);

$(function () {
  var tabContainersMP3 = $('div.tabsMP3 > div');
  
  $('div.tabsMP3 ul.tabNavigationMP3 a').click(function () {
      tabContainersMP3.hide().filter(this.hash).show();
      
      $('div.tabsMP3 ul.tabNavigationMP3 a').removeClass('selected');
      $(this).addClass('selected');
      
      return false;
  }).filter(':first').click();
  
  var tabContainersVideo = $('div.tabsVideo > div');
  
  $('div.tabsVideo ul.tabNavigationVideo a').click(function () {
      tabContainersVideo.hide().filter(this.hash).show();
      
      $('div.tabsVideo ul.tabNavigationVideo a').removeClass('selected');
      $(this).addClass('selected');
      
      return false;
  }).filter(':first').click();
});

function TrimTxt(str) {return str.replace(/^\s+|\s+$/g,"");}

function SearchMP3() {
	txtSearch = TrimTxt(document.frmSearch.qword.value);
	if ((txtSearch) && (txtSearch.length > 0)) {
		txtSearch = txtSearch.replace(/[^a-zA-Z0-9 _-]/g, "");
		txtJenis	= document.frmSearch.jenis[document.frmSearch.jenis.selectedIndex].value;
		document.frmSearch.action = '/search/' + txtJenis + '/' + txtSearch.replace(/ |_/g, "+");
		return true;
	} else {
		alert('Try another keyword');
		document.frmSearch.qword.focus();
		return false;
	}
}

function PlayMP3(sURL) {
	$.ajax({
		type: "GET",
		url: sURL,
		dataType: "html",
		beforeSend: function(){
			$("#PlayBox").block(); 
		},
		success: function(msg){
		 	$("#PlayBox").html(msg);
		  $("#PlayBox").unblock(); 
		}
	});
}