//
// iMedia_player-api.js - General configuration, add Content etc.
// Version 1.0.2
// Author Marian Dix, Max Behrsing
// (c) Audiantis GmbH, 2008
// http://www.audiantis.com/
//

//-latest change
//-exist variable
//-fade in/out for Banners

// Declaration
var player;
var name;
var exist=false;


// ************************
// *** StopStream ***
// ************************
function stopStream() {

/*
	*** DESCRIPTION ***
		The current Stream will be stoped

	*** USAGE ***
	<a href="javascript:stopStream();">stoppe iMedia Player via javascript function</a> 

	*** PARAMETERS ***
		None

	*** VARIABLES ***
		None

	*** RETURN VALUE ***
		None
	*/

     player.StopStream();
}

// ************************
// *** eraseBanner ***
// ************************
function eraseBanner(fadeTime) {

/*	*** DESCRIPTION ***
		An ativ Banner/Swf will be erased

	*** USAGE ***
	<a href="javascript:eraseBanner('3');">eraseBanner</a>

	*** PARAMETERS ***
		fadeTime = Time ins sec. fade out

	*** VARIABLES ***
		None

	*** RETURN VALUE ***
		None
	*/

     player.EraseBanner(fadeTime);
}

// ************************
// *** eraseText ***
// ************************
function eraseText() {
	
/*	*** DESCRIPTION ***
		An ativ Textfield will be erased

	*** USAGE ***
	<a href="javascript:eraseText();">eraseText</a>

	*** PARAMETERS ***
		None

	*** VARIABLES ***
		None

	*** RETURN VALUE ***
		None
	*/

     player.EraseText();
}
// ************************
// *** setBanner ***
// ************************
function setBanner(src,url,x,y,fadeTime,duration,alpha,x_size,y_size) {

/*	*** DESCRIPTION ***
		Sets an banner into the video area.
		you can set all kind of pictures and .swf files

	*** USAGE ***
	<a href="javascript:setBanner('http://audiantistest.com/demos/wmode.swf','http://www.audiantis.com',0,0,3);">setBanner</a>

	*** PARAMETERS ***
		src = the source path of the file
		url = a link which is ativ if you click on the shown Banner
		x   = horizontal position
		y   = vertikal position
	   fadeTime = Time ins sec. fade out
           duration = in sec. how long the banner will be displayed
	      alpha = transparency (0.0 , 0.1 ...1.0)

	*** VARIABLES ***
		None

	*** RETURN VALUE ***
		None
	*/

     player.setBanner(src,url,x,y,fadeTime,duration,alpha,x_size,y_size);
}

// ************************
// *** setText ***
// ************************
function setText(txt,x,y,width,url) {


    
     player.SetText(txt,x,y,width,url);
}



// ************************
// *** setStaticLogo ***
// ************************
function setStaticLogo(source,x,y,alpha) {

/*	*** DESCRIPTION ***
		Sets an static Logo the video area.
		you can adjust the the Shown Textsfield via html tags

	*** USAGE ***
	<a href="javascript:setText('<P ALIGN=\'LEFT\'><FONT FACE=\'Times New Roman\' SIZE=\'20\' COLOR=\'#FF0000\' ><b>Lorem ipsum dolor sit amet.</b></FONT></P>',2,2,320,'http://web.de');">setText</a>

	*** PARAMETERS ***
		Source = 
		x     = horizontal position
		y     = vertikal position
		alpha = transparency (0.0 , 0.1 ...1.0)

	*** VARIABLES ***
		None

	*** RETURN VALUE ***
		None
	*/
    
     player.setStaticLogo(source,x,y,alpha);
}


// *********************
// *** OnBannerEvent ***
// *********************
function BannerEvent(bannerevent)
{

	/*
	*** DESCRIPTION ***
		This function is called if the video iMedia player erase a shown Banner content


	
	*/
//alert(bannerevent);
if(bannerevent== "BannerErased")
{
	//alert(bannerevent);
	hightVolOnAd();
	//button wird wieder aktiviert
	document.getElementById("b1").disabled=false;
	
	//#######
	// Variable für aktive werbung wird auf false gesetzt somit sind die flaggen wieder frei
	aktivAd= 'false';
MM_swapImage('Image1','','img/fahne_en.jpg',1);
MM_swapImage('Image2','','img/fahne_ita.jpg',1);
MM_swapImage('Image3','','img/fahne_de.jpg',1);
	//#######
	
	count_display += duration;
	
	InfoBox =  "<span class='style4'>Mesure the audiance of your Instream Video Ad</span><br />"
		    + " <center><table width='232' border='0'>"
           	+ "<tr>"
  		   	+ "<td><span class='style3'>Ad Impression </span></td>"
    	  	+ " <td><span class='style3'>Click-Through </span></td>"
      		+ "<td><span class='style3'>Display Duration </span></td>"
    		+ "</tr>"
    		+ "<tr>"
      		+ "<td><center><span class='style3'>"+count_page+"</span></center></td>"
      		+ "<td><center><span class='style3'>"+count_click+"</span></center></td>"
      		+ "<td><center><span class='style3'>"+count_display+"</span></center></td>"
    		+ "</tr>"
  			+ "</table></center>";
}

}

