/** 
 * Add the layer for the player
 * @access public
 * @param string Id
 * @return void
 */
jQuery.fn.addPlayerDiv = function(id) {
	$j("#" + id).append("<div class=\"" + playerClass + "\"></div>");
};

/** 
 * Add the layer for the control panel
 * @access public
 * @param string Id
 * @return void
 */
jQuery.fn.addControlPanelDiv = function(id) {
	$j("#" + id).append("<div class=\"controlpanel\">" +
			"<a href=\"#\"><span class=\"mt-icon mt-icon-collapseable_arrow\" />Einstellungen</a>" +
		"</div>");
	$j("#" + id).append("<div id=\"" + controlPanelBoxId + id + "\" class=\"controlpanelbox\">" +
		"<div class=\"format\">Playerformat<ul>" +
			"<li class=\"f0\"><a href=\"#\">Flash</a></li>" +
			"<li class=\"f1\"><a href=\"#\">Silverlight</a></li>" +
			"<li class=\"f2\"><a href=\"#\">Windows Media Plugin</a></li>" +
		"</ul></div>" +
		"<div class=\"connection\">Verbindung<ul>" +
			"<li class=\"q0\"><a href=\"#\">Modem/ISDN</a></li>" +
			"<li class=\"q1\"><a href=\"#\">DSL</a></li>" +
		"</ul></div>" +
		"<div><a class=\"save\" href=\"#\">Einstellungen speichern</a></div>" +
		"<div><a class=\"deletesave\" href=\"#\">Standard wiederherstellen</a></div>" +
	"</div>");
	
	$j("#" + id + " .format .f0").hide();
	$j("#" + id + " .format .f1").hide();
	$j("#" + id + " .format .f2").hide();
	
	$j("#" + id + " .connection .q0").hide();
	$j("#" + id + " .connection .q1").hide();
	
	$j("#" + id + " #" + controlPanelBoxId + id).hide();
	$j("#" + id + " .controlpanel a").click(function(event) { 
		event.preventDefault();
		if ($j("#" + id + " #" + controlPanelBoxId + id).is(":hidden")) {
			$j("#" + id + " #" + controlPanelBoxId + id).slideDown("fast");
			$j("#" + id + " .controlpanel").addClass("opened");
		} 
		else {
			$j("#" + id + " #" + controlPanelBoxId + id).slideUp("fast");
			$j("#" + id + " .controlpanel").removeClass("opened");
		} 
    });

	$j("#" + id + " .deletesave").click(function(event) { 
		event.preventDefault();
		$j("#" + id + " #" + controlPanelBoxId + id).slideUp("fast");
		$j("#" + id + " .controlpanel").removeClass("opened");
	});
	$j("#" + id + " .save").click(function(event) { 
		event.preventDefault();
		$j("#" + id + " #" + controlPanelBoxId + id).slideUp("fast");
		$j("#" + id + " .controlpanel").removeClass("opened");
	});
};

/** 
 * Add the layer for the buttons (hq, download, podcast)
 * @access public
 * @param string Id
 * @return void
 */
jQuery.fn.addButtonDiv = function (id) {
	$j("#" + id + " .controlpanel").append(
		"<a class=\"" + xqButtonId + "\" href=\"#\" />" +
		"<a class=\"" + hqButtonId + "\" href=\"#\" />"
		
	);
	$j("#" + id + " ." + hqButtonId).hide();
	$j("#" + id + " ." + xqButtonId).hide();
	
	$j("#" + id + " .controlpanel").append(
		"<a class=\"" + downloadButtonId + "\" href=\"#\" />"
	);
	$j("#" + id + " ." + downloadButtonId).hide();
	
	$j("#" + id + " .controlpanel").append(
		"<a class=\"" + podcastButtonId + "\" href=\"#\" />"
	);
	$j("#" + id + " ." + podcastButtonId).hide();
};

/** 
 * Add the layer for the hq video
 * @access public
 * @param string Id
 * @param string HqVideoId
 * @return void
 */
jQuery.fn.addHqVideoDiv = function (id) {
	$j("#" + id).before("<div id=\"" + id + hqVideoId + "\">" +
		"<a class=\"" + hqCloseButtonId + "\" href=\"#\"><span>schlie&szlig;en</span><span class=\"mt-icon\">&nbsp;</span></a>" +
		"<div />" +
	"</div>");
	$j("#" + id + hqVideoId).hide();
};

/** 
 * Show the download button and set the link url
 * @access public
 * @param string Id
 * @param string Download url
 * @return void
 */
jQuery.fn.showDownloadButton = function (id, url) {
	$j("#" + id + " ." + downloadButtonId).attr("href", url).show();
	$j("#" + id + " ." + downloadButtonId).click(function(event){
		event.preventDefault();
		window.open(this.href, "Download", "width=441,height=256,top=50,left=50");
	});
};

