/*
	
	JavaScripts used throughout the DarklyAbsurd.com site
	
	-> Embedded music player
	-> Open full size image
	
*/


function open_image(Imageurl) {
	var imageFolder = "images/";
	
	$('full_size_image').update('<div class="imagecloser"><a class="imagecloser" href="javascript:close_image()">X CLOSE</a></div><img class="fullscreen" src="' + imageFolder + Imageurl + '" />');
}


function close_image() {
	$('full_size_image').update('');
}


function play(MP3file, MP3dir) {
	$(MP3file).update(embedPlayer(MP3file, MP3dir));
}


function embedPlayer(MP3url, MP3dir) { 
   // If you have a default audio directory, e.g., http://www.your-media-hosting-site.com/sounds/, you can put it here to make links on the referring page shorter.
	 var audioFolder = "audio/";
	 
	 // Get Operating System 
   var isWin = navigator.userAgent.toLowerCase().indexOf("windows") != -1;
   if (isWin) { // Use MIME type application/x-mplayer2
      visitorOS="Windows";
   } else { // Use MIME type audio/mpeg, audio/x-wav, etc.
      visitorOS="Other";
   }

   var audioURL = audioFolder + MP3dir + "/" + MP3url;
   var objTypeTag = "application/x-mplayer2"; // The MIME type to load the WMP plugin in non-IE browsers on Windows
   if (visitorOS != "Windows") { objTypeTag = "audio/mpeg"}; // The MIME type for Macs and Linux
  
	 html = "<object width='280' height='69'>" // Width is the WMP minimum. Height = 45 (WMP controls) + 24 (WMP status bar)
   html += "<param name='type' value='" + objTypeTag + "'>"
   html += "<param name='src' value='" + audioURL + "'>"
   html += "<param name='autostart' value='1'>"
   html += "<param name='showcontrols' value='1'>"
   html += "<param name='showstatusbar' value='1'>"
   html += "<embed src ='" + audioURL + "' type='" + objTypeTag + "' autoplay='true' autostart='1' width='280' height='69' controller='1' showstatusbar='1' bgcolor='#E6E6E6'></embed>" 
   html += "</object>"
	 
	 return html
}
