/**
 * Equal Heights Plugin
 * Equalize the heights of elements. Great for columns or any elements
 * that need to be the same size (floats, etc).
 * 
 * Version 1.0
 * Updated 12/10/2008
 *
 * Copyright (c) 2008 Rob Glazebrook (cssnewbie.com) 
 *
 * Usage: $(object).equalHeights([minHeight], [maxHeight]);
 * 
 * Example 1: $(".cols").equalHeights(); Sets all columns to the same height.
 * Example 2: $(".cols").equalHeights(400); Sets all cols to at least 400px tall.
 * Example 3: $(".cols").equalHeights(100,300); Cols are at least 100 but no more
 * than 300 pixels tall. Elements with too much content will gain a scrollbar.
 * Oder falls ID statt Class: $(“#div1, #div2″).equalHeights();
 * 
 */

(function($) {
	$.fn.equalHeights = function(minHeight, maxHeight) {
		var tallest = (minHeight) ? minHeight : 0;
		this.each(function() {
			if($(this).height() > tallest) {
				tallest = $(this).height();
			}
		});
		if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
		return this.each(function() {
			$(this).height(tallest).css("overflow","visible");
		});
	}
})(jQuery);



// URL Parameter auslesen und Stage-Bild ändern

/* Copyright (c) 2006 Mathias Bank (http://www.mathias-bank.de)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * 
 * Thanks to Hinnerk Ruemenapf - http://hinnerk.ruemenapf.de/ for bug reporting and fixing.
 */
jQuery.extend({
/**
* Returns get parameters.
*
* If the desired param does not exist, null will be returned
*
* @example value = $.getURLParam("paramName");


This plugin can be used to get the URL parameters. You have to specify, which parameter you want. If the parameter does not exist, you will get “null”.

 var param1 = $.getURLParam("userID");

Even testing, if a specific parameter exists, is easy:

if ($.getURLParam("userID")==null) {
  alert("There is no userID");
}

*/ 

getURLParam: function(strParamName){
	  var strReturn = "";
	  var strHref = window.location.href;
	  var bFound=false;
	  
	  var cmpstring = strParamName + "=";
	  var cmplen = cmpstring.length;

	  if ( strHref.indexOf("?") > -1 ){
	    var strQueryString = strHref.substr(strHref.indexOf("?")+1);
	    var aQueryString = strQueryString.split("&");
	    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
	      if (aQueryString[iParam].substr(0,cmplen)==cmpstring){
	        var aParam = aQueryString[iParam].split("=");
	        strReturn = aParam[1];
	        bFound=true;
	        break;
	      }
	      
	    }
	  }
	  if (bFound==false) return null;
	  return strReturn;
	}
});

// Dazugehörige Funktion für Bildwechsel auf Stage

	// Stage IMG-Tag ersetzen
	var currentPage = $.getURLParam("link");
	function StageImage() {
		var stage = document.getElementById ("stage");
		stage.innerHTML = "<img src='img/image_0" + currentPage + ".jpg' width='940px' height='250px' border='0px' />";
	// für Index Seite ohne Parameter
		if ($.getURLParam("link")==null) {
  			var stage00 = document.getElementById ("stage");
			stage00.innerHTML = "<img src='img/image_00.jpg' width='940px' height='250px' border='0px' />";
		}
	// Menüpunkt auf Startseite aktivieren
		if ($.getURLParam("link")==null) {
			var menu = document.getElementById("startseite");
			menu.className = "link_on";
		}
}


// FadeIn gekoppelt mit effects.js

//create onDomReady Event
window.onDomReady = initReady;
// Initialize event dpending on browser
function initReady(fn) {
	//W3C-compliant browser
	if(document.addEventListener) {
    document.addEventListener("DOMContentLoaded", fn, false);
  }
	//IE
	else {
    document.onreadystatechange = function(){readyState(fn)}
  }
}
//IE execute function
function readyState(func) {
	// DOM is ready
	if(document.readyState == "interactive" || document.readyState == "complete")
	{
		func();
	}
}
//execute as soon as DOM is loaded
window.onDomReady(MM_effectAppearFade);

//do when DOM is ready
function MM_effectAppearFade()
{
Spry.Effect.DoFade('fade', {duration: 1500, from: 0, to: 100, toggle: false});
}
