<!--//--><![CDATA[//><!--

/* Get URL parameters */
function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if ( aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
}

function IsValidEmailAddress(mailaddress){
	var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,4}$/;
	return email.test(mailaddress);
}

/* Set active top menu */
function topmenu(newClass) {
	if (getURLParam("tm")){
		topMenuID=document.getElementById("tm" + getURLParam("tm"));
		topMenuID.className=newClass;
		}
	}

/* Slideshow using prototype and scriptaculous */
var delay = 6000;
var duration = 1.5; // fade/appear time in second

function Slideshow(slideshow) {
  this.slides = [];
  var nl = $(slideshow).getElementsByTagName('div');
  for (var i = 0; i < nl.length; i++) {
    if (Element.hasClassName(nl[i], 'slide')) {
      this.slides.push(nl[i]);
    }
  }
  this.delay = delay;
  this.current = 0;

  for (var i = 0; i < this.slides.length; i++) {
    this.slides[i].style.zIndex = this.slides.length - i;
  }

  Element.show(slideshow);
  setTimeout((function(){this.next();}).bind(this), this.delay);
}

Slideshow.prototype = {
  next: function() {
    for (var i = 0; i < this.slides.length; i++) {
      var slide = this.slides[(this.current + i) % this.slides.length];
      slide.style.zIndex = this.slides.length - i;
    }

    Effect.Fade(this.slides[this.current], {
	  duration: duration,
      afterFinish: function(effect) {
        effect.element.style.zIndex = 0;
        Element.show(effect.element);
        Element.setOpacity(effect.element, 1);
      }
    });
    
    this.current = (this.current + 1) % this.slides.length;
    setTimeout((function(){this.next();}).bind(this), this.delay + 850);
  }
}
/* Start commands when document is loaded */
window.onload=function(){
	//new Slideshow('slideshow');
	//topmenu('active');
	//document.execCommand("BackgroundImageCache", false, true); /* Prevent background-images to flicker */
}

function XBrowserAddHandler(target,eventName,handlerName)
{
    if ( target.addEventListener )
      target.addEventListener(eventName, handlerName, false);
    else if ( target.attachEvent )
      target.attachEvent("on" + eventName, handlerName);
    else
      target["on" + eventName] = handlerName;
}



//--><!]]>


