var UA=navigator.userAgent.toLowerCase();
// IE
var ffpr_ie6=false;var ffpr_ie=false;
if(UA.indexOf('msie')>-1) { var tmp=UA.substring(UA.indexOf('msie')+5,UA.length);var ieV=tmp.substring(0,tmp.indexOf(";"));if(ieV<7) { ie6=true; } ie=true; }


var tr_posX=0;
var tr_posEnd=0;
var tr_timer=2;
function tr_slideIn() {
	if(tr_posX==0) {
		tr_posEnd=document.getElementById('topnav').offsetWidth;
		document.getElementById('topnav').style.position='absolute';
		document.getElementById('topnav').style.top="0px";
		document.getElementById('topnav').style.visibility="visible";
	}
	if(tr_posX<tr_posEnd) {
		document.getElementById('topnav').style.left="-"+((tr_posEnd-(tr_posX)))+"px";
		var step=25;
		if(tr_posX>=(tr_posEnd*0.25)) {	step=20; }
		if(tr_posX>=(tr_posEnd*0.50)) {	step=15; }
		if(tr_posX>=(tr_posEnd*0.75)) {	step=10; }
		if(tr_posX>=(tr_posEnd*0.95)) {	step=5; tr_timer=2; }
		tr_posX+=step;
		window.setTimeout("tr_slideIn()",tr_timer);
	}
	return;	
}

function tr_findFlash (flash) {
if (document.all) {
  if (document.all[flash]) {
	return document.all[flash];
  }
  if (window.opera) {
	var movie = eval(window.document + flash);
	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.SetVariable) {
  return movie;
}
var movies = movie.getElementsByTagName('embed');
if (!movies || !movies.length) {
  return;
}
movie = movies[0];
if (movie.SetVariable) {
  return movie;
}
return;
}


function tr_setCookie(name, value) { 
    var argv=(arguments?arguments:tr_setCookie.arguments); 
    var argc=argv.length; 
    var expires=(argc > 2)?argv[2]:null; 
    var path="/";//(argc > 3)?argv[3]:null; 
    var domain=(argc > 4)?argv[4]:null; 
    var secure=(argc > 5)?argv[5]:false; 
    var cookieStr=name + "=" + escape (value) + 
      ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
      ((path == null) ? "" : ("; path=" + path)) + 
      ((domain == null) ? "" : ("; domain=" + domain)) + 
      ((secure == true) ? "; secure" : "");
    document.cookie=cookieStr;
}

function tr_getCookie(name) { 
    var arg = name + "="; 
    var alen = arg.length; 
    var clen = document.cookie.length; 
    var i = 0; 
    while (i < clen) { 
        var j = i + alen; 
        if(document.cookie.substring(i,j) == arg) 
        return tr_getCookieValue(j); 
        i = document.cookie.indexOf(" ",i)+1; 
        if(i == 0) break; 
    } 
    return null;
}
function tr_getCookieValue(offset) { 
    var endstr = document.cookie.indexOf (";", offset); 
    if(endstr == -1) 
    endstr = document.cookie.length; 
    return unescape(document.cookie.substring(offset, endstr));
}


var tr_soundState=1;
var tr_soundFile=false;
var tmp=tr_getCookie('audio');
if(tmp!=null) { 
	tr_soundState=tmp; 
}

function tr_isObject(targetID){
   var isFound = false;
   var el = document.getElementById("audiofile");
   if(el && (el.nodeName === "OBJECT" || el.nodeName === "EMBED")){ isFound = true; }
   return isFound;
}

function tr_soundSwitch(state) {
	if(!tr_soundFile) return;
	if(state==null) {
		if(tr_soundState==1) { state=0; }
		else { state=1; }
	}
	else {
		state=tr_soundState;	
	}
//	var movie=document.getElementById('myFlashSound');
//	var movie=swfobject.getObjectById('myFlashSound');
	if(state==0) {
		tr_soundState=0;
		document.getElementById('audiolink').innerHTML='Audio on';
		if(tr_isObject('audiofile')) {		
		  var el = document.getElementById("audiofile");
		  if(el){
			  var div = document.createElement("div");
			  el.parentNode.insertBefore(div, el);
			  //Remove the SWF
			  swfobject.removeSWF("audiofile");
			  //Give the new DIV the old element's ID
			  div.setAttribute("id", "audiofile");
		   }
		}
	}
	else {
		tr_soundState=1;
		document.getElementById('audiolink').innerHTML='Audio off';		

			if(tr_isObject('audiofile')) {	
			
			  var el = document.getElementById("audiofile");
			  if(el){
				  var div = document.createElement("div");
				  el.parentNode.insertBefore(div, el);
				  //Remove the SWF
				  swfobject.removeSWF("audiofile");
				  //Give the new DIV the old element's ID
				  div.setAttribute("id", "audiofile");
			   }
			}		
			var flashvars = {};
			var params = {};
			params.play = "true";
			params.loop = "true";
			params.menu = "false";
			params.quality = "best";
			params.scale = "noscale";
			params.wmode = "transparent";
			params.allowfullscreen = "false";
			params.allowscriptaccess = "sameDomain";
			var attributes = {};
			swfobject.embedSWF("/media/"+tr_soundFile, "audiofile", "1", "1", "6.0.0", false, flashvars, params, attributes);
	}
	tr_setCookie('audio',tr_soundState);
}