/**********************************************************************************   
FoldoutMenu 
*   Copyright (C) 2001 Thomas Brattli
*   This script was released at DHTMLCentral.com
*********************************************************************************/

function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=new lib_bwcheck()

/**********************************************************************************   
Style Sheets
*   Styles_ie.css for IE and newer netscape version. For old netscape 4.x styles_ns.css
*********************************************************************************/


function d(txt){
	document.write(txt);
}

if(bw.ie) {
    d('<link rel="STYLESHEET" type="text/css" href="styles_ie.css">')
} else if(bw.dom) {
    d('<link rel="STYLESHEET" type="text/css" href="styles_ie.css">')
} else {
   d('<link rel="STYLESHEET" type="text/css" href="styles_ns.css">')
}

/*** variables you can configure ***/

FoldNumber = 6					//How many toplinks do you have?
var stayFolded = false			//Stay open when you click a new toplink?
foldImg = 0						//Do you want images (if not set to 0 and remove the images from the body)?
mainOffsetY = 0					//Vertical space adjustment between the main items, in pixels.

//This is the default image.
//Remember to change the actual images in the page as well, but remember to keep the name of the image.
var unImg=new Image();
unImg.src='foldoutmenu_arrow.gif'

var exImg=new Image();					//Making an image variable...
exImg.src='foldoutmenu_arrow_open.gif'	//...this is the source of the image that it changes to when the menu expands.

// NOTE: if you change the position of divCont from absolute to relative, you can put the foldoutmenu in a table.
// HOWEVER it will no longer work in netscape 4. If you wish to support netscape 4, you have to use absolute positioning.

/*** There should be no need to change anything beyond this. ***/

// A unit of measure that will be added when setting the position of a layer.
var px = bw.ns4||window.opera?"":"px";

if(navigator.userAgent.indexOf('Opera')>-1 && document.getElementById){ //Opera 5 resize fix.
	scrX= innerWidth; scrY= innerHeight;
	document.onmousemove= function(){
		if(scrX<innerWidth-10 || scrY<innerHeight-10 || scrX>innerWidth+10 || scrY>innerHeight+10){
			scrX = innerWidth;
			scrY = innerHeight;
			initFoldout();
		}
	};
}

//object constructor...
function makeMenu(obj,nest){
	nest= (!nest)?"":'document.'+nest+'.';
	this.el= bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):document.getElementById(obj);	
   	this.css= bw.ns4?this.el:this.el.style;
	this.ref= bw.ns4?this.el.document:document;		
	this.x= (bw.ns4||bw.opera5)?this.css.left:this.el.offsetLeft;
	this.y= (bw.ns4||bw.opera5)?this.css.top:this.el.offsetTop;
	this.h= (bw.ie||bw.ns6)?this.el.offsetHeight:bw.ns4?this.ref.height:bw.opera5?this.css.pixelHeight:0;
    this.vis= b_vis;
	this.hideIt= b_hideIt;
    this.showIt= b_showIt;
    this.moveIt= b_moveIt;
	return this
}
//object methods...
function b_showIt(){this.css.visibility='visible'}
function b_hideIt(){this.css.visibility='hidden'}
function b_vis(){if(this.css.visibility=='hidden' || this.css.visibility=='HIDDEN' || this.css.visibility=='hide') return true;}
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x+px; this.css.top=this.y+px}

