function writeFlash(_file,_width,_height,_bgcolor,_wmode,_id) {
	document.write('<object data="'+_file+'" type="application/x-shockwave-flash" width="'+_width+'" height="'+_height+'" id="'+(_id?_id:'flashMovie')+'"  align="middle">');
	document.write('<param name="movie" value="'+_file+'"/>\n');
	document.write('<param name="menu" value="false"/>\n');
	document.write('<param name="qulality" value="best"/>\n');
	document.write('<param name="AllowScriptAccess" value="always"/>\n');
	document.write('<param name="align" value="middle"/>\n');
   if(_bgcolor) {
		document.write('<param name="bgcolor" value="'+_bgcolor+'"/>\n');
   }
   if(_wmode) {
		document.write('<param name="wmode" value="transparent"/>\n');
   }
   document.write('<embed src="'+_file+'" menu="false" '+(_wmode?'wmode="'+_wmode+'"':'')+' '+(_bgcolor?'bgcolor="'+_bgcolor+'"':'')+' quality="best" width="'+_width+'" height="'+_height+'" AllowScriptAccess="always" scale="exactfit" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>\n');
   document.write('</object>\n');
}


popup = false;
audioOn = layout + 'audio_on_'+lang+'.jpg';
audioOff = layout + 'audio_off_'+lang+'.jpg';

function swapAudio(_lang) {
	d = document.getElementById('audio');
	if(!popup) {
   	popup = window.open(dir + "static/flash/flash_"+_lang+".html",'Audioplayer',"width=110,height=35,scrollbars=no,resizable=no");
      d.src = audioOn;
   } else {
   	popup.close();
      popup = false;
      d.src = audioOff;
   }

}

function checkArrows() {
   frame_s = document.getElementById('frame');
   arrow_up_s = document.getElementById('arrow_up');
   arrow_down_s = document.getElementById('arrow_down');


   if(frame_s && arrow_up_s && arrow_down_s) {
   	if(frame_s.parentNode.offsetHeight < frame_s.offsetHeight) {
      	arrow_up_s.style.display = "block";
         arrow_down_s.style.display = "block";
         maxi = frame_s.parentNode.offsetHeight-frame_s.offsetHeight;
      }
   }
}

/* Startup */

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function setContent() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentElement = document.getElementById('align');
			var contentHeight = contentElement.offsetHeight;
			if (windowHeight - contentHeight > 0) {
				contentElement.style.position = 'relative';
				contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
			}
			else {
				contentElement.style.position = 'static';
			}
		}
	}
}

window.onresize = function() {
	setContent();
}

/* FUNCTIONS */

var isIE_PNG = (navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf('Opera') == -1);

function Popup(path,name,width,height,scrolling,resizable)
 {
   window.open(path,name,"width="+width+",height="+height+",scrollbars="+scrolling+",resizable="+resizable);
 }

var isMoving = false;
var inMove = false;
var element = "frame";
var refreshRate = 20;
var space = 3;

function startMove(direction) {
	isMoving = direction;
   if(!inMove) {
   	inMove = true;
	   window.setTimeout("move('"+direction+"')",refreshRate);
   }
}

function stopMove() {
	isMoving = false;
}

function move(direction) {


	if(isMoving == direction) {

	   d = document.getElementById(element);

      var left = d.style.top;
		left = left.substring(0,left.length-2)*1;

      if(direction == "up") {
			left -= space;
		} else {
			left += space;
		}

      if(left > 0) {
      	left = 0;
      } else if(left < maxi) {
      	left = maxi;
      }

		d.style.top = left + "px";

		window.setTimeout("move('"+direction+"')",refreshRate);

	}
   inMove = false;
}