function findeFlash (flash) {
    if (document.all) {
      if (document.all[flash]) {
        return document.all[flash];
      }
      if (window.opera) {
		try {
	        var movie = eval(window.document + flash);
		}
		catch(exception) {
			return false;
		}
        if (movie.SetVariable) {
          return movie;
        }
      }
      return;
    }
    if(document.layers) {
      if(document.embeds) {
        var movie = document.embeds[flash];
        if (movie.SetVariable) {
          return movie;
        }
      }
      return;
    }
    if (!document.getElementById) {
      return;
    }
    var movie = document.getElementById(flash);
	if (!movie) return;
    if (movie.SetVariable) {
      return movie;
    }
    var movies = movie.getElementsByTagName('embed');
    if (!movies || !movies.length) {
      return;
    }
    movie = movies[0];
    if (movie.SetVariable) {
      return movie;
    }
    return;
  }
  
function _debug(obj, str) {
	//return;
	var s = str+'\n';
	s += 'Objekt: '+obj+'\n\n';
	for(temp in obj) s += temp +': '+obj[temp]+'\n';
	alert(s);
}

  

		
	function get_cookie_val(key) {
		if (!document.cookie) return null;
		var sRE = "(?:; )?" + key + "=([^;]*);?";
		var oRE = new RegExp(sRE);
		if (oRE.test(document.cookie)) {
			return decodeURIComponent(RegExp["$1"]);
		}
		else {
			return null;
		}
	}
		
	function set_cookie_val(key, val) {
		document.cookie = key + "=" + escape(val) + "; path=/;";
	}
	
	function sound_come() {
		var film = findeFlash('sg_sound');
		if (!film) { 
			if (flash_find++ < 300) window.setTimeout('sound_come()', 100);
			return;
		}

		flash_found = true;
		for (v in flash_vars) {
			flash_vars[v] = parseFloat(get_cookie_val(v));
			if (!flash_vars[v] || flash_vars[v] == 'null') flash_vars[v] = flash_vars_def[v];
		}
		for (v in flash_vars) {
			eval("try{film.SetVariable('_root."+v+"', '"+flash_vars[v]+"');} catch(e) { flash_found = false; }");
		}
	}
/*	
		var flash_pos= film.GetVariable('_root.mp3pos');
		var flash_vol= film.GetVariable('_root.musicvol');
		var flash_play = film.GetVariable('_root.startplay');
		set_cookie_val('soundpos', flash_pos);		
		set_cookie_val('startplay', flash_play);
		set_cookie_val('musicvol', flash_vol);		
*/
	function sound_go() {
		if (!flash_found) return;
		var film = findeFlash('sg_sound');
		if (!film) { return; }

		for (v in flash_vars) {
			var _v = v;
			if (v == 'musicposition') _v = 'mp3pos';
			flash_vars[v] = film.GetVariable('_root.'+_v);
		}
		for (v in flash_vars) {
			set_cookie_val(v, flash_vars[v]);
		}
	}
	