// Navigation Script Created by Melanie Wiora
// 05-Dec-2004
// (C) by Melanie Wiora


// List of filenames in this site
var AFilenames = new Array("news.htm",
			"natura.htm","natura_02.htm","natura_03.htm","natura_04.htm","natura_05.htm","natura_06.htm","natura_07.htm","natura_08.htm","natura_09.htm","natura_10.htm","natura_11.htm","natura_12.htm","natura_13.htm","natura_14.htm","natura_15.htm","natura_16.htm",
		"outside.htm","outside_02.htm","outside_03.htm","outside_04.htm","outside_05.htm","outside_06.htm","outside_07.htm","outside_08.htm","outside_09.htm","outside_10.htm","outside_11.htm","outside_12.htm","outside_13.htm","outside_14.htm","outside_15.htm","outside_16.htm",
           "outside2.htm","outside2_02.htm","outside2_03.htm","outside2_04.htm","outside2_05.htm","outside2_06.htm","outside2_07.htm","outside2_08.htm","outside2_09.htm","outside2_10.htm","outside2_11.htm","outside2_12.htm","outside2_13.htm","outside2_14.htm","outside2_15.htm","outside2_16.htm",
"outside3.htm","outside3_02.htm","outside3_03.htm","outside3_04.htm","outside3_05.htm","outside3_06.htm","outside3_07.htm",
		   "pers_reflect.htm","pers_reflect_02.htm","pers_reflect_03.htm","pers_reflect_04.htm","pers_reflect_05.htm","pers_reflect_06.htm","pers_reflect_07.htm","pers_reflect_08.htm","pers_reflect_09.htm","pers_reflect_10.htm","pers_reflect_11.htm","pers_reflect_12.htm","pers_reflect_13.htm","pers_reflect_14.htm","pers_reflect_15.htm","pers_reflect_16.htm",
           "eye1.htm","eye1_02.htm","eye1_03.htm","eye1_04.htm","eye1_05.htm","eye1_06.htm","eye1_07.htm",
		   "eye1_08.htm","eye1_09.htm","eye1_10.htm","eye1_11.htm","eye1_12.htm","eye1_13.htm","eye1_14.htm","eye1_15.htm","eye1_16.htm",
		   "eye2.htm","eye2_02.htm","eye2_03.htm","eye2_04.htm","eye2_05.htm","eye2_06.htm","eye2_07.htm","eye2_08.htm",
		   "eye3.htm","eye3_02.htm","eye3_03.htm","eye3_04.htm","eye3_05.htm","eye3_06.htm","eye3_07.htm","eye3_08.htm","eye3_09.htm","eye3_10.htm","eye3_11.htm","eye3_12.htm",
		   "eyevideo.htm","eyevideo_02.htm",
		   "present.htm","present_02.htm","present_03.htm","present_04.htm","present_05.htm","present_06.htm","present_07.htm","present_08.htm",
		   "present_09.htm","present_10.htm","present_11.htm","present_12.htm","present_13.htm","present_14.htm","present_15.htm","present_16.htm",
		   "bio.htm","solo.htm","group.htm","cat.htm","press.htm","text.htm","address.htm","newsletter.htm");
var AMenus = new Array("news",
		   "works","works","works","works","works","works","works","works",
		   "works","works","works","works","works","works","works","works",
		   "works","works","works","works","works","works","works","works",
		   "works","works","works","works","works","works","works","works",
           "works","works","works","works","works","works","works","works",
		   "works","works","works","works","works","works","works","works",
		   "works","works","works","works","works","works","works",
		   "works","works","works","works","works","works","works","works",
		   "works","works","works","works","works","works","works","works",
		   "works","works","works","works","works","works","works","works",
		   "works","works","works","works","works","works","works","works",
		   "works","works","works","works","works","works","works","works",
		   "works","works","works","works","works","works","works","works",
		   "works","works","works","works",
		   "works","works",
		   "works","works","works","works","works","works","works","works",
		   "works","works","works","works","works","works","works","works",
		   "bio","exhib","exhib","pub","pub","pub","contact","contact");
//var ASubmenus = new Array("none","none","none");

//preload images for Header Navigation
var preloadArray = new Array();
var preloadArrayLength = 0;
var pfad = "m/";  // Stores the relative or absolute image path

// Set default images for on and off
var MenuOffImage = "dot_1.gif";
var MenuOnImage = "dot_2.gif";

// Globals for active Menu
var this_menu="";    // Active Menue for this page
//var this_submenu=""; // Active SubMenue for this page
var current_menu="";    // Currently displayed menu
//var current_submenu=""; // Currently Displayed submenu

// Globals for browser independent object access
var genObj="";
var genStyle="";

// This is code from dreamweaver
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) 
  {
    if ((appName=="Netscape")&&(parseInt(appVersion)==4))
    {
      document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; 
    }
  }
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)
   location.reload();
}

MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}


function preloadImages() {
	if (document.images) {
		var imgName = preloadImages.arguments;
		for (var i=0; i<imgName.length; i++)
		{
	    preloadArray[preloadArrayLength] = new Image;
		  preloadArray[preloadArrayLength].src = pfad + imgName[i];
			preloadArrayLength++;
		}
	}
}

var reloaded=false;
// netscape reload fix
function MM_reloadPage()
{  //reloads the window if Nav4 resize
  with (navigator)
  {
    if ((appName=="Netscape")&&(parseInt(appVersion)==4) && (reloaded==false))
    {
      document.MM_pgW=window.innerWidth;
	  document.MM_pgH=window.innerHeight;
	  onresize=DoReload();
    }
  }
}
// End of dreamweaver code


