

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;


function preloadMenuImages() {
	if (document.images) {
		//menu_objekt_on = newImage("images/menu_objekt_on.gif");
		preloadFlag = true;
	}
}

var screen_width = window.screen.availWidth;
var screen_height = window.screen.availHeight;

function initWin(){
        window.moveTo(0,0);
        window.resizeTo(screen_width,screen_height);
       //setTimeout('updateView();',500);
}




//Stage Centering
////////////////////////////////////////////////////////////////////////////////////////////
function updateView() {					

	 if (document.getElementById) {

		var bg = document.getElementById("bg");
		var stage = document.getElementById("stage");
		var homeContent = document.getElementById("homeContent");

		var bg_origWidth = 2000;
		var stage_origWidth = 780;
		var homeContent_origWidth = 780;
		
		
		if(window.innerWidth){
			var scrWidth = window.innerWidth;
			var scrHeight = window.innerHeight;
		}else{
			var scrWidth = document.body.offsetWidth;
			var scrHeight = document.body.offsetHeight;
		}

		if(scrWidth>stage_origWidth){

			var bgLeft = ( scrWidth - bg_origWidth ) / 2

			bg.style.left = bgLeft;
			bg.style.width = scrWidth - bgLeft;


			stage.style.left = ( scrWidth - stage_origWidth ) / 2;
			homeContent.style.left = ( scrWidth - homeContent_origWidth ) / 2;

		}else{

			stage.style.left = 0;
			homeContent.style.left = 0;

			var bgLeft = ( stage_origWidth - bg_origWidth ) / 2

			bg.style.left = bgLeft;


		}

		homeContent.style.visibility = 'visible';
		stage.style.visibility = 'visible';
		
	
		
	
	}
}


//Side bar navigation resizing (called from sidebar swf)
////////////////////////////////////////////////////////////////////////////////////////////
function setFlashSize(_divName,datoX,datoY) {
	
	if(document.all && !document.getElementById) {
		document.all[_divName].style.pixelWidth = datoX;
		document.all[_divName].style.pixelHeight = datoY;
	}else{
		document.getElementById(_divName).style.width = datoX;
		document.getElementById(_divName).style.height = datoY;
	}
}




//LogIn
////////////////////////////////////////////////////////////////////////////////////////////
function initLoginScreen(){
	var wX = screen_width/2-200;
	var wY = screen_height/2-150;
	
        window.moveTo(wX,wY);
        window.resizeTo(400,300);
}




//LaunchWin  for popups within flash menus  > can be set in xml/mainNav.xml  if popup value=true
///////////////////////////////////////////////////////////////////////////////////////////////

function launchWin(winurl)
{
        //This launches a new window and then
        //focuses it if window.focus() is supported.

	var newwin;
	
	winfeatures = "menubar=yes, toolbar=yes, addressbar=yes, resizable=yes, location=yes, titlebar=yes, status=yes, scrollbars=auto";
	winname = "_new";


        newwin = window.open(winurl,winname,winfeatures);

        if(javascript_version > 1.0)
        {
                //delay a bit here because IE4 encounters errors
                //when trying to focus a recently opened window
                setTimeout('newwin.focus();',350);
        }
}




//LAYERS
//////////////////////////////////////////////////////////////////////////////////////////////////
function turnOnLayer(layerName){
  	if (document.getElementById) {
	  	var ln = document.getElementById(layerName);
	  	ln.style.visibility = 'visible';
  	}else{
  	}
}

function turnOffLayer(layerName){
  	if (document.getElementById) {
	  	var ln = document.getElementById(layerName);
	  	ln.style.visibility = 'collapse';
  	}else{
  	}
}

