var d = document;
var theBody;

function showStartLogo(){

	divCode = '<div onClick="hideStartLogo();" style="cursor:hand;cursor:pointer;position:absolute;top:0px;left:0px;width:100%;height:100%;background-color:white;"><table width=100% height=100%><tr><td align=center><img src="/images/bigLogo.gif"><br><br><br><br></td></tr></table></div>';

	theBody = document.body.innerHTML;

	document.body.innerHTML = divCode;

}

function hideStartLogo(){
	document.body.innerHTML = theBody;
}

function markNewSubSub(nbr) {
	alert('markNewSubSub has been called. That is not correct! Contact Micke and inform him of this.');
}

function jumpToMovie(frame) {
		theSrc = '/images/controll.swf?frame='+navSection+'.'+navSubSection+'.'+frame;
		
		
		divhtml = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
		divhtml += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"';
		divhtml += 'WIDTH="512" HEIGHT="330" id="flashen">';
		divhtml += '<PARAM NAME=movie VALUE="'+theSrc+'"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF><PARAM NAME="LOOP" VALUE="false">';
		divhtml += '<EMBED src="'+theSrc+'" quality=high bgcolor=#FFFFFF  WIDTH="512" HEIGHT="330" LOOP="false" NAME="flashen" swLiveConnect="true" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>';
		divhtml += '</OBJECT> ';
		
		document.getElementById('flashmovie').innerHTML= divhtml;
}

function jumpToFrame(frame) {
	jumpToMovie(frame);
}

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 // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

var IE = document.all?true:false;

if (!IE) document.captureEvents(Event.MOUSEMOVE);

document.onmousemove = getMouseXY;

var mouseX = 0;
var mouseY = 0;

function getMouseXY(e) {
	if (IE) {
		mouseX = event.clientX + document.body.scrollLeft;
		mouseY = event.clientY + document.body.scrollTop;
	}
	else {
		mouseX = e.pageX;
		mouseY = e.pageY;
	}
	if (mouseX < 0){mouseX = 0;}
	if (mouseY < 0){mouseY = 0;}
	return true;
}

function showEvalBox(){
	hideEvalBox();
	theDiv = document.createElement('iframe');
	theDiv.setAttribute('id','evalBox');
	theDiv.setAttribute('frameborder','0');
	theDiv.setAttribute('src','/eval/?section=/'+navSectionName+'/'+navSubSectionName+'/');
	theDiv.style.position = 'absolute';
	theDiv.style.top = '620px';
	theDiv.style.zIndex = '500';
	theDiv.style.left = '300px';
	theDiv.style.width = '550px';
	theDiv.style.height = '160px';
	theDiv.style.backgroundColor = '#efefef';
	theDiv.style.border = '3px black solid';
	theDiv.style.padding = '0px';
	document.body.appendChild(theDiv);
}

function hideEvalBox(){
	if(document.getElementById('evalBox')){
		document.body.removeChild(document.getElementById('evalBox'));
	}
}

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
function flashen_DoFSCommand(command, args){
  var flashenObj = InternetExplorer ? flashen : document.flashen;
  eval(args);
}
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
  document.write('<SCRIPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('Sub flashen_FSCommand(ByVal command, ByVal args)\n');
  document.write(' call flashen_DoFSCommand(command, args)\n');
  document.write('end sub\n');
  document.write('</SCRIPT\> \n');
} 

function gotoURL(URL) {
	
	document.location = URL;
	
}

function showHideID(id) {

	element = document.getElementById(id);
	
	if(element.style.display == 'inline') {

		element.style.display = 'none';
		
	}
	else {
		
		element.style.display = 'inline';
		
	}

}

function hideID(id) {

	element = document.getElementById(id);
	
	element.style.display = 'none';

}

function showID(id) {

	element = document.getElementById(id);
	
	element.style.display = 'inline';

}

function joinNodeLists(){

  if (!arguments.length) {
    return null;
  }
  var newList = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var list = arguments[i];
    for (var j = 0; j < list.length; j++) {
    // Don't use push() for IE 5 // compatibility
    newList[newList.length] = list[j];
    }
  }
  return newList;
}



/**
* Function : dump()
* Arguments: The data - array,hash(associative array),object
*    The level - OPTIONAL
* Returns  : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.
*/
function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects
 for(var item in arr) {
  var value = arr[item];
 
  if(typeof(value) == 'object') { //If it is an array,
   dumped_text += level_padding + "'" + item + "' ...\n";
   dumped_text += dump(value,level+1);
  } else {
   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
  }
 }
} else { //Stings/Chars/Numbers etc.
 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
}
