var showdetcount = 0;
var currentScale = "mid";
var shrinkFactor = 0.75;
var growFactor = 1/shrinkFactor;

function showdetail() {
	detaildiv = document.getElementById("showdet");
	if ( showdetcount == 0 ) {
		detaildiv.style.visibility = "visible";
		showdetcount = 1;
	}
	else {
		detaildiv.style.visibility = "hidden";
		showdetcount = 0;			
	}
	return void(0);
}

function hidedetail() {
	detaildiv = document.getElementById("showdet");
	detaildiv.style.visibility = "hidden";
	showdetcount = 0;
	return void(0);
}


function scale( ref, factor ) {
	ref.width = ref.width * factor;
	ref.height = ref.height * factor;
}


function goodToShrink() {
	return ( currentScale == "mid" || currentScale == "big" );
}


function goodToGrow() {
	return ( currentScale == "mid" || currentScale == "small" );
}


function shrink() {
	if (!goodToShrink()) return;
	art = document.getElementById("_art");
	det = document.getElementById("_det");
	if (art) { scale(art, shrinkFactor); }
	if (det) { 
		scale(det, shrinkFactor); 
		showdet = document.getElementById("showdet");
		if (showdet) { 
			showdet.style.height = Math.round(showdet.style.height * growFactor); 
		}
	}
	if ( currentScale == "mid" ) { currentScale = "small"; } 
	else { currentScale = "mid"; }
	saveNavInfo();
}


function grow() {
	if (!goodToGrow()) return;
	art = document.getElementById("_art");
	det = document.getElementById("_det");
	if (art) { scale(art, growFactor); }
	if (det) { 
		scale(det, growFactor); 
		showdet = document.getElementById("showdet");
		if (showdet) { 
			showdet.style.height = Math.round(showdet.style.height * growFactor); 
		}
	}
	if ( currentScale == "mid" ) { currentScale = "big"; }
	else { currentScale = "mid"; }
	saveNavInfo();
}


function saveNavInfo() {
	var prev = document.getElementById("_prev");
	var next = document.getElementById("_next");
	if (prev) { setQueryVar( prev, "sc", currentScale ); }
	if (next) { setQueryVar( next, "sc", currentScale ); }
}


function setQueryVar( ref, key, value ) {
	if ( ref.href.indexOf(key + "=") != -1 ) {
		// "etwas?bu=well&sc=-5.7".replace(/sc=([a-zA-Z0-9\.-]+)/, "sc=" + "zut")
		var rex = new RegExp( key + "=([a-zA-Z0-9\.-]+)" );
		ref.href = ref.href.replace(rex, key + "=" + value);
		bugtxt = " replace " + key + "=" + value;
	}
	else {
		if ( ref.href.indexOf("?") != -1 ) {
			ref.href = ref.href + "&"+key+"=" + value;
			bugtxt = " append var " + key + "=" + value;
		}
		else {
			ref.href = ref.href + "?"+key+"=" + value;	
			bugtxt = " append query " + key + "=" + value;
		}
	}
	/*
	if (document.getElementById("_sc")) {
		document.getElementById("_sc").innerHTML = bugtxt;
	}
	*/
}


function init() {
	 if (FORM_DATA["sc"]) {
	 	var sc = (FORM_DATA["sc"]);
	 	if (sc == "small") shrink();
	 	if (sc == "big") grow();
	 	// alert(currentScale);
	 }
}


/*
Webmonkey GET Parsing Module
Language: JavaScript 1.0

The parsing of GET queries is fundamental
to the basic functionality of HTTP/1.0.
This module parses GET with JavaScript 1.0.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Patrick Corcoran
Author Email: patrick@taylor.org
*/

function createRequestObject() {
  
  FORM_DATA = new Object();
    // The Object ("Array") where our data will be stored.
  
  separator = ',';
    // The token used to separate data from multi-select inputs
  
  query = '' + this.location;
    // Get the current URL so we can parse out the data.
    // Adding a null-string '' forces an implicit type cast
    // from property to string, for NS2 compatibility.
    
  query = query.substring((query.indexOf('?')) + 1);
    // Keep everything after the question mark '?'.
  
  if (query.length < 1) { return false; }  // Perhaps we got some bad data?
  
  keypairs = new Object();
  numKP = 1;
    // Local vars used to store and keep track of name/value pairs
    // as we parse them back into a usable form.
    
  while (query.indexOf('&') > -1) {
    keypairs[numKP] = query.substring(0,query.indexOf('&'));
    query = query.substring((query.indexOf('&')) + 1);
    numKP++;
      // Split the query string at each '&', storing the left-hand side
      // of the split in a new keypairs[] holder, and chopping the query
      // so that it gets the value of the right-hand string.
  }

  keypairs[numKP] = query;
    // Store what's left in the query string as the final keypairs[] data.
  
  for (i in keypairs) {
    keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));
      // Left of '=' is name.
    keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
      // Right of '=' is value.
    while (keyValue.indexOf('+') > -1) {
      keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
        // Replace each '+' in data string with a space.
    }
    
    keyValue = unescape(keyValue);
      // Unescape non-alphanumerics
      
    if (FORM_DATA[keyName]) {
      FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;
        // Object already exists, it is probably a multi-select input,
        // and we need to generate a separator-delimited string
        // by appending to what we already have stored.
    } else {
      FORM_DATA[keyName] = keyValue;
        // Normal case: name gets value.
    }
  }

  return FORM_DATA;
}

FORM_DATA = createRequestObject();
  // This is the array/object containing the GET data.
  // Retrieve information with 'FORM_DATA [ key ] = value'.