// *********************
// *** onClickEvent ***
// *********************
function onClickEvent(event)
{

	/*
	*** DESCRIPTION ***
		This function is called after clicking an Ad


	
	*/

	count_click += 1;
	
	InfoBox = "<span class='style4'>Mesure the audiance of your Instream Video Ad</span><br />"
		    + " <center><table width='232' border='0'>"
           	+ "<tr>"
  		   	+ "<td><span class='style3'>Ad Impression </span></td>"
    	  	+ " <td><span class='style3'>Click-Through </span></td>"
      		+ "<td><span class='style3'>Display Duration </span></td>"
    		+ "</tr>"
    		+ "<tr>"
      		+ "<td><center><span class='style3'>"+count_page+"</span></center></td>"
      		+ "<td><center><span class='style3'>"+count_click+"</span></center></td>"
      		+ "<td><center><span class='style3'>"+count_display+"</span></center></td>"
    		+ "</tr>"
  			+ "</table></center>";

}



// ************************
// *** createPlayer ***
// ************************
function createPlayer(movieName,path,instantStart,def_vol,bt_link) {
	


/*	*** DESCRIPTION ***
		Creats the param tags for embading the flashplayer.
		You can set different default settings.

		Features:
		You can choose between direct play or pause mode with the "instantStart" parameter.
		You can set the Default Volumen with the "def_vol" parameter.
		You can set a mode for the FullScreenButton with with the "bt_link" parameter. 
		(If you set bt_link = 0 the normal fullscreen mode is aktiv)
		(If you set bt_link = e.g. http://audiantis.com the fullscreen mode is disable and on click on the FullScreenButton you will get a new windows with the Url)

	*** USAGE ***
	<script>
	createPlayer('iMediaPlayer','isound/iMedia_Player_frontpage.swf','true',0,0);
	</script>

	*** PARAMETERS ***
		movieName  	= Sets the name of the flashplayer object
		path       	= The path to iMedia Player. You can also sets a full path
		instantStart	= if instsantStart = true the player will be play the stream instant after loading.
		def_vol         = Sets a Default Volume. 0-70
		bt_link		= If bt_link is set to 0 the Fullscreen button is aktiv. If bt_link is a url like "http://audiantis.com" the fullscreen mode is disable and the works like a normale linkbutton.
		txt   = the text which will be set
		x     = horizontal position
		y     = vertikal position
		width = sets the width of the textfield.
		url   = a link which is ativ if you click on the shown Banner

	*** VARIABLES ***
		None

	*** RETURN VALUE ***
		None
	*/
	if(!exist) {

          name = movieName;
 		       
          var myplayer = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='320' height='240' id='" + name + "' align='middle'>"
                         + "<param name='allowScriptAccess' value='sameDomain' />"
                         + "<param name='allowFullScreen' value='true' />"
                         + "<param name='flashvars' value='sound=" + g_isoundStreamingURL + " &streamID= "+ g_isoundStreamID +"&instantStart=" + instantStart + "&defaultVolume=" + def_vol + "&fullscreenBtnUrl=" + bt_link + " '  />"
                         + "<param name='movie' value='" + path + "' />"
                         + "<param name='quality' value='high' />"
                         + "<param name='bgcolor' value='#000000' />"
                         + "<param name='loop' value='false' />"	
                         + "<embed src='" + path + "' name='" + name + "'  flashvars='sound=" + g_isoundStreamingURL + " &streamID= "+ g_isoundStreamID +"&instantStart=" + instantStart + "&defaultVolume=" + def_vol + "&fullscreenBtnUrl=" + bt_link + " ' swLiveConnect='true' quality='high' bgcolor='#000000' loop='false' width='320' height='240' align='middle' allowScriptAccess='sameDomain' allowFullScreen='true' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"
                         + "</object>";
		   
          document.getElementById('video').innerHTML += myplayer;

          var isIE = navigator.appName.indexOf("Microsoft") != -1;
          player = (isIE) ? window[movieName] : document[movieName];
          exist=true;
     }
}



