//
// soundScript.js - Sound Handling
// Version 1.0.0
// Author Marian Dix
// (c) Audiantis GmbH, 2009
// http://www.audiantis.com/
//

// Declaration

	
	    var activAudioStream="";
		var activVideoStream="";
		var vol=250;
		var currentID;
		var muteStatus=false;
		var currentLanguage = "eng";
		var aktivAd;
		
		

		
		//AD
		
		var xpos_selected = "0";
		var ypos_selected = "0";
		var fade_selected = "3";
		var alpha_selected= "1";
		var size_selected= "2";
		var start_time_selected= "2";
		var count_page=0;
		var count_click=0;
		var count_display=0;
		var duration =0;
		
		
		
		
		
		




		var 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>";
		
		
		//var InfoBox = '';

function updateInfo() {
    div = document.getElementById('Info');
    div.innerHTML = InfoBox;
    window.setTimeout('updateInfo()',1000); // 3 Sekunden
}


		
		function getAdWWW(){
    var x=document.getElementById("ad2")
    return(x.options[x.selectedIndex].text);
}
		
		
				function stopVideo(){
			if(activVideoStream!=""){
					vkk = "stopvideo|" + g_isoundStreamID + "|videos/"+activVideoStream+"|";
					sendCommand(vkk);
			}
		}	
		
		
		
		function startVideoFirstTime()
		{
		window.setTimeout("startVideo('staatsfeind')", 2000);
		}
		function startVideo(video)
		{
			stopAll();
			
			if(video == "staatsfeind"){
			muteStatus=false;
			vkk =  "setsound|" + g_isoundStreamID + "|sounds/staatsfeind/de_staatsfeind.pcm|0|1|1~";
			vkk += "setsound|" + g_isoundStreamID + "|sounds/staatsfeind/en_staatsfeind.pcm|250|1|1~";
			vkk += "setsound|" + g_isoundStreamID + "|sounds/staatsfeind/ita_staatsfeind.pcm|0|1|1~";
			vkk += "setvideo|" + g_isoundStreamID + "|videos/staatsfeind.flv|";
			currentID = 1;;
			window.setTimeout("sendCommand('"+vkk+"')", 1000);
			activAudioStream="staatsfeind/en_staatsfeind.pcm";
			activVideoStream="staatsfeind.flv";
			
			}else if(video == "hitch"){
				muteStatus=false;
				vkk =  "setsound|" + g_isoundStreamID + "|sounds/hitch/de_hitch.pcm|150|1|1|1~";
				vkk += "setsound|" + g_isoundStreamID + "|sounds/hitch/en_hitch.pcm|0|1|1~";
				vkk += "setsound|" + g_isoundStreamID + "|sounds/hitch/pol_hitch.pcm|0|1|1~";
				vkk += "setvideo|" + g_isoundStreamID + "|videos/hitch.flv|";
				window.setTimeout("sendCommand('"+vkk+"')", 1000);
				currentID = 2;
				activAudioStream="hitch/de_hitch.pcm";
				activVideoStream="hitch.flv";
			}else if(video == "smoking"){
				muteStatus=false;
				vkk =  "setsound|" + g_isoundStreamID + "|sounds/smoking/de_smoking.pcm|150|1|1~";
				vkk += "setvideo|" + g_isoundStreamID + "|videos/smoking.flv|";
				window.setTimeout("sendCommand('"+vkk+"')", 1000);
				currentID = 4;
				activAudioStream="smoking/de_smoking.pcm";
				activVideoStream="smoking.flv";
				
			}else if(video == "matrix"){
				muteStatus =false;
				vkk  = "setsound|" + g_isoundStreamID + "|sounds/matrix/de_matrix.pcm|150|1|1~";
				vkk += "setsound|" + g_isoundStreamID + "|sounds/matrix/en_matrix.pcm|0|1|1~";
				vkk += "setvideo|" + g_isoundStreamID + "|videos/matrix.flv|";
				window.setTimeout("sendCommand('"+vkk+"')",1000);
				currentID=3;
				activAudioStream="matrix/de_matrix.pcm";
				activVideoStream="matrix.flv";
			}
			
		}
		function stopAll(){
		if(activVideoStream== "staatsfeind.flv"){
			vkk =  "stopsound|" + g_isoundStreamID + "|sounds/staatsfeind/de_staatsfeind.pcm|~";
			vkk += "stopsound|" + g_isoundStreamID + "|sounds/staatsfeind/en_staatsfeind.pcm|~";
			vkk += "stopsound|" + g_isoundStreamID + "|sounds/staatsfeind/ita_staatsfeind.pcm|~";
			vkk += "stopvideo|" + g_isoundStreamID + "|videos/staatsfeind.flv|";	
			window.setTimeout("sendCommand('"+vkk+"')", 500);
			//alert(vkk);
			activVideoStream="";
			activAudioStream="";
		} else if(activVideoStream=="hitch.flv"){
			//alert("stop hitch sound");
			vkk =  "stopsound|" + g_isoundStreamID + "|sounds/hitch/de_hitch.pcm|~";
			vkk += "stopsound|" + g_isoundStreamID + "|sounds/hitch/en_hitch.pcm|~"; 
			vkk += "stopsound|" + g_isoundStreamID + "|sounds/hitch/pol_hitch.pcm|~";
			vkk += "stopvideo|" + g_isoundStreamID + "|videos/hitch.flv|";
			window.setTimeout("sendCommand('"+vkk+"')", 500);
			//alert(vkk);
			activVideoStream="";
			activAudioStream="";			
		}else if(activVideoStream=="smoking.flv"){
			vkk =  "stopsound|" + g_isoundStreamID + "|sounds/smoking/de_smoking.pcm|~";
			vkk += "stopvideo|" + g_isoundStreamID + "|videos/smoking.flv|";
			activVideoStream="";
			activAudioStream="";
			window.setTimeout("sendCommand('"+vkk+"')", 500);
			
		}else if(activVideoStream=="matrix.flv"){
			vkk  = "stopsound|" + g_isoundStreamID + "|sounds/matrix/de_matrix.pcm|~";
			vkk += "stopsound|" + g_isoundStreamID + "|sounds/matrix/en_matrix.pcm|~";
			vkk += "stopvideo|" + g_isoundStreamID + "|videos/matrix.flv";
			activVideoStream="";
			activAudioStream="";
			window.setTimeout("sendCommand('"+vkk+"')", 500);
		}
		}
		function mute(){
		
			if(activAudioStream!= "" || !muteStatus){
				vkk =  "setvolsound|" + g_isoundStreamID + "|sounds/"+activAudioStream+"|0";
				sendCommand(vkk);
				muteStatus = !muteStatus;
				//alert(vkk);
			}else if(activAudioStream!="" || muteStatus){
				vkk =  "setvolsound|" + g_isoundStreamID + "|sounds/"+activAudioStream+"|"+vol;
				sendCommand(vkk);
				muteStatus = !muteStatus;
			}
		}

		function changeLang(sound1,id,language){
			
			
			
			
			//wenn Werbung aktiv wechsel die sprache nicht!
			if(aktivAd != 'true')
			{
			
			if(id == currentID){
		  	vkk =  "setvolsound|" + g_isoundStreamID + "|sounds/staatsfeind/de_staatsfeind.pcm|0~";
			  vkk +=  "setvolsound|" + g_isoundStreamID + "|sounds/staatsfeind/en_staatsfeind.pcm|0~";
				vkk +=  "setvolsound|" + g_isoundStreamID + "|sounds/staatsfeind/ita_staatsfeind.pcm|0~";
				vkk += "setvolsound|" + g_isoundStreamID + "|sounds/" + sound1 +"|"+vol;
				sendCommand(vkk);
				activAudioStream=sound1;
				currentLanguage = language;
				//benachrichtig php script über neue sprache
				SendLangChange(language);
				//alert(vkk);
			}
			}
		}
		function increaseVol(){
			if(vol!=250){
				vol=vol+30;
				vkk =  "setvolsound|" + g_isoundStreamID + "|sounds/"+activAudioStream+"|"+vol;
				sendCommand(vkk);
			}
		}
		function decreaseVol(){
			if(vol!=0) {
				vol=vol-30;
				vkk =  "setvolsound|" + g_isoundStreamID + "|sounds/"+activAudioStream+"|"+vol;
				sendCommand(vkk);
			}
		}
		
		function lowVolOnAd(){
			
				vkk =  "setvolsound|" + g_isoundStreamID + "|sounds/"+activAudioStream+"|50";
				sendCommand(vkk);
			
		}
		
		function hightVolOnAd(){
			
				vkk =  "setvolsound|" + g_isoundStreamID + "|sounds/"+activAudioStream+"|200";
				sendCommand(vkk);
			
		}
		function check(){
			if(document.filmselection.film[0].checked) alert("staatsfeind");
		}