/*
Methods for resizing the flash stage at runtime.

setFlashWidth(divid, newW)
divid: id of the div containing the flash movie.
newW: new width for flash movie

setFlashWidth(divid, newH)
divid: id of the div containing the flash movie.
newH: new height for flash movie

setFlashSize(divid, newW, newH)
divid: id of the div containing the flash movie.
newW: new width for flash movie
newH: new height for flash movie

canResizeFlash()
returns true if browser supports resizing flash, false if not.
*/

/**
 * Sett denne til størrelsen på forsiden av siten
 */
var intFlashContentHeight = 700;

function getCurrentWindowHeight() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function getFlashMovieObject( movieName ){
	if( window.document[movieName] ){
		return window.document[movieName];
	}
	if( navigator.appName.indexOf("Microsoft Internet")==-1 ){
		if( document.embeds && document.embeds[movieName] ){
			return document.embeds[movieName];
		}
	}else{
		return document.getElementyId(movieName);
	}
}

function sendHeightToFlash(divid){
	objFlash = getFlashMovieObject(divid);
	if (objFlash){
//		alert( 'sendHeightToFlash ('+parseInt( objFlashContent.style.height )+')' );
		objFlash.SetVariable( 'browserHeight', parseInt( objFlashContent.style.height ) );
	}
}

function setFlashContentHeight( intHeight ){
	intHeight = parseInt( intHeight )+5;
	if( intHeight!=intFlashContentHeight ){
		intFlashContentHeight = intHeight;
		setFlashHeight();
	}
}

function setFlashHeight(){
	intCurrentWinHeight = getCurrentWindowHeight();
	intFlashHeight = (intCurrentWinHeight>=intFlashContentHeight) ? intCurrentWinHeight : intFlashContentHeight;
	objFlashContent = document.getElementById( 'flashcontent' );
	if( objFlashContent ){
		if( objFlashContent.style.height != intFlashHeight+'px' ){
			objFlashContent.style.height = intFlashHeight+'px';
			sendHeightToFlash( 'theflash' );
		}else{
		}
	}
}

window.onresize = setFlashHeight;
