/*
suararadio.js
javascript fungsi untuk suara radio
dependency: jquery
*/

function suararadio_playlist_add(postid,pos) {
	jQuery.ajax({
		type: "GET",
		url:  "/suararadio_api/add_playlist_item/"+postid+"/"+pos,
		dataType: "json",
		success: function (data) {
				str = "File: "+data.title+", telah ditambahkan.";
				suararadio_flash(str);
		},
		error: function(data) {
			str = "Gagal menambahkan item.";
			suararadio_flash(str);
		}
	});
}

function suararadio_playlist_clear() {
	jQuery.ajax({
		type: "GET",
		url:  "/suararadio_api/clear_playlist/1",
		dataType: "json",
		success: function (data) {
				str = "Playlist dikosongkan.";
				suararadio_flash(str);
			}
	});
}

function suararadio_playlist_del(idx) {
	jQuery.ajax({
		type: "GET",
		url:  "/suararadio_api/del_playlist_item/"+idx,
		dataType: "json",
		success: function (data) {
				str = "File: "+data.title+", telah dihapus.";
				suararadio_flash(str);
			}
	});
}

function suararadio_flash(str) {
	$("div#flash-msg").html(str).show();
	setTimeout(function(){ $("div#flash-msg").fadeOut("slow"); },3000);
}
         

function suararadio_create_player(divid,playlist,width,height) {
	swfobject.embedSWF("/wp-content/plugins/suararadio/xspf_player.swf?autoload=true&repeat_playlist=true&player_title=e-Broadcasting Institute&playlist_url="+playlist, divid, width, height, "9.0.0", "wp-content/plugins/suararadio/js/swfobject/expressInstall.swf");
	return true;
}

function suararadio_hide_player() {
	jQuery("#suararadio_player").css("display","none");
	jQuery("#suararadio_player_menu").css("display","none");
	jQuery("#suararadio_player_container").css("height","16px");
	jQuery("#suararadio_player_container").css("width","16px");
}

function suararadio_show_player() {
	jQuery("#suararadio_player").css("display","inline");
	jQuery("#suararadio_player_menu").css("display","inline");
	jQuery("#suararadio_player_container").css("height","130px");
	jQuery("#suararadio_player_container").css("width","180px");
}

function suararadio_refresh_player(divid) {
	
}
