<?php
class jPlayer {

public $playertype = 1;
public $jPlayer_title;
public $jPlayer_url;
public $jPlayer_skin = 'skin/new/audio-style.css';
public $jPlayer_allow_title = 1;
public $jPlayer_allow_stop = 1;
public $jPlayer_allow_mute = 1;
public $jPlayer_allow_unmute = 1;
public $jPlayer_allow_maxvolume = 1;
public $jPlayer_allow_progress = 1;
public $jPlayer_allow_volumebar = 1;
public $jPlayer_allow_currenttime = 1;
public $jPlayer_allow_duration = 1;
public $jPlayer_allow_repeat = 1;
public $jPlayer_js_jquery = 'js/jPlayer';
public $jPlayer_js_more = '';
public $jPlayer_js_min = 1;
public $jPlayer_auto_play = 0;
public $jPlayer_nosolution = '<div class="jp-no-solution">
					<span>Update Required</span>
					To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.
				</div>';

public $flash_mp3_player_js_folder = 'js/flash';
public $flash_mp3_player_auto = 1;
public $flash_mp3_player_width = 290;
public $flash_mp3_player_height = 24;
public $flash_mp3_player_color_bg = 'cccccc';
public $flash_mp3_player_color_leftbg = 'ffffff';
public $flash_mp3_player_color_lefticon = '333333';
public $flash_mp3_player_color_rightbg = 'ffffff';
public $flash_mp3_player_color_rightbghover = 'cccccc';
public $flash_mp3_player_color_righticon = '333333';
public $flash_mp3_player_color_righticonhover = '415306';
public $flash_mp3_player_color_text = '333333';
public $flash_mp3_player_color_slider = '333333';
public $flash_mp3_player_color_track = 'ffffff';
public $flash_mp3_player_color_border = 'cccccc';
public $flash_mp3_player_color_loader = '333333';
public $flash_mp3_player_color_loop = 1; // 1=yes OR 0=no


function jPlayer_head_css(){
$s = '<link href="'.$this->jPlayer_skin.'" rel="stylesheet" type="text/css" />';
return $s;
}

function jPlayer_head_js(){
$s = '';
if($this->jPlayer_js_min == 1){
$s .= '<script type="text/javascript" src="'.$this->jPlayer_js_jquery.'/jquery.min.js"></script>'."\n"; //http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js
}else{
$s .= '';
}
$s .= '<script type="text/javascript" src="'.$this->jPlayer_js_jquery.'/jquery.jplayer.min.js"></script>'."\n";
$s .= $this->jPlayer_js_more;
return $s;
}

function jPlayer_head(){
if($this->jPlayer_auto_play == 1){
$autoplay = '.jPlayer("play")';
}else{
$autoplay = '';
}



$s = $this->jPlayer_head_css();
$s .= $this->jPlayer_head_js();
$s .= '<script type="text/javascript">
//<![CDATA[

$(document).ready(function(){

	$("#jquery_jplayer_1").jPlayer({
		ready: function (event) {
			$(this).jPlayer("setMedia", {
				mp3:"'.$this->jPlayer_url.'"
			})'.$autoplay.';
		},
		swfPath: "js",
		supplied: "mp3",
		wmode: "window"
	});
});
//]]>
</script>';
return $s;
}

function jPlayer_audio(){

if($this->jPlayer_allow_title == 1){
$jPlayer_titles = '<div class="jp-title">
					<ul class="ultitle">
						<li>'.$this->jPlayer_title.'</li>
					</ul>
				</div>';
}else{
$jPlayer_titles = '';
}

if($this->jPlayer_allow_stop == 1){
$jPlayer_stop = '<li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>';
}else{
$jPlayer_stop = '';
}

if($this->jPlayer_allow_mute == 1){
$jPlayer_mute = '<li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a></li>';
}else{
$jPlayer_mute = '';
}

if($this->jPlayer_allow_unmute == 1){
$jPlayer_unmute = '<li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li>';
}else{
$jPlayer_unmute = '';
}

if($this->jPlayer_allow_maxvolume == 1){
$jPlayer_maxvolume = '<li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a></li>';
}else{
$jPlayer_maxvolume = '';
}

if($this->jPlayer_allow_progress == 1){
$jPlayer_progress = '<div class="jp-progress">
						<div class="jp-seek-bar">
							<div class="jp-play-bar"></div>
						</div>
					</div>';
}else{
$jPlayer_progress = '';
}

if($this->jPlayer_allow_volumebar == 1){
$jPlayer_volumebar = '<div class="jp-volume-bar">
						<div class="jp-volume-bar-value"></div>
					</div>';
}else{
$jPlayer_volumebar = '';
}

if($this->jPlayer_allow_currenttime == 1){
$jPlayer_currenttime = '<div class="jp-current-time"></div>';
}else{
$jPlayer_currenttime = '';
}

if($this->jPlayer_allow_duration == 1){
$jPlayer_duration = '<div class="jp-duration"></div>';
}else{
$jPlayer_duration = '';
}

if($this->jPlayer_allow_repeat == 1){
$jPlayer_repeat = '<ul class="jp-toggles">
							<li><a href="javascript:;" class="jp-repeat" tabindex="1" title="repeat">repeat</a></li>
							<li><a href="javascript:;" class="jp-repeat-off" tabindex="1" title="repeat off">repeat off</a></li>
						</ul>';
}else{
$jPlayer_repeat = '';
}

if($this->jPlayer_allow_currenttime == 0 AND $jPlayer_allow_duration == 0 AND $jPlayer_allow_repeat == 0){
$jPlayer_timeholder = '';
}else{
$jPlayer_timeholder = '<div class="jp-time-holder">
						'.$jPlayer_currenttime.'
						'.$jPlayer_duration.'
						'.$jPlayer_repeat.'
					</div>';
}

$s = '<div id="jquery_jplayer_1" class="jp-jplayer"></div>

		<div id="jp_container_1" class="jp-audio">
			<div class="jp-type-single">
			'.$jPlayer_titles.'
				<div class="jp-gui jp-interface">
					<ul class="jp-controls">
						<li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li>
						<li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>
						'.$jPlayer_stop.'
						'.$jPlayer_mute.'
						'.$jPlayer_unmute.'
						'.$jPlayer_maxvolume.'
					</ul>
					'.$jPlayer_progress.'
					'.$jPlayer_volumebar.'
					'.$jPlayer_timeholder.'
				</div>
				
				'.$this->jPlayer_nosolution.'
			</div>
		</div>';
$s .= '';

return $s;
}


function flash_mp3_player(){

//ereg("^[0-9a-zA-Z]+$" , $s)

if($this->flash_mp3_player_width == ""){ $width = '290'; }else{ $width = $this->flash_mp3_player_width; }
if($this->flash_mp3_player_height == ""){ $height = '24'; }else{ $height = $this->flash_mp3_player_height; }
if($this->flash_mp3_player_auto == 1){ $au = 'yes'; }else{ $au = 'no'; }
if($this->flash_mp3_player_color_bg == ""){ $bg = 'cccccc'; }else{ $bg = $this->flash_mp3_player_color_bg; }
if($this->flash_mp3_player_color_leftbg == ""){ $leftbg = 'ffffff'; }else{ $leftbg = $this->flash_mp3_player_color_leftbg; }
if($this->flash_mp3_player_color_lefticon == ""){ $lefticon = '333333'; }else{ $lefticon = $this->flash_mp3_player_color_lefticon; }
if($this->flash_mp3_player_color_rightbg == ""){ $rightbg = 'ffffff'; }else{ $rightbg = $this->flash_mp3_player_color_rightbg; }
if($this->flash_mp3_player_color_rightbghover == ""){ $rightbghover = 'cccccc'; }else{ $rightbghover = $this->flash_mp3_player_color_rightbghover; }
if($this->flash_mp3_player_color_righticon == ""){ $righticon = '333333'; }else{ $righticon = $this->flash_mp3_player_color_righticon; }
if($this->flash_mp3_player_color_righticonhover == ""){ $righticonhover = '415306'; }else{ $righticonhover = $this->flash_mp3_player_color_righticonhover; }
if($this->flash_mp3_player_color_text == ""){ $text = '333333'; }else{ $text = $this->flash_mp3_player_color_text; }
if($this->flash_mp3_player_color_slider == ""){ $slider = '333333'; }else{ $slider = $this->flash_mp3_player_color_slider; }
if($this->flash_mp3_player_color_track == ""){ $track = 'ffffff'; }else{ $track = $this->flash_mp3_player_color_track; }
if($this->flash_mp3_player_color_border == ""){ $border = 'cccccc'; }else{ $border = $this->flash_mp3_player_color_border; }
if($this->flash_mp3_player_color_loader == ""){ $loader = '333333'; }else{ $loader = $this->flash_mp3_player_color_loader; }
if($this->flash_mp3_player_color_loop == 1){ $loop = 'yes'; }else{ $loop = 'no'; }

$op = 'playerID=audioplayer1&bg=0x'.$bg.'&leftbg=0x'.$leftbg.'&lefticon=0x'.$lefticon.'&rightbg=0x'.$rightbg.'&rightbghover=0x'.$rightbghover.'&righticon=0x'.$righticon.'&righticonhover=0x'.$righticonhover.'&text=0x'.$text.'&slider=0x'.$slider.'&track=0x'.$track.'&border=0x'.$border.'&loader=0x'.$loader.'&loop='.$loop.'&autostart='.$au.'&soundFile='.$this->jPlayer_url.'';

$s = '<script language="javascript" src="'.$this->flash_mp3_player_js_folder.'/audio-player.js"></script>';
$s .= '<div class="flash_mp3_player">';
$s .= '<object type="application/x-shockwave-flash" data="'.$this->flash_mp3_player_js_folder.'/player.swf" id="audioplayer1" height="'.$height.'" width="'.$width.'">
<param name="movie" value="'.$this->flash_mp3_player_js_folder.'/player.swf" />
<param name="FlashVars" value="playerID='.$op.'" />
<param name="quality" value="high" />
<param name="menu" value="false" />
<param name="wmode" value="transparent" />
</object>';
$s .= '</div>';
return $s;
}

function jPlayer_view()
{
if($this->playertype == 1){
$s = $this->jPlayer_head();
$s .= $this->jPlayer_audio();
}else{
$s = $this->flash_mp3_player();
}
return $s;
}

}

