initCalled=false;

if (! initCalled) {init()}

function init () {
	zindexStart = 1000;  
	initCalled=true;
}
     
function setzindex(element, effect) {
	if (effect.direction == Spry.forwards) {
		element.style.zIndex=zindexStart;
		//seems that IE needs a seperate solution
		if(/MSIE/.test(navigator.userAgent) && /Windows NT/.test(navigator.userAgent)) {
			Spry.Effect.setStyleProp(	element.parentNode, 'zIndex', zindexStart);
			element.parentNode.style.zIndex = zindexStart;
		}

	}
	zindexStart++;
}

function resetzindex(element, effect) {
	if (effect.direction == Spry.backwards) {
		element.style.zIndex=1;
		if(/MSIE/.test(navigator.userAgent) && /Windows NT/.test(navigator.userAgent))  {
			Spry.Effect.setStyleProp(	element.parentNode, 'zIndex', 1);
		}
	}
}

function toggleThumb(targetElement) {
	Spry.Effect.GrowShrink(targetElement, {duration: 150, from: '100%', to: '130%', toggle: true, setup:setzindex, finish:resetzindex});
}

function toggleMap(targetElement) {
	Spry.Effect.GrowShrink(targetElement, {duration: 250, from: '100%', to: '350%', toggle: true, setup:setzindex, finish:resetzindex});
}


function SimpleSwap(el,which){
  el.src=el.getAttribute(which || "origsrc");
}

function SimpleSwapSetup(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
    var oversrc = x[i].getAttribute("oversrc");
    if (!oversrc) continue;
      
    // preload image
    // comment the next two lines to disable image pre-loading
    x[i].oversrc_img = new Image();
    x[i].oversrc_img.src=oversrc;
    // set event handlers
    x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
    x[i].onmouseout = new Function("SimpleSwap(this);");
    // save original src
    x[i].setAttribute("origsrc",x[i].src);
  }
}

var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};
window.onload = function(){PreSimpleSwapOnload(); SimpleSwapSetup();}

