/*
 * jPlayer configuration script for samshousemarin.com
 * http://www.samshousemarin.com/
 *
 * Copyright (c) 2010
 *
 * Author: Marleny Nunez
 * Version: 1.0
 * Date: 20th December 2010
 */
$(document).ready(function() {
	$("#jquery_jplayer").jPlayer( {
		customCssIds: true
	})
	.jPlayer( "cssId", "play", "normal" )
	.jPlayer( "cssId", "pause", "playing" )
	.jPlayer( "cssId", "stop", "loading" );
	
	$(".jp-play").click( function(){
		u = 0;
		if($(this).is(".loading") || $(this).is(".jp-pause")){
			$(this).addClass("jp-play");
			$(this).removeClass("jp-pause");
			$(this).removeClass("loading");
			$(this).removeClass("playing");
			$("#jquery_jplayer").jPlayer( "clearFile" );
			return false;
		} else {
			var strAudio = $(this).attr("title");
			$(this).addClass("loading");
			$(this).removeClass("jp-play");
			$("#jquery_jplayer").jPlayer("setFile", strAudio ).jPlayer("play");
			return false;
		}
	});
	$(".loading").click( function(){
		$(this).addClass("jp-play");
		$(this).removeClass("loading");
		$(this).removeClass("playing");
		$("#jquery_jplayer").jPlayer( "clearFile" );
		return false;
	});
	$("#jquery_jplayer").jPlayer("onSoundComplete", function() {
		$(".jplayer_play > a").addClass("jp-play");
		$(".jplayer_play > a").removeClass("jp-pause");
		$(".jplayer_play > a").removeClass("loading");
	});
	var u = 0;
	$("#jquery_jplayer").jPlayer("onProgressChange", function(lp,ppr,ppa,pt,tt) {
	  if(ppa>0.1 && u!=1){
		$(".jplayer_play > a.loading").addClass("jp-pause");
		$(".jplayer_play > a.jp-pause").removeClass("loading");
		u = 1;
	  }
	});
});