$jPlayer = new jPlayer();
if(preg_match('/(apple|iphone|ipod)/i', $_SERVER['HTTP_USER_AGENT']) && preg_match('/mobile/i', $_SERVER['HTTP_USER_AGENT'])) {
$jPlayer->playertype = 1;
}else{
$jPlayer->playertype = 0;
}
//$jPlayer->jPlayer_skin = 'templates/blue/player/audio-style.css';
//$jPlayer->jPlayer_js_jquery = 'js/jPlayer';
$jPlayer->jPlayer_allow_title = 1;
$jPlayer->jPlayer_allow_stop = 1;
$jPlayer->jPlayer_allow_mute = 1;
$jPlayer->jPlayer_allow_unmute = 1;
$jPlayer->jPlayer_allow_maxvolume = 1;
$jPlayer->jPlayer_allow_progress = 1;
$jPlayer->jPlayer_allow_volumebar = 1;
$jPlayer->jPlayer_allow_currenttime = 1;
$jPlayer->jPlayer_allow_duration = 1;
$jPlayer->jPlayer_allow_repeat = 1;

$jPlayer->flash_mp3_player_js_folder = 'js/audio';
$jPlayer->flash_mp3_player_auto = 1;
$jPlayer->flash_mp3_player_color_loop = 1;
$jPlayer->flash_mp3_player_width = 290;
$jPlayer->flash_mp3_player_height = 24;
$jPlayer->flash_mp3_player_color_bg = 'cccccc';
$jPlayer->flash_mp3_player_color_leftbg = 'ffffff';
$jPlayer->flash_mp3_player_color_lefticon = '333333';
$jPlayer->flash_mp3_player_color_rightbg = 'ffffff';
$jPlayer->flash_mp3_player_color_rightbghover = 'cccccc';
$jPlayer->flash_mp3_player_color_righticon = '333333';
$jPlayer->flash_mp3_player_color_righticonhover = 'cccccc';
$jPlayer->flash_mp3_player_color_text = '333333';
$jPlayer->flash_mp3_player_color_slider = '333333';
$jPlayer->flash_mp3_player_color_track = 'ffffff';
$jPlayer->flash_mp3_player_color_border = 'cccccc';
$jPlayer->flash_mp3_player_color_loader = '333333';
//echo $jPlayer->jPlayer_view();
?>