// Author Michael Pelny
// (c) Audiantis GmbH, 2005, 2006
// http://www.audiantis.com/

// *********************
// *** iSound config ***
// *********************

// iSound Hostname
var iSoundHost = "85.214.131.230"; //window.location.host;

// Currently not in use
var customerID = "";

// Port for streaming. If You use a proxy change to port 80.
var streamingPort = "8081";
//var streamingPort = "80";

//Do you use a Proxy? Set path here or leave blank, if you don't use a proxy.
var proxyPath = "";
//var proxyPath = "isndf";

// Path to CGI-Interface on iSound server.
var PathToCGI = "";								// -> Use default value from API: cgi-bin/control.cgi?
//var PathToCGI = "cgi-bin/control.cgi?";			// -> Don't send reply messages to client
//var PathToCGI = "cgi-bin/control-reply.cgi?";	// -> Send reply messages to client

// Don't change. Generated by API
var streamID = "";
streamID = stream_init(iSoundHost, customerID, streamingPort, PathToCGI, streamID, proxyPath);

// Complete streaming URL for Flash Player 
var streamingURL = "http://" + iSoundHost + ":" + streamingPort + "/autoopen/" + streamID;







checkBrowserName("safari");
setScriptLocation("./isound/remote.php");

function checkBrowserName(name){  
    var agent = navigator.userAgent.toLowerCase();  
    if (agent.indexOf(name.toLowerCase())>-1) {  
      enableSafari();  
    }  
    	  
}  



// ********************************
// *** Flash Player Integration ***
// ********************************

function isoundLoadPlayer()
{
	/*
	*** DESCRIPTION ***
		This function puts together the HTML string for player integration and
		writes out the player into the HTML page.
	
	*** USAGE ***
		e.g. in body of HTML page 
	
	*** PARAMETERS ***
		none
						  
	*** VARIABLES ***
		player : Takes the HTML string
	
	*** RETURN VALUE ***
		none
	*/
	var player = "";
	
	// Put together the HTML string for player integration
	player =  "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='1' height='1' id='iSoundPlayer' align='middle'>";
	player += "<param name='allowScriptAccess' value='sameDomain' />";
	player += "<param name='flashvars' value='sound=" + streamingURL + "' />";
	//player += "<param name='movie' value='iSoundPlayer.swf' />";
	player += "<param name='movie' value='http://audiantis.com/isound/iSoundPlayer.swf' />";
	player += "<param name='quality' value='high' />";
	player += "<param name='bgcolor' value='#FFFFFF' />";
	//player += "<embed src='iSoundPlayer.swf' id='iSoundPlayer' flashvars='sound=" + streamingURL + "' swLiveConnect='true' quality='high' bgcolor='#f0f0f0' width='100' height='100' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	player += "<embed src='http://audiantis.com/isound/iSoundPlayer.swf' id='iSoundPlayer' flashvars='sound=" + streamingURL + "' swLiveConnect='true' quality='high' bgcolor='#FFFFFF' width='1' height='1' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	player += "</object>";
	
	// Write complete HTML-tag out for player integration into page				
	document.write(player);
}

// **********************
// *** Sound handling ***
// **********************			
function mysound_start(fname)
{
	/*
	*** DESCRIPTION ***
		This function sets a sound on the opened stream by
		calling the appropriate API function
	
	*** USAGE ***
		e.g. in HTML-Code: <a href="javascript:mysound_start('sounds/demo/vox.pcm')">start</a>
	
	*** PARAMETERS ***
		fnme : Name of PCM file to play (incl. path)
			 : REQUIRED
	
	*** VARIABLES ***
		none
								
	*** RETURN VALUE ***
		none
	*/
	
	// Call API function 'sound_start(streamID, fname, volume, fade_time, loop)'
	sound_start(streamID, fname, 200, 1, 1);
}

function mysound_stop(fname)	
{
	/*
	*** DESCRIPTION ***
		This function stops a sound on the opened stream by
		calling the appropriate API function
	
	*** USAGE ***
		e.g. in HTML-Code: <a href="javascript:mysound_stop('sounds/demo/vox.pcm')">stop</a>
	
	*** PARAMETERS ***
		fnme : Name of PCM file to stop (incl. path)
			 : REQUIRED
	
	*** VARIABLES ***
		none
								
	*** RETURN VALUE ***
		none
	*/

	// Call API function 'sound_stop(streamID, fname, volume, fade_time)'
	// Parameter 'volume' currently not in use.
	sound_stop(streamID, fname, 1);
}
