// PLAY SAMPLE FUNCTIONS

var player = null;
function playerReady(thePlayer) {
	player = window.document[thePlayer.id];
}


function createPlayer() {

	if (!document.getElementById('mp3SamplePlayer')) {
		
	var flashvars = {
		file:"", 
		autostart:"true"
	}

	var params = {
		allowfullscreen:"false", 
		allowscriptaccess:"always"
	}

	var attributes = {
		id:"player1",  
		name:"player1"
	}

	var divTag = document.createElement("div");
	
	divTag.id = "mp3SamplePlayer";
	
	divTag.setAttribute("top","0");
	divTag.setAttribute("left","0");
	divTag.setAttribute("position","absolute");	
	document.body.appendChild(divTag);
								
	var so = new SWFObject("/globalResources/swf/player.swf?", "player1", "0", "0", "9", "false, flashvars, params, attributes");
	so.write("mp3SamplePlayer");
	}
}

var curClipURL = ''
var curPlayingIndex = -1

function playSample(clipNum,clipURL,playImg,stopImg) {
	var flashVersion = deconcept.SWFObjectUtil.getPlayerVersion();

	if(flashVersion['major'] <= 7) {
		document.location = clipURL
	} else {
			
		if (curPlayingIndex != clipNum) {
			player.sendEvent('STOP');
			player.sendEvent('LOAD',clipURL);
			player.sendEvent('PLAY');	
			document.images['playButton' + clipNum].src = stopImg
			if (curPlayingIndex >= 0) document.images['playButton' + curPlayingIndex].src = playImg
			curPlayingIndex = clipNum
		} else {
			player.sendEvent('STOP');
			document.images['playButton' + clipNum].src = playImg
			curPlayingIndex = -1
		}
	}
}

/* for Mozilla/Opera9 */
if (document.addEventListener) {
  document.addEventListener("DOMContentLoaded", createPlayer, false);
/* for IE and others */
} else {
	window.attachEvent( "onload", createPlayer )	
}
/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
  var _timer = setInterval(function() {
    if (/loaded|complete/.test(document.readyState)) {
      createPlayer(); // call the onload handler
    }
  }, 10);
}

