function Schreiben(strBasePath){
  var a = new Date();
  a = new Date(a.getTime()+99960000);
  var Jetzt = new Date();
  Jetzt = new Date(Jetzt.getTime()-99960000);
  
  document.cookie = 'SoundLogoTA=1#'+Jetzt.getTime() +'; expires='+a.toGMTString()+';';
 writeCode(strBasePath);
}

function Lesen(){
 n = 'SoundLogoTA';
 a = document.cookie;
 res = '';
 while(a != '')
 {
  while(a.substr(0,1) == ' '){a = a.substr(1,a.length);}
  cookiename = a.substring(0,a.indexOf('='));
  if(a.indexOf(';') != -1)
  {cookiewert = a.substring(a.indexOf('=')+1,a.indexOf('#'));}
  else{cookiewert = a.substr(a.indexOf('=')+1,a.length);}
  if(n == cookiename){res = cookiewert;}
  i = a.indexOf(';')+1;
  if(i == 0){i = a.length}
  a = a.substring(i,a.length);
 }
 return(res);
}

function Loeschen(strBasePath){
  var a = new Date();
  a = new Date(a.getTime()+99960000);
  var Jetzt = new Date();
  Jetzt = new Date(Jetzt.getTime()-864000);
  
 document.cookie = 'SoundLogoTA=0#'+Jetzt.getTime()+'; expires='+a.toGMTString()+';';
 //alert('SoundLogoTA=0; expires='+a.toGMTString()+';');
 writeCode(strBasePath);
 //location.reload();
} 
function writeCode(strBasePath){
    var tx="";
    if (Lesen()=='1'){
	    tx=('<a href="javascript:;" onclick="Loeschen(\'' + strBasePath + '\')"><img src="' + strBasePath + 'speaker_on_16.png" width="16" height="16" alt="Soundlogo ausschalten" /></a>');
	    //location.reload();
	}
	if(Lesen()=='0'){
		tx=('<a href="javascript:;" onclick="Schreiben(\'' + strBasePath + '\')"><img src="' + strBasePath + 'speaker_off_16.png" width="16" height="16" alt="Soundlogo einschalten" /></a>');
		//location.reload();
    }
    document.getElementById("SoundButton").innerHTML=tx;
}
function zusammenbauen(strBasePath){
if (Lesen()==''){
		    Schreiben(strBasePath);
		}

		if (Lesen()=='1'){
			a = document.cookie.split('#')[1];
			var LastRun = new Date(a.substring(0,a.indexOf(';')));
			var Jetzt = new Date();
			Jetzt = new Date(Jetzt.getTime());
			
			var Rest = Math.floor(Jetzt - a.substring(0,a.indexOf(';')));
		    if (Rest>86400000) {
			
		    Schreiben(strBasePath);
			  var a = new Date();
  a = new Date(a.getTime()+99960000);
			document.cookie = 'SoundLogoTA=1#'+Jetzt.getTime() +'; expires='+a.toGMTString()+';';
			var swfVersionStr = "0";
			var xiSwfUrlStr = "";
			var flashvars = {};
			var params = {};
			params.quality = "high";
			params.bgcolor = "#ffffff";
			params.play = "true";
			params.loop = "false";
			params.wmode = "transparent";
			params.scale = "noscale";
			params.menu = "false";
			params.devicefont = "false";
			params.salign = "lt";
			params.allowscriptaccess = "sameDomain";
			var attributes = {};
			attributes.id = "soundlogo";
			attributes.name = "soundlogo";
			attributes.align = "middle";
			swfobject.createCSS("flashContent", "style=margin:0; padding:0; width:1px,height:1px;");
			swfobject.createCSS("object", "margin:0; padding:0; overflow:hidden;");
       		swfobject.embedSWF(
				strBasePath + "soundlogo.swf", "flashContent",
				"1", "1",
				swfVersionStr, xiSwfUrlStr,
				flashvars, params, attributes);
				}

       }
}

