function Popup(src, wd, ht)
{
  //var wd=784;
  //var ht=548;
  var le=screen.width/2-wd/2;
  var tp=screen.height/2-ht/2;
  win = window.open(src,'22',"width="+wd+",height="+ht+",left="+le+",top="+tp);
  //win = window.open("Bilder/seite_01.gif","Mark sein Zeich","WIDTH=300, HEIGHT=200");
}

function Live2007(){
	myleft=180;
	mytop=170;
	settings="width=584,height=521,top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no,dependent=no";
	win=window.open("live.html","",settings);
	win.focus();
}

function bbcode(v,target)
{
 if (document.selection) // für IE
   {
    var str = document.selection.createRange().text;
    target.focus();
    var sel = document.selection.createRange();
    sel.text = "[" + v + "]" + str + "[/" + v + "]";
    return;
   }
  else if ((typeof target.selectionStart) != 'undefined') // für Mozilla
   {
    var txtarea = target;
    var selLength = txtarea.textLength;
    var selStart = txtarea.selectionStart;
    var selEnd = txtarea.selectionEnd;
    var oldScrollTop = txtarea.scrollTop;
    var s1 = (txtarea.value).substring(0,selStart);
    var s2 = (txtarea.value).substring(selStart, selEnd)
    var s3 = (txtarea.value).substring(selEnd, selLength);
    txtarea.value = s1 + '[' + v + ']' + s2 + '[/' + v + ']' + s3;
    txtarea.selectionStart = s1.length;
    txtarea.selectionEnd = s1.length + 5 + s2.length + v.length * 2;
    txtarea.scrollTop = oldScrollTop;
    return;
   }
  else input('[' + v + '][/' + v + '] ');
}


function initJPlayer(myPlayList)
{

		$(function(){
		var playItem = 0;

		// Local copy of jQuery selectors, for performance.
		var jpPlayTime = $("#jplayer_play_time");
		var jpTotalTime = $("#jplayer_total_time");

		$("#jquery_jplayer").jPlayer({
			ready: function() {
				displayPlayList();
				playListInit(false); // Parameter is a boolean for autoplay.
			},
			nativeSupport: false, 
			oggSupport: false,
			/*ready: function () {
				this.element.jPlayer("setFile", "http://localhost/randfichten3/data/music/tpau.mp3").jPlayer("play");
				
			},*/
			volume: 50

		})
		.jPlayer("onProgressChange", function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
			jpPlayTime.text($.jPlayer.convertTime(playedTime));
			jpTotalTime.text($.jPlayer.convertTime(totalTime));
		})
		.jPlayer("onSoundComplete", function() {
			playListNext();
		});

		$("#jplayer_previous").click( function() {
			playListPrev();
			$(this).blur();
			return false;
		});

		$("#jplayer_next").click( function() {
			playListNext();
			$(this).blur();
			return false;
		});

		function displayPlayList() {
			
			
			$("#jplayer_playlist ul").empty();
			for (i=0; i < myPlayList.length; i++) {
				var listItem = (i == myPlayList.length-1) ? "<li class='jplayer_playlist_item_last'>" : "<li>";
				listItem += "<a href='#' id='jplayer_playlist_item_"+i+"' tabindex='1'>"+ myPlayList[i].name +"</a></li>";
				$("#jplayer_playlist ul").append(listItem);
				$("#jplayer_playlist_item_"+i).data( "index", i ).click( function() {
					var index = $(this).data("index");
					if (playItem != index) {
						playListChange( index );
					} else {
						$("#jquery_jplayer").jPlayer("play");
					}
					$(this).blur();
					return false;
				});
			}
		}

		function playListInit(autoplay) {
			if(autoplay) {
				playListChange( playItem );
			} else {
				playListConfig( playItem );
			}
		}

		function playListConfig( index ) {
			$("#jplayer_playlist_item_"+playItem).removeClass("jplayer_playlist_current").parent().removeClass("jplayer_playlist_current");
			$("#jplayer_playlist_item_"+index).addClass("jplayer_playlist_current").parent().addClass("jplayer_playlist_current");
			playItem = index;
			$("#jquery_jplayer").jPlayer("setFile", myPlayList[playItem].mp3, myPlayList[playItem].ogg);
		}

		function playListChange( index ) {
			playListConfig( index );
			$("#jquery_jplayer").jPlayer("play");
		}

		function playListNext() {
			var index = (playItem+1 < myPlayList.length) ? playItem+1 : 0;
			playListChange( index );
		}

		function playListPrev() {
			var index = (playItem-1 >= 0) ? playItem-1 : myPlayList.length-1;
			playListChange( index );
		}
		
	});

}