/************************************************************************************
This is the function that changes the sub menus to folded or unfolded state.
************************************************************************************/
function menu(num){
	if(bw.bw){
		if (!stayFolded){
			for (var i=0; i<oSub.length; i++){
				if (i!=num){
					oSub[i].hideIt()
					if (foldImg)oTop[i].ref["imgA"+i].src = unImg.src
				}
			}
			for(var i=5; i>=0; i--){
				if(i==5) oTop[i].moveIt(0,140)
				else oTop[i].moveIt(0,oTop[i+1].y+oTop[i].h)
			}
		}
		if (oSub[num].vis()){
			oSub[num].showIt()
			if (foldImg)oTop[num].ref["imgA"+num].src = exImg.src
		}else{
			oSub[num].hideIt()
			if(foldImg)oTop[num].ref["imgA"+num].src = unImg.src
		}
		for(var i=5; i>=0; i--){
		if(i==5) {
			if (!oSub[i].vis()) { 
				oTop[i].moveIt(0,140)
			} else {
				oTop[i].moveIt(0,oTop[i].y+oSub[i].h)
			}
		} else {
			if (!oSub[i].vis()) {
				oTop[i].moveIt(0,oTop[i+1].y-oTop[i].h-oSub[i].h) 
			} else {
				oTop[i].moveIt(0,oTop[i+1].y-oTop[i].h)
			}
		}
			
		}
	}
}

/*********************************************************************
The init function... there should be no need to change anything here.
*********************************************************************/
function initFoldout(){
	//Fixing the browsercheck for opera... this can be removed if the browsercheck has been updated!!
	bw.opera5 = (navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?true:false
	if (bw.opera5) bw.ns6 = 0

	oTop = new Array()
	oSub = new Array()
	//Making the objects and hiding the subs...
	for (var i=0; i<FoldNumber; i++){
		oTop[i] = new makeMenu('divTop'+i,'divCont')
		oSub[i] = new makeMenu('divSub'+i,'divCont.document.divTop'+i)
		oSub[i].hideIt()
	}
	
	//Positioning the top objects...
	oTop[0].moveIt(0,50)
	for (var i=1; i<oTop.length; i++){
		oTop[i].moveIt(0, oTop[i-1].y+oTop[i-1].h+mainOffsetY)
	}
	
	//Making the containing menu object and showing it...
	oCont = new makeMenu('divCont')
	oCont.showIt()
}

// If the browser is ok, the script is started onload...
if(bw.bw) onload = initFoldout;




/**********************************************************************************   
Fast pictures flash check. If no flash jpg with link to macromedia download page is shown.
*********************************************************************************/

var fastpics='<a href=\"http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&Lang=English&P5_Language=English\" target=\"_blank\"><img src=\"pics/malli_fast_pictures.jpg\" width=\"579\" height=\"382\" border=\"0\"></a><br>';

var requiredVersion = 5;   // Version the user needs to view site (max 6, min 2)

var flash2Installed = false;    // boolean. true if flash 2 is installed
var flash3Installed = false;    // boolean. true if flash 3 is installed
var flash4Installed = false;    // boolean. true if flash 4 is installed
var flash5Installed = false;    // boolean. true if flash 5 is installed
var flash6Installed = false;    // boolean. true if flash 6 is installed
var maxVersion = 6;             // highest version we can actually detect
var actualVersion = 0;          // version the user really has
var hasRightVersion = false;    // boolean. true if it's safe to embed the flash movie in the page
var jsVersion = 1.0;            // the version of javascript supported

function detectFlash() {  

  if (navigator.plugins) {

    if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {

      var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;

      var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));

      flash2Installed = flashVersion == 2;    
      flash3Installed = flashVersion == 3;
      flash4Installed = flashVersion == 4;
      flash5Installed = flashVersion == 5;
      flash6Installed = flashVersion >= 6;
    }
  }

var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if we're on windows

jsVersion = 1.1;

if(isIE && isWin){
  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
  document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}
  
  
  for (var i = 2; i <= maxVersion; i++) {  
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }

  if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 3;  

  if (actualVersion >= requiredVersion) {

        //fast pictures
        fastpics = '<OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0 WIDTH=579 HEIGHT=382 id=kolmio01><PARAM NAME=movie VALUE=flash/fast_pictures.swf><PARAM NAME=menu VALUE=false><PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF><EMBED src=flash/fast_pictures.swf menu=false quality=high bgcolor=#FFFFFF  WIDTH=579 HEIGHT=382 NAME=kolmio01 TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/go/getflashplayer></EMBED></OBJECT>';

    hasRightVersion = true;                
  } 
}

detectFlash();  // call our detector now that it's safely loaded.  