function showobj(objname)
{
//  ret = prompt ("Enter object", "document");
  obj = eval(objname);
  var temp = "";
  for (x in obj)
    temp += x + ": " + obj[x] + "\n";
  alert (temp);
}

// Variables for browser check
var ie=(document.all);
var n = (document.layers);
var dom=(document.getElementById);

// Browser check
function init()
{
  var x;

  dom=(document.getElementById);
  ie=(document.all);
  n = (document.layers);
  mac=(navigator.userAgent.indexOf("Mac")!=-1);
  iemac=(ie && mac);
  if(ie)
  {
    genObj="document.all";
    genStyle=".style";
  }
  if(n)
  {
    genObj="document.layers";
    genStyle="";
  }
}

//change images at OnMouseOver/OnMouseOut
function changeImage(divName,imgName,imgSource)
{
  //alert ("Change image(name/source)=\n"+imgName+"\n"+imgSource);
  obj = createObj(divName);
  if (n)
  {
    document.layers[divName].document.images[imgName].src= pfad+imgSource;
  }
  else
  {
    document.images[imgName].src = pfad+imgSource;
  }
}


//Get an Object with respect to different browsers
function createObj(divName)
{
  var stand_obj;

  if (divName.length <= 0)
  {
    alert("Null Object with divName: "+divName);
    return 0;
  }

  if(dom)
  {
    stand_obj=document.getElementById(divName);
    //alert('Objname: '+divName);
    obj=stand_obj.style ;
  }
  else
  {
    obj=eval(genObj+"['"+divName+"']"+genStyle);
  }
  return obj;
}

// Show a layer by name
function show(divName)
{
  if (divName.length == 0)
    alert("Empty Div Name in show!");
  createObj(divName).visibility='visible';
}

// hide a layer by name
function hide(divName)
{
  if (divName.length == 0)
    alert("Empty Div Name in hide!");

  createObj(divName).visibility='hidden';
}


// Function to resolve from the page file name to the current menu
// returns the index of the current page in the page list
function FindPageNameIndex()
{
  var i=0;
  var pos,currentpath,filename;

  currentpath=window.location.pathname;
  //alert('Path: '+currentpath);
  // remove targets
  pos = currentpath.lastIndexOf("#");
  if (pos >= 1)
    currentpath = currentpath.substr(0,pos);
  // find last path separator and get name of current file
  pathsep = currentpath.lastIndexOf("/");
  // This is needed in case of local usage on M$-Win
  pathsep_dos = currentpath.lastIndexOf("\\");
  // Use the righter one
  if  (pathsep < pathsep_dos)
    pathsep = pathsep_dos;
    
  filename = currentpath.substr(pathsep+1,currentpath.length);
  //alert("Filename=\""+filename+"\"");

  // find the number of the page entry in the page list
  for (i=0 ; i<AFilenames.length ; i++)
  {
    if (AFilenames[i] == filename)
	  return i;
  }

  return -1;
}

// This is the main startup function
//set active menu on load usign the filename to find the menu and sub menu entry
function set_active()
{
  // do browser check and image preload
  init();

  // Get index of page in list
  pageIndex = FindPageNameIndex();
  // Resolve Page name and Title extension
  Name = AMenus[pageIndex];
  
  // Show overlay for menu entry
  show(Name+"1");

  // Save name of current menu selection
  this_menu = Name;
  //this_submenu = SubName;
  current_menu = Name;
}

// Hide current menue if it is not the active one on mouse out event
function HideMenu()
{
  // Check for current menue
  if(this_menu != current_menu)
  {
	// Menu has changed
	// Check if a different menue was displayed
	if (current_menu.length > 0)
	{
	  // Hide the menue with mouse over
	  hide(current_menu+"1");
	  hide(current_menu+"2");
    }
  }
  // Display active menu if availible
  if (this_menu.length > 0)
  {
    show(this_menu+"1");
	hide(this_menu+"2");
  }
	
  // Reset current menu and submenu
  current_menu = this_menu;
}

// Show menu on mouse over and hide active menue
function ShowMenu(Name,SubName)
{
  // Check for current menue
  if ((current_menu.length > 0) && (current_menu != Name))
  {
    // Hide the current menu
    hide(current_menu+"1");
    hide(current_menu+"2");
  }

  // Show the new active menu
  show(Name+"1");
  show(Name+"2");

  // Save name of current menu
  current_menu = Name ;
}


// Encrypt links to hide from stupid spammers
// this is a *very* *secret* encryption 8-)
function EncryptMe(input)
{
	var out="";
	var code=0;
	
	for (i=0 ; i<input.length ; i++)
	{
		code=input.charCodeAt(i);
		c=input.charAt(i);
		// IMplement rot13
		if ((c >= 'a') && (c <= 'z'))
		{
			code = (code - ('a').charCodeAt(0) + 13) % (('z').charCodeAt(0)-('a').charCodeAt(0)+1);
			code += ('a').charCodeAt(0);
		}
		else if ((c >= 'A' && c<= 'Z'))
		{
			code = (code - ('A').charCodeAt(0) + 13) % (('Z').charCodeAt(0)-('A').charCodeAt(0)+1);
			code += ('A').charCodeAt(0);
		}
		else if (c == '@')
		  code = ('!').charCodeAt(0)
		else if (c == '!')
		  code = ('@').charCodeAt(0)

	  out = out + unescape("%"+code.toString(16));
	} 
	// get the url
  window.location.href = out;
}



