/* Author: Josef Buchinger
 * Version: 1.0
 * Date: Aug 2004
*/

/* Each left column link (that links to a different page) has an id following naming convention:
 *lcl-[parent-integer-number]-[child-integer-position-from-parent]....
 *NOTE:	Do not change this numbers even if you change the link position.
 *		The lcl number only has to be unique but not ordered
 *
 *lcl-0-0	->	Home
 *lcl-1-0	->	Africa 					afr
 *lcl-1-4 ->			Habari
 *lcl-1-1	->			Reports
 *lcl-1-2	->			Pictures
 *lcl-1-3	->			Glossary
 *lcl-1-4	->			FAQ
 *lcl-2-0	->	Duties					dut
 *lcl-2-1	->			Alt Service
 *lcl-2-2	->			Solar Energy
 *lcl-2-3	->			Scouting
 *lcl-3-0	->	Pictures			pic
 *lcl-3-1	->			Africa			
 *lcl-3-2	->			General
 *lcl-4-0	->	Words					wrd
 *lcl-5-0	->	c_vitae				cvi
 *lcl-5-1	->			german
 *lcl-5-2	->			english
 *lcl-6-0	->	contact				con
 *lcl-7-0	->	guests				gues
 *lcl-8-0	->	favourites		fav
 *lcl-11-0	->	usa				usa´
 *lcl-11-1	->			news
 *lcl-11-2	->	´		pictures
 *lcl-11-3	->			reports
 *lcl-11-3	->			glossary	
 *lcl-12-0	->	off
 *lcl-10-0	->	test

archiviert *lcl-9-0	->	search
*/

/* Browser detection script borrowed from Powell Schneider's Javascript: The Complete Refference */
var ns4 = false; // true if the browser supports layers
var ie4 = false; // true if the browser supports document.all
var ie5plus = false; // true if browser is IE 5+
var DOM = false; // true if ns6 or IE 6

function detectBrowser(){
	if (document.layers){
		ns4 = true;
	}
	else if (document.all){
		ie4 = true;
		if (navigator.userAgent.indexOf("MSIE 4") != -1){
			ie5plus = false;
		}
		else ie5plus = true;
	}
	else if (document.getElementById){
		DOM = true;
	}
}


/* Objects to expand or collapse table */
function Collapsible(id, imageName){
	
	
	this.active = false; /* Boolean to strore if table is expanded(active) or collapsed */
	this.image = document.images[imageName];
	
	
	this.mouseClick = function (){
		if (!this.active){
			
			if(ie4 || ie5plus ){
				this.image.src='images/bullet-minus.gif';
				document.all(id).style.display='block';
				this.active=true;
			}
			
			else if(DOM){
				this.image.src='images/bullet-minus.gif';
				document.getElementById(id).style.display='block';
				this.active=true;
			}
		}
		else if(this.active){
			if(ie4 || ie5plus ){
				this.image.src='images/bullet-plus.gif';
				document.all(id).style.display='none';
				this.active=false;
			}
			else if(DOM){
				this.image.src='images/bullet-plus.gif';
				document.getElementById(id).style.display='none';
				this.active=false;
			}
			return 1;
		}
	}

	this.mouseOver = function (){
		this.image.src='images/bullet-plus.gif';
		return 1;
	}

	this.mouseOut = function (){
		if(!this.active){
			this.image.src='images/bullet-plus.gif'
		}
		else{
			this.image.src='images/bullet-minus.gif';
		}
		return 1;
	}
									
}

/* x -> stores state whether a selection is on plus or minus state
 * afr -> Africa
 * pas -> Duties
 * nwk -> Pictures
 * cvi -> c vitae
*/
var afr = null;
var dut = null;
var pic = null;
var cvi = null;
var usa = null;

function createObjects(){
	afr = new Collapsible("afr", "afrImage");
	dut = new Collapsible("dut", "dutImage");
	pic = new Collapsible("pic", "picImage");
	cvi = new Collapsible("cvi", "cviImage");
	usa = new Collapsible("usa", "usaImage");
	returnState();
	return 1;
}

/* Function to save the state of the collapsible table */
function saveState(){
	var state = new Array(afr.active, dut.active, pic.active, cvi.active, usa.active);
	document.cookie = "state="+state+"; path=/";
//	alert("Saving state: " + state);
	return 1;
}

function returnState(){
	var x =0;
	var objects = new Array("afr", "dut", "pic", "cvi", "usa");
	if(document.cookie){
		var state = document.cookie;
		var trash = state.split("=");
		state = trash[1].split(",");
		
		
		for(var object in objects){
			if(state[x]=="true"){
				eval(objects[object]).mouseClick();
			}
			++x;
		}
	}
	return 1;
}

function openDoc(pulldown){
	var location = 	pulldown[pulldown.selectedIndex].value;
	if(location!=""){
		self.location = location;
	}
}

function highlight(linkId){
	if(ie4 || ie5plus ){
		document.all(linkId).style.color='black';
	}
	else if(DOM){
		document.getElementById(linkId).style.color='black';
	}	
}
function expand(object){
	if(!object.active){
		object.mouseClick();
	}
}
/* randompic from scout.at, modified by Josef Buchinger */
/* wird in head.html ausgeführt */

function randompic ()
{
 var i;
 i = Math.round( (30) * Math.random() );
 return "<img name=zpic src=\"pic/hp-rnd/hp" + i + "\.jpg\" height=120px width=810px>";
 }
function _onpicclick()
{
  var i;
  i = Math.round( (30) * Math.random() );
  document.zpic.src="pic/hp-rnd/hp" + i + ".jpg" ;
}
function hhautoload()
{
	window.setInterval("_onpicclick()",4500); 
}
/* ENDE randompic */
detectBrowser();