/** 
 * Show the podcast button and set the link url
 * @access public
 * @param string Id
 * @param string Podcast url
 * @return void
 */
jQuery.fn.showPodcastButton = function (id, url) {
	$j("#" + id + " ." + podcastButtonId).attr("href", url).show();
	$j("#" + id + " ." + podcastButtonId).click(function(event){
		event.preventDefault();
		window.open(this.href, "Podcast", "width=441,height=256,top=50,left=50");
	});
};

/** 
 * Show the flash, silverlight, wm button
 * @access public
 * @param string Id
 * @param string Format 0 - flash, 1 - silverlight, 3 - windows media
 * @return void
 */
jQuery.fn.showFormatButton = function(id, format) {
	$j("#" + id + " .format .f" + format).show();
};

/** 
 * Hide the flash, silverlight, wm button 
 * @access public
 * @param string Id
 * @param string Format 0 - flash, 1 - silverlight, 3 - windows media
 * @return void
 */
jQuery.fn.hideFormatButton = function (id, format) {
	$j("#" + id + " .format .f" + format).hide();
};

/** 
 * Select a format button
 * @access public
 * @param string Id
 * @param string Format 0 - flash, 1 - silverlight, 3 - windows media
 * @return void
 */
jQuery.fn.selectFormatButton = function(id, format) {
	$j("#" + id + " .format a").removeClass("selected");
	$j("#" + id + " .format .f" + format + " a").addClass("selected");
};

/** 
 * Show a quality button
 * @access public
 * @param string Id
 * @param string Quality of the stream 0 - small, 1 - medium or 2 - large
 * @return void
 */
jQuery.fn.showQualityButton = function(id, quality) {
	switch(quality) {
	case "0":
	case "1":
		$j("#" + id + " .connection .q" + quality).show();
	break;
	case "2":
		$j("#" + id + " ." + hqButtonId).show();
	break;
	case "3":
		$j("#" + id + " ." + xqButtonId).show();
	break;
	}
};

/** 
 * Hide quality buttons
 * @access public
 * @param string Id
 * @return void
 */
jQuery.fn.hideQualityButtons = function(id) {
		$j("#" + id + " .connection li").hide();
		$j("#" + id + " ." + hqButtonId).hide();
		$j("#" + id + " ." + xqButtonId).hide();
};

/** 
 * Select a quality button
 * @access public
 * @param string Id
 * @param string Quality of the stream 0 - small, 1 - medium or 2 - large
 * @return void
 */
jQuery.fn.selectQualityButton = function(id, quality) {
	$j("#" + id + " .connection a").removeClass("selected");
	$j("#" + id + " .connection .q" + quality + " a").addClass("selected");
};

/** 
 * Emtpy the div containing the player object-tag
 * @access public
 * @param void
 * @return void
 */
jQuery.fn.emptyPlayerDiv = function(id) {
	$j("#" + id + " ." + playerClass).empty();
};

/** 
 * Emtpy the div containing the hq player object-tag
 * @access public
 * @param void
 * @return void
 */
jQuery.fn.emptyHqPlayerDiv = function(id) {
	$j("#" + id + hqVideoId + " div").empty();
	$j("#" + id + hqVideoId + " div").removeAttr("class");
	$j("#" + id + hqVideoId).removeAttr("class");
};

/** 
 * Show an error message, if no or no usable plugin is found
 * @access public
 * @param void
 * @return void
 */
jQuery.fn.showErrorMsg = function(id, bestMediaNumber) {
	var pluginName = "";
	var pluginLink = "";
	switch(bestMediaNumber){
		// Flash
		case 0:
			pluginName = "(Adobe Flash Player) ";
			pluginLink = " <a href=\"http://get.adobe.com/de/flashplayer/\" onclick=\"window.open(this.href); return false;\">[Download Plugin]</a>";
		break;
		// Silverlight
		case 1:
			pluginName = "(Silverlight) ";
			pluginLink = " <a href=\"www.microsoft.com/silverlight/downloads.aspx\" onclick=\"window.open(this.href); return false;\">[Download Plugin]</a>";
		break;
		// WindowsMedia
		case 2:
			pluginName = "(WindowsMedia Player) ";
			pluginLink = " <a href=\"http://www.microsoft.com/windows/windowsmedia/de/default.aspx\" onclick=\"window.open(this.href); return false;\">[Download Plugin]</a>";
		break;
	
	}
	$j("#" + id).html("<div class=\"errormsg\">Es ist ein zus&auml;tzliches Plugin " +
		pluginName + "notwendig, um den Clip abspielen zu k&ouml;nnen." + pluginLink +"</div>");
};

