var FOLDERS={domainRoot:"http://gregorschatz.com/",images:"http://gregorschatz.com/template/images",css:"http://gregorschatz.com/template/styles",js:"http://gregorschatz.com/system/javascript"};
var ie=(document.all)?1:0;function addEvent(obj,type,fn)
{if(obj.addEventListener){obj.addEventListener(type,fn,false);EventCache.add(obj,type,fn);}else if(obj.attachEvent){obj['e'+type+fn]=fn;obj[type+fn]=function(){obj['e'+type+fn](window.event);}
obj.attachEvent('on'+type,obj[type+fn]);EventCache.add(obj,type,fn);}else{obj['on'+type]=obj['e'+type+fn];}};function removeEvent(obj,type,fn)
{EventCache.remove(obj,type,fn);};var EventCache=function()
{var listEvents=[];return{listEvents:listEvents,add:function(node,sEventName,fHandler)
{listEvents.push(arguments);},remove:function(node,sEventName,fHandler)
{var i,item;for(i=listEvents.length-1;i>=0;i=i-1){if(node==listEvents[i][0]&&sEventName==listEvents[i][1]&&fHandler==listEvents[i][2]){item=listEvents[i];if(item[0].removeEventListener){item[0].removeEventListener(item[1],item[2],item[3]);}
if(item[1].substring(0,2)!='on'){item[1]='on'+item[1];}
if(item[0].detachEvent){item[0].detachEvent(item[1],item[0][sEventName+fHandler]);}
item[0][item[1]]=null;}}},flush:function()
{var i,item,eventtype;for(i=listEvents.length-1;i>=0;i=i-1){item=listEvents[i];if(item[0].removeEventListener){item[0].removeEventListener(item[1],item[2],item[3]);}
eventtype=item[1];if(item[1].substring(0,2)!='on'){item[1]='on'+item[1];}
if(item[0].detachEvent){item[0].detachEvent(item[1],item[2]);item[0].detachEvent(item[1],item[0][eventtype+item[2]]);}
item[0][item[1]]=null;}}}}();function getElementsByClassName(oElm,strTagName,oClassNames){var arrElements=(strTagName=="*"&&oElm.all)?oElm.all:oElm.getElementsByTagName(strTagName);var arrReturnElements=new Array();var arrRegExpClassNames=new Array();if(typeof oClassNames=="object"){for(var i=0;i<oClassNames.length;i++){arrRegExpClassNames.push(new RegExp("(^|\\s)"+oClassNames[i].replace(/\-/g,"\\-")+"(\\s|$)"));}}
else{arrRegExpClassNames.push(new RegExp("(^|\\s)"+oClassNames.replace(/\-/g,"\\-")+"(\\s|$)"));}
var oElement;var bMatchesAll;for(var j=0;j<arrElements.length;j++){oElement=arrElements[j];bMatchesAll=true;for(var k=0;k<arrRegExpClassNames.length;k++){if(!arrRegExpClassNames[k].test(oElement.className)){bMatchesAll=false;break;}}
if(bMatchesAll){arrReturnElements.push(oElement);}}
return(arrReturnElements)}
function $(){var elements=new Array();for(var i=0;i<arguments.length;i++){var element=arguments[i];if(typeof element=='string')
element=document.getElementById(element);if(arguments.length==1)
return element;elements.push(element);}
return elements;}
new Cookie();Cookie.prototype.write=CookieWrite;Cookie.prototype.del=CookieDelete;Cookie.prototype.read=CookieRead;function Cookie(document,name,hours,path,domain,secure){this.$doc=document;this.$name=name;if(hours)this.$expiration=new Date((new Date()).getTime()+hours*3600000);else this.$expiration=null;if(path)this.$path=path;else this.$path=null;if(domain)this.$domain=domain;else this.$domain=null;if(secure)this.$secure=true;else this.$secure=false;}
function CookieWrite(){var cookieval="";for(var prop in this){if((prop.charAt(0)=='$')||((typeof this[prop])=='function')||prop=='')continue
if(cookieval!="")cookieval+='&'
cookieval+=escape(this[prop])}
var cookie=this.$name+"="+cookieval;if(this.$expiration)cookie+='; expires='+this.$expiration.toGMTString();if(this.$path)cookie+='; path='+this.$path;if(this.$domain)cookie+='; domain='+this.$domain;if(this.$secure)cookie+='; secure';this.$doc.cookie=cookie;}
function CookieRead(){var allcookies=this.$doc.cookie;if(allcookies==""){return false;}
var start=allcookies.indexOf(this.$name+'=');if(start==-1){return false;}
start+=this.$name.length+1;var end=allcookies.indexOf(';',start);if(end==-1)end=allcookies.length;var cookieval=allcookies.substring(start,end);var a=cookieval.split('&');for(var i=0;i<a.length;i++)a[i]=a[i].split(':');for(var i=0;i<a.length;i++)this[a[i][0]]=unescape(a[i][1]);return true;}
function CookieDelete(){var cookie=this.$name+'=';if(this.$path)cookie+='; path='+this.$path;if(this.$domain)cookie+='; domain='+this.$domain;cookie+='; expires=Fri, 02-Jan-1970 00:00:00 GMT';this.$doc.cookie=cookie;}
function attachOverImage(obj,objSrc){if(obj.doNotParse)return;var img=new Image();var defaultImage=obj.src;img.src=objSrc;obj.onmouseover=function(){obj.doNotParse=1;this.src=objSrc;}
obj.onmouseout=function(){this.src=defaultImage;}
img.onerror=function(){alert("Can not load the image '"+objSrc+"'")}
delete img;}
function isEmail(m){var email_regex=/^[\w\d\!\#\$\.\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~]+(\.[\w\d\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~])*\@(((\w+[\w\d\-]*[\w\d]\.)+(\w+[\w\d\-]*[\w\d]))|((\d{1,3}\.){3}\d{1,3}))$/;return(email_regex.test(m));}
function newElement(data){var el;if('string'==typeof data){el=document.createTextNode(data);}else{el=document.createElement(data.tag);delete(data.tag);if('undefined'!=typeof data.children){if('string'==typeof data.children||'undefined'==typeof data.children.length){el.appendChild(newElement(data.children));}else{for(var i=0,child=null;'undefined'!=typeof(child=data.children[i]);i++){el.appendChild(newElement(child));}}
delete(data.children);}
for(attr in data){el[attr]=data[attr];}}
return el;}
function checkPassStrength(passwd){var intScore=0
var strVerdict="weak"
var strLog=""
if(passwd.length<5){intScore=(intScore+3)
strLog=strLog+"3 points for length ("+passwd.length+")\n"}else if(passwd.length>4&&passwd.length<8){intScore=(intScore+6)
strLog=strLog+"6 points for length ("+passwd.length+")\n"}else if(passwd.length>7&&passwd.length<16){intScore=(intScore+12)
strLog=strLog+"12 points for length ("+passwd.length+")\n"}else if(passwd.length>15){intScore=(intScore+18)
strLog=strLog+"18 point for length ("+passwd.length+")\n"}
if(passwd.match(/[a-z]/)){intScore=(intScore+1)
strLog=strLog+"1 point for at least one lower case char\n"}
if(passwd.match(/[A-Z]/)){intScore=(intScore+5)
strLog=strLog+"5 points for at least one upper case char\n"}
if(passwd.match(/\d+/)){intScore=(intScore+5)
strLog=strLog+"5 points for at least one number\n"}
if(passwd.match(/(.*[0-9].*[0-9].*[0-9])/)){intScore=(intScore+5)
strLog=strLog+"5 points for at least three numbers\n"}
if(passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)){intScore=(intScore+5)
strLog=strLog+"5 points for at least one special char\n"}
if(passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)){}
if(passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)){intScore=(intScore+2)
strLog=strLog+"2 combo points for upper and lower letters\n"}
if(passwd.match(/(\d.*\D)|(\D.*\d)/)){intScore=(intScore+2)
strLog=strLog+"2 combo points for letters and numbers\n"}
if(passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/)){intScore=(intScore+2)
strLog=strLog+"2 combo points for letters, numbers and special chars\n"}
if($("passwordStrengthProgress")){if(!passwd){$("passwordStrengthProgress").style.width="0"
strVerdict=""}else if(intScore<16){$("passwordStrengthProgress").style.width="25%"
$("passwordStrengthProgress").style.backgroundColor="red"
strVerdict="very weak"}else if(intScore>15&&intScore<25){$("passwordStrengthProgress").style.width="50%"
$("passwordStrengthProgress").style.backgroundColor="#FFA900"
strVerdict="weak"}else if(intScore>24&&intScore<35){$("passwordStrengthProgress").style.width="75%"
$("passwordStrengthProgress").style.backgroundColor="#6CA7FF"
strVerdict="mediocre"}else if(intScore>34&&intScore<45){$("passwordStrengthProgress").style.width="100%"
$("passwordStrengthProgress").style.backgroundColor=""
strVerdict="strong"}else{$("passwordStrengthProgress").style.width="100%"
$("passwordStrengthProgress").style.backgroundColor=""
strVerdict="stronger"}
$("passwordStrengthStatus").innerHTML=(strVerdict)}
return intScore;}
function resize(e){if(e.scrollHeight&&(e.scrollHeight>e.clientHeight)){}}
function print_r(obj,aler){if(!aler)aler=false;try{var debugWindow={};if(typeof obj=="object"||typeof obj=="array"){var result=""
var name=(obj.name||obj.id);for(var i in obj)
result+=name+"."+i+" = "+obj[i]+"; "
if(aler){alert(result)}else{if(debugWindow){debugWindow.innerText=debugWindow.innerText+"\n\n--------------------------------------------------\n\n"+result}else{debugWindow=newElement({tag:"div",innerText:result})
document.body.appendChild(debugWindow);}}}else{alert("you can't show element properties typeof "+typeof obj)}}catch(e){throw(e)}}
function UserException(message){this.message=message;this.name="UserException";}
function selectImage(e,t){document.body.style.cursor="wait";e.blur();var width=580;var height=(ie)?440:450;var posX=(screen.availWidth-width)/2;var posY=(screen.availHeight-height)/2;if(typeof win!="undefined")win.close();win=window.open("../select_image.php#"+t,"_colorSelect","width="+width+",height="+height+",top="+posY+",left="+posX+",status=1");if(!win){alert("Error:\n\nSome Popup-Blocker program has blocked the ColorSelector!\nPlease allow popups from our site.\n");}
document.body.style.cursor="";}
function uploadMusic(e){document.body.style.cursor="wait";e.blur();var width=340;var height=150;var posX=(screen.availWidth-width)/2;var posY=(screen.availHeight-height)/2;if(typeof win!="undefined")win.close();win=window.open("upload.php","_uploader","width="+width+",height="+height+",top="+posY+",left="+posX+",status=1");if(!win){alert("Error:\n\nSome Popup-Blocker program has blocked the ColorSelector!\nPlease allow popups from our site.\n");}
document.body.style.cursor="";}
function uploadPhotos(e){document.body.style.cursor="wait";e.blur();var width=340;var height=150;var posX=(screen.availWidth-width)/2;var posY=(screen.availHeight-height)/2;if(typeof win!="undefined")win.close();win=window.open("upload_photos.php","_uploader","width="+width+",height="+height+",top="+posY+",left="+posX+",status=1");if(!win){alert("Error:\n\nSome Popup-Blocker program has blocked the ColorSelector!\nPlease allow popups from our site.\n");}
document.body.style.cursor="";}
function isset(e){if(typeof e=="undefined")return false;else return typeof e;}
function redirect(url){if(!url)return;document.location.href=url;}
function forum(dir){if(!dir)return;document.body.style.cursor="wait";if(typeof win!="undefined")win.close();win=window.open("../"+dir+"/forum/","_uploader","");if(!win){alert("Error:\n\nSome Popup-Blocker program has blocked the ColorSelector!\nPlease allow popups from our site.\n");}
document.body.style.cursor="";}
function checkLoginForm(){if($("username").value==""){tip.show($("username"),"left","Enter your username","error");$("username").focus();return false;}else if($("password").value==""){tip.show($("password"),"left","Plase enter the password","error");$("password").focus();return false;}}
function confirmDelete(){if(confirm("Are you sure you want to delete this record?")){return true;}else{return false;}}
function copy(inElement){if(inElement.createTextRange){var range=inElement.createTextRange();if(range&&BodyLoaded==1)
range.execCommand('Copy');}else{var flashcopier='flashcopier';if(!document.getElementById(flashcopier)){var divholder=document.createElement('div');divholder.id=flashcopier;document.body.appendChild(divholder);}
document.getElementById(flashcopier).innerHTML='';var divinfo='<embed src="'+FOLDERS.js+'/modules/clipboard.swf" FlashVars="clipboard='+encodeURIComponent(inElement.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';document.getElementById(flashcopier).innerHTML=divinfo;}}
window.onload=function(){if($("filename")){$("filename").onblur=function(){if(this.value!=this.defaultValue)
this.value=escape(this.value);};}}
Array.prototype.in_array=function(obj){var len=this.length;for(var x=0;x<=len;x++){if(this[x]==obj)return true;}
return false;}
function showLevel(parent){if(!$(parent))return;if($(parent).style.display=="none"){$(parent).style.display="block";e=$(parent);while(e.parentNode){e=e.parentNode;if(e.id&&e.id=="sidebar"){break;}
if(e.tagName.toUpperCase()=="UL"&&e.id.indexOf("childsOf")!=-1){e.style.display="block";}}}else{$(parent).style.display="none";}}

// Settings

var includeCaption = 0;   // Turn on the "caption" feature, and write out the caption HTML
var zoomTime       = 3;   // Milliseconds between frames of zoom animation
var zoomSteps      = 5;  // Number of zoom animation frames
var fade           = 1;   // Fade images in / out
var minBorder      = 90;  // Amount of padding between large, scaled down images, and the window edges
var slideshowTime  = 6;		// The time for the slideshow in seconds

var zoomImageURI   = FOLDERS.images+"/"; // Location of the zoom images
var myWidth = 0, myHeight = 0, myScroll = 0; myScrollWidth = 0; myScrollHeight = 0;
var zoomOpen = false, preloadFrame = 1, preloadActive = false, preloadTime = 0, imgPreload = new Image();

var zoomActive = new Array(); var zoomTimer  = new Array(); 
var zoomOrigW  = new Array(); var zoomOrigH  = new Array();
var zoomOrigX  = new Array(); var zoomOrigY  = new Array();

var zoomID    = "ZoomBox";
var theID     = "ZoomImage";
var theCap    = "ZoomCaption";
var theCapDiv = "ZoomCapDiv";
var imagesArray = [];

var fadeActive = new Array();
var fadeQueue  = new Array();
var fadeTimer  = new Array();
var fadeClose  = new Array();


if(typeof window.addEvent == "function") {
	window.addEvent("load",function() {
		setupZoom();
	});
}

function fadeOut(elem) {
	if (elem.id) {
		fadeElementSetup(elem.id, 100, 0, 10);
	}
}

function fadeIn(elem) {
	if (elem.id) {
		fadeElementSetup(elem.id, 0, 100, 10);	
	}
}

// Fade: Initialize the fade function

function fadeElementSetup(theID, fdStart, fdEnd, fdSteps, fdClose) {

	if (fadeActive[theID] == true) {
		// Already animating, queue up this command
		fadeQueue[theID] = new Array(theID, fdStart, fdEnd, fdSteps);
	} else {
		fadeSteps = fdSteps;
		fadeCurrent = 0;
		fadeAmount = (fdStart - fdEnd) / fadeSteps;
		if(typeof fadeTimer[theID]=="undefined") {
			fadeTimer[theID] = setInterval("fadeElement('"+theID+"', '"+fadeCurrent+"', '"+fadeAmount+"', '"+fadeSteps+"')", 15);
		}
		fadeActive[theID] = true;
		if (fdClose == 1) {
			fadeClose[theID] = true;
		} else {
			fadeClose[theID] = false;
		}
	}
}

// Fade: Do the fade. This function will call itself, modifying the parameters, so
// many instances can run concurrently.

function fadeElement(theID, fadeCurrent, fadeAmount, fadeSteps) {
  
	if (fadeCurrent == fadeSteps) {

	    // We're done, so clear.
	    clearInterval(fadeTimer[theID]);
	    fadeActive[theID] = false;
	    
	    // Should we close it?
	    
	    if (fadeClose[theID] == true) {
	    	document.getElementById(theID).style.visibility = "hidden";
	    }
	    
	    // Hang on.. did a command queue while we were working? If so, make it happen now
	    
	    if (fadeQueue[theID] && fadeQueue[theID] != false) {
	    	fadeElementSetup(fadeQueue[theID][0], fadeQueue[theID][1], fadeQueue[theID][2], fadeQueue[theID][3]);
	    	fadeQueue[theID] = false;
	    }  
  
	} else {
  
		fadeCurrent++;
		
		// Set the opacity depending on if we're adding or subtracting (pos or neg)
		if (fadeAmount < 0) {
			setOpacity(Math.abs(fadeCurrent * fadeAmount), theID);
		} else {
			setOpacity(100 - (fadeCurrent * fadeAmount), theID);
		}
		
		// Keep going, and send myself the updated variables
		clearInterval(fadeTimer[theID]);
		fadeTimer[theID] = setInterval("fadeElement('"+theID+"', '"+fadeCurrent+"', '"+fadeAmount+"', '"+fadeSteps+"')", 15);
	}
}

// Utility: Set the opacity, compatible with a number of browsers. Value from 0 to 100.

function setOpacity(opacity, theID) {

	var object = document.getElementById(theID).style;

	// If it's 100, set it to 99 for Firefox.

	if (navigator.userAgent.indexOf("Firefox") != -1) {
		if (opacity == 100) { opacity = 99.9999; } // This is majorly retarded
	}

	// Multi-browser opacity setting

	object.filter = "alpha(opacity=" + opacity + ")"; // IE/Win
	//object.KhtmlOpacity = (opacity / 100);            // Safari 1.1 or lower, Konqueror
	//object.MozOpacity = (opacity / 100);              // Older Mozilla+Firefox
	object.opacity = (opacity / 100);                 // Safari 1.2, Firefox+Mozilla

}

// Utility: Math functions for animation calucations - From http://www.robertpenner.com/easing/
//
// t = time, b = begin, c = change, d = duration
// time = current frame, begin is fixed, change is basically finish - begin, duration is fixed (frames),

function linear(t, b, c, d)
{
	return c*t/d + b;
}

function sineInOut(t, b, c, d)
{
	return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
}

function cubicIn(t, b, c, d) {
	return c*(t/=d)*t*t + b;
}

function cubicOut(t, b, c, d) {
	return c*((t=t/d-1)*t*t + 1) + b;
}

function cubicInOut(t, b, c, d)
{
	if ((t/=d/2) < 1) return c/2*t*t*t + b;
	return c/2*((t-=2)*t*t + 2) + b;
}

function bounceOut(t, b, c, d)
{
	if ((t/=d) < (1/2.75)){
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)){
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)){
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
}

////////////////////////////
//
// ZOOM IMAGE functions
// (C) 2007 Cabel Sasser / Panic Inc.


// Init. Do not add anything below this line, unless it's something awesome.


// Zoom: Setup The Page! Called onLoad();

function setupZoom() {
	prepZooms();
	insertZoomHTML();
	zoomdiv = document.getElementById(zoomID);  
	zoomimg = document.getElementById(theID);
}

// Zoom: Inject Javascript functions into zoomable href's, one by one.
// This is done at page load time via an onLoad() handler.

function prepZooms() {
	if (! document.getElementsByTagName) {
		return;
	}
	var links = document.getElementsByTagName("a");
	for (i = 0; i < links.length; i++) {
		if (links[i].getAttribute("href")) {
			file = links[i].getAttribute("href");
			if ((file.indexOf(".php") != -1 && file.indexOf("image.php") != -1 ) && /(png|gif|jpg|jpeg)/i.test(file)) {
				links[i].onclick = function () { zoomClick(this); return false; };
				links[i].onmouseover = function () { zoomPreload(this); };
				imagesArray[imagesArray.length] = links[i];
			}
		}
	}
}


// Zoom: Preload a zoom image when hovering over the thumbnail, then set the image once the preload is complete.
// Preloaded image is stored in imgPreload() and swapped out in the zoom function.

function zoomPrev() {
	if(typeof imagesArray == "undefined") return;
	var current;
	for(i in imagesArray) {
		if(String(imagesArray[i]).indexOf(document.getElementById("ZoomImage").src)!=-1) {
			current = i;
			break;
		}
	}
	if(current==0) {
		zoomOut();
	} else {
		var image = new Image();
		image.src = imagesArray[current-1];
		image.onload = function() {
			imgPreload = image;
			zoomClick(newElement({tag:"a",href:imagesArray[current-1],children:[{
				tag:"img",
				src: image.src,
				width: image.width,
				height: image.height
			}]}))
		}
	}
}

function zoomNext() {
	if(typeof imagesArray == "undefined") return;
	var current;
	for(i in imagesArray) {
		if(String(imagesArray[i]).indexOf(document.getElementById("ZoomImage").src)!=-1) {
			current = i;
			break;
		}
	}
	if(current==(imagesArray.length-1)) {
		zoomOut();
	} else {
		var image = new Image();
		image.src = imagesArray[parseInt(current)+1];
		image.onload = function() {
			imgPreload = image;
			zoomClick(newElement({tag:"a",href:imagesArray[parseInt(current)+1],children:[{
				tag:"img",
				src: image.src,
				width: image.width,
				height: image.height
			}]}))
		}
	}
}
var SlideShowInterval;
function zoomSlideshow() {
	if(typeof imagesArray == "undefined") return;
	clearInterval(SlideShowInterval)
	SlideShowInterval = setInterval(zoomNext,slideshowTime*1000);
	var image = new Image();
	image.src = imagesArray[0];
	image.onload = function() {
		imgPreload = image;
		zoomClick(newElement({tag:"a",href:imagesArray[0],children:[{
			tag:"img",
			src: image.src,
			width: image.width,
			height: image.height
		}]}))
	}
}


function zoomPreload(from) {

	var theimage = from.getAttribute("href");
	// console.log("PRELOAD START: "+theimage);

	// Only preload if we have to, i.e. the image isn't this image already

	if (imgPreload.src.indexOf(from.getAttribute("href").substr(from.getAttribute("href").lastIndexOf("/"))) == -1) {
		preloadActive = true;
		imgPreload = new Image();
      
		// Set a function to fire when the preload is complete, setting flags along the way.
   
		imgPreload.onload = function() {
			// console.log("PRELOAD END");
			preloadActive = false;
		}

		// Load it!
		imgPreload.src = theimage;
	}
}

// Zoom: Start the preloading animation cycle.

function preloadAnimStart() {
	preloadTime = new Date();
	document.getElementById("ZoomSpin").style.left = (myWidth / 2) + 'px';
	document.getElementById("ZoomSpin").style.top = ((myHeight / 2) + myScroll) + 'px';
	document.getElementById("ZoomSpin").style.visibility = "visible";	
	preloadFrame = 1;
	document.getElementById("ZoomSpin").src = zoomImageURI+'zoom-spin-'+preloadFrame+'.png';
	if(typeof preloadAnimTimer!="undefined") {
		clearInterval(preloadAnimTimer)
	}
	preloadAnimTimer = setInterval("preloadAnim()", 100);
}

// Until we've been preloading for one second, just chill out in here.
// 
// function preloadAnimPending(from) {
// 	if (preloadActive != false) {
// 		if ((new Date() - preloadTime) > 1000) {
// 			document.getElementById("ZoomSpin").style.visibility = "visible";
// 			clearInterval(preloadAnimTimer);
// 			preloadAnimTimer = setInterval("preloadAnim()", 100);
// 		}
// 		else {
// 			// Stay in this loop and don't do anything while we wait one second
// 		}
// 	} else {
// 		clearInterval(preloadAnimTimer);
// 		zoomIn(preloadFrom);
// 	}
// } 

// Zoom: Display and ANIMATE the jibber jabber widget. Once preloadActive is false, bail and zoom it up!


function preloadAnim(from) {
	if (preloadActive != false) {
		document.getElementById("SpinImage").src = zoomImageURI+'zoom-spin-'+preloadFrame+'.png';
		preloadFrame++;
		if (preloadFrame > 12) preloadFrame = 1;
	} else {
		document.getElementById("ZoomSpin").style.visibility = "hidden";    
		if(typeof preloadAnimTimer!="undefined") clearInterval(preloadAnimTimer);
		zoomIn(preloadFrom);
	}
}

// Zoom: We got a click! Should we do the zoom? Or wait for the preload to complete?

function zoomClick(from) {

	// TODO: Double check that imgPreload src = clicked src

	// Get browser dimensions
	getWindowSizes();
	
	

	if (preloadActive == true) {
		// Preloading is otherwise still going on. So wait.
		preloadFrom = from;
		preloadAnimStart();
	} else {
		// Otherwise, we're loaded: do the zoom!
		zoomIn(from);
	}
}

// Zoom: Move an element in to endH endW, using zoomHost as a starting point.
// "from" is an object reference to the href that spawned the zoom.

function zoomIn(from) {

	zoomimg.src = from.getAttribute("href");

	// Determine the zoom settings from where we came from, the element in the <a>.
	// If there's no element in the <a>, or we can't get the width, make stuff up

	if (from.childNodes[0].width) {
		startW = from.childNodes[0].width;
		startH = from.childNodes[0].height;
		startPos = findElementPos(from.childNodes[0]);
	} else {
		startW = 200;
		startH = 200;
		startPos = findElementPos(from);
	}
	
		    
	hostX = startPos[0];
	hostY = startPos[1];

	// Make up for a scrolled containing div.
	// TODO: This HAS to move into findElementPos.
	
	if (document.getElementById('scroller')) {
		hostX = hostX - document.getElementById('scroller').scrollLeft;
	}

	// Determine the target zoom settings
	endW = imgPreload.width;
	endH = imgPreload.height;
	if(endW==0 && endH==0) {
		return;
	}
	// TODO: need to get "rollover" setting somehow.
  
	// Don't act if we're already doing something.
  
	if (zoomActive[theID] != true) {
  
		// Clear everything out just in case something is already open
     
		document.getElementById("ShadowBox").style.visibility = "hidden";
		document.getElementById("BlackBackground").style.visibility = "hidden";
		document.getElementById("BlackBackground").style.display = "none";
		document.getElementById("PrevBtn").style.visibility = "hidden";
		document.getElementById("NextBtn").style.visibility = "hidden";
		document.getElementById("ZoomClose").style.visibility = "hidden";     
     
		// Set the CAPTION if turned on
  
		if (includeCaption == 1) {
			zoomcap  = document.getElementById(theCap);
			zoomcapd = document.getElementById(theCapDiv);
       
			if (from.getAttribute('title') && includeCaption == 1) {
				zoomcapd.style.display = 'block';
				zoomcap.innerHTML = from.getAttribute('title');
			} else {
				zoomcapd.style.display = 'none';
			}
       
		}   
     
		// Store original position in an array for future zoomOut.

		zoomOrigW[theID] = startW;
		zoomOrigH[theID] = startH;
		zoomOrigX[theID] = hostX;
		zoomOrigY[theID] = hostY;
     
		// Now set the starting dimensions
     
		zoomimg.style.width = startW + 'px';
		zoomimg.style.height = startH + 'px';
		zoomdiv.style.left = hostX + 'px';
		zoomdiv.style.top = hostY + 'px';
     
		// Show the zoom box, make it invisible
     
		if (fade == 1) {
			setOpacity(0, zoomID);
		}
		zoomdiv.style.visibility = "visible";
  
		// If it's too big to fit in the window, shrink the width and height to fit (with ratio).
  
		sizeRatio = endW / endH;
		if (endW > myWidth - minBorder) {
			endW = myWidth - minBorder;
			endH = endW / sizeRatio;
		}
		if (endH > myHeight - minBorder) {
			endH = myHeight - minBorder;
			endW = endH * sizeRatio;
		}

		zoomChangeX = ((myWidth / 2) - (endW / 2) - hostX);
		zoomChangeY = (((myHeight / 2) - (endH / 2) - hostY) + myScroll);
		zoomChangeW = (endW - startW);
		zoomChangeH = (endH - startH);
		
		// console.log("X: "+zoomChangeX+" Y: "+zoomChangeY+" W: "+zoomChangeW+" H: "+zoomChangeH);

		// Setup Zoom
     
		zoomCurrent = 0;
     
		// Setup Fade with Zoom, If Requested
     
		if (fade == 1) {
			fadeCurrent = 0;
			fadeAmount = (0 - 100) / zoomSteps;
		} else {
			fadeAmount = 0;
		}
       
		// Do It!
		
		clearInterval(zoomTimer)
		zoomTimer[theID] = setInterval("zoomElement('"+zoomID+"', '"+theID+"', "+zoomCurrent+", "+startW+", "+zoomChangeW+", "+startH+", "+zoomChangeH+", "+hostX+", "+zoomChangeX+", "+hostY+", "+zoomChangeY+", "+zoomSteps+", "+fade+", "+fadeAmount+", 'zoomDoneIn(zoomID)')", zoomTime);		
		zoomActive[theID] = true; 
		setOpacity(90, "BlackBackground");
		document.getElementById("BlackBackground").style.visibility = "visible";
		document.getElementById("BlackBackground").style.display = "block";
		document.getElementById("PrevBtn").style.visibility = "visible";
		document.getElementById("NextBtn").style.visibility = "visible";
		document.getElementById("PrevBtn").style.top = myScroll+"px";
		document.getElementById("NextBtn").style.top = myScroll+"px";
		if(document.all) {
			document.getElementById("BlackBackground").style.width = myWidth+"px";
			document.getElementById("BlackBackground").style.height = document.body.offsetHeight+"px";
			document.getElementById("BlackBackground").style.top = "0px";
			document.getElementById("PrevBtn").style.top = myScroll+"px";
			document.getElementById("NextBtn").style.top = myScroll+"px";
			document.getElementById("PrevBtn").style.height = myHeight+"px";
			document.getElementById("NextBtn").style.height = myHeight+"px";
		}
	}
}

function clearIntervals(array) {
	if(typeof array=="object") {
		for(i in array) {
			console.log(typeof array[i]);
		}
	}
}

// Zoom it back out.

function zoomOut() {

	// Check to see if something is happening/open
  
	if (zoomActive[theID] != true) {
		
		if(SlideShowInterval) clearInterval(SlideShowInterval);
     
		// First, get rid of the shadow if necessary
     
		document.getElementById("ShadowBox").style.visibility = "hidden";
		document.getElementById("BlackBackground").style.visibility = "hidden";
		document.getElementById("BlackBackground").style.display = "none";
		document.getElementById("ZoomClose").style.visibility = "hidden";
		document.getElementById("PrevBtn").style.visibility = "hidden";
		document.getElementById("NextBtn").style.visibility = "hidden";
     
		// Now, figure out where we came from, to get back there

		startX = parseInt(zoomdiv.style.left);
		startY = parseInt(zoomdiv.style.top);
		startW = zoomimg.width;
		startH = zoomimg.height;
		zoomChangeX = zoomOrigX[theID] - startX;
		zoomChangeY = zoomOrigY[theID] - startY;
		zoomChangeW = zoomOrigW[theID] - startW;
		zoomChangeH = zoomOrigH[theID] - startH;
    
		// Setup Zoom
	   
		zoomCurrent = 0;
     
		// Setup Fade with Zoom, If Requested
     
		if (fade == 1) {
			fadeCurrent = 0;
			fadeAmount = (100 - 0) / zoomSteps;
		} else {
			fadeAmount = 0;
		}
     
		// Do It!
		clearInterval(zoomTimer[theID])
		zoomTimer[theID] = setInterval("zoomElement('"+zoomID+"', '"+theID+"', "+zoomCurrent+", "+startW+", "+zoomChangeW+", "+startH+", "+zoomChangeH+", "+startX+", "+zoomChangeX+", "+startY+", "+zoomChangeY+", "+zoomSteps+", "+fade+", "+fadeAmount+", 'zoomDone(zoomID, theID)')", zoomTime);	
		zoomActive[theID] = true;
   }
}

// Finished Zooming In

function zoomDoneIn(zoomdiv, theID) {

	// Note that it's open
  
	zoomOpen = true;

	// Make sure they are gone

	setOpacity(0, "ShadowBox");
	setOpacity(0, "ZoomClose");

	// Position the shadow behind the zoomed in image.

	zoomdiv = document.getElementById(zoomdiv);
	shadowdiv = document.getElementById("ShadowBox");
 
	shadowLeft = parseInt(zoomdiv.style.left) - 13;
	shadowTop = parseInt(zoomdiv.style.top) - 8;
	shadowWidth = zoomdiv.offsetWidth + 26;
	shadowHeight = zoomdiv.offsetHeight + 26; 

	shadowdiv.style.width = shadowWidth + 'px';
	shadowdiv.style.height = shadowHeight + 'px';
	shadowdiv.style.left = shadowLeft + 'px';
	shadowdiv.style.top = shadowTop + 'px';
  
	// Display Shadow and Zoom
  
//	document.getElementById("ShadowBox").style.visibility = "visible";
//	fadeElementSetup("ShadowBox", 0, 100, 5);
	if(!document.all) document.getElementById("ZoomClose").style.visibility = "visible";
	fadeElementSetup("ZoomClose", 0, 100, 5);
  
}

// Finished Zooming Out

function zoomDone(zoomdiv, theID) {

	// No longer open
  
	zoomOpen = false;

	// Clear stuff out, clean up

	zoomOrigH[theID] = "";
	zoomOrigW[theID] = "";
	document.getElementById(zoomdiv).style.visibility = "hidden";
	zoomActive[theID] == false;
}

// Actually zoom the element

function zoomElement(zoomdiv, theID, zoomCurrent, zoomStartW, zoomChangeW, zoomStartH, zoomChangeH, zoomStartX, zoomChangeX, zoomStartY, zoomChangeY, zoomSteps, fade, fadeAmount, execWhenDone) {

	// console.log("Zooming Step #"+zoomCurrent+ " of "+zoomSteps+" (zoom " + zoomStartW + "/" + zoomChangeW + ") (zoom " + zoomStartH + "/" + zoomChangeH + ")  (zoom " + zoomStartX + "/" + zoomChangeX + ")  (zoom " + zoomStartY + "/" + zoomChangeY + ") Fade: "+fadeAmount);
    
	// Test if we're done, or if we continue
	
	if (zoomCurrent == (zoomSteps + 1)) {
		zoomActive[theID] = false;
		clearInterval(zoomTimer[theID]);

		if (execWhenDone != "") {
			eval(execWhenDone);
		}
	} else {
	
		// Do the Fade!
	  
		if (fade != 0) {
			if (fadeAmount < 0) {
				setOpacity(Math.abs(zoomCurrent * fadeAmount), zoomdiv);
			} else {
				setOpacity(100 - (zoomCurrent * fadeAmount), zoomdiv);
			}
		}
	  
		// Calculate this step's difference, and move it!
		
		moveW = cubicInOut(zoomCurrent, zoomStartW, zoomChangeW, zoomSteps);
		moveH = cubicInOut(zoomCurrent, zoomStartH, zoomChangeH, zoomSteps);
		moveX = cubicInOut(zoomCurrent, zoomStartX, zoomChangeX, zoomSteps);
		moveY = cubicInOut(zoomCurrent, zoomStartY, zoomChangeY, zoomSteps);
	
		document.getElementById(zoomdiv).style.left = moveX + 'px';
		document.getElementById(zoomdiv).style.top = moveY + 'px';
		zoomimg.style.width = moveW + 'px';
		zoomimg.style.height = moveH + 'px';
	
		zoomCurrent++;
		
		clearInterval(zoomTimer[theID]);
		zoomTimer[theID] = setInterval("zoomElement('"+zoomdiv+"', '"+theID+"', "+zoomCurrent+", "+zoomStartW+", "+zoomChangeW+", "+zoomStartH+", "+zoomChangeH+", "+zoomStartX+", "+zoomChangeX+", "+zoomStartY+", "+zoomChangeY+", "+zoomSteps+", "+fade+", "+fadeAmount+", '"+execWhenDone+"')", zoomTime);
	}
}

// Zoom Rollover Functions
// To be re-added

function zoomMouseOver() {
//  if (rollOverImg) {
//     if (document.getElementById("ZoomImage").src != rollOverImg) {
//        document.getElementById("ZoomImage").src = rollOverImg;
//     }
//  }
}

function zoomMouseOut() {
//  if (rollOverImg) {
//     if (document.getElementById("ZoomImage").src != image) {
//        document.getElementById("ZoomImage").src = image;
//     }
//  }
}

// Get the size of the window, and set myWidth and myHeight

function getWindowSizes() {
	if (document.all) {
		// IE4+ or IE6+ in standards compliant 
		myWidth  = (document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth;
		myHeight = (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
		myScroll = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
	} else {
		// Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myScroll = window.pageYOffset;
	}
	
	// Core code from - quirksmode.org
    if (window.innerHeight && window.scrollMaxY) {	
        myScrollWidth = document.body.scrollWidth;
		myScrollHeight = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
		myScrollWidth = document.body.scrollWidth;
		myScrollHeight = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		myScrollWidth = document.body.offsetWidth;
		myScrollHeight = document.body.offsetHeight;
	}
}

// Find the Y position of an element on a page
// Return Y and X as an array

function findElementPos(elemFind)
{
	var elemX = 0;
	var elemY = 0;
	do {
		elemX += elemFind.offsetLeft;
		elemY += elemFind.offsetTop;
	} while ( elemFind = elemFind.offsetParent )

	//console.log("Found element "+elemFind+" at "+elemY+"/"+elemX);

	return Array(elemX, elemY);
}

//
// ----- DISPLAY CODE -----
//

function insertZoomHTML() {

  // All of this junk creates the three <div>'s used to hold the closebox, image, and zoom shadow.
  // It's a lot of Javascript for a little HTML. But, hey, this must be the "right way", though, yeah?
  // I'd also like to ask forgiveness for the large amounts of tables in use. Sometimes, CSS just doesn't cut it... I think.

  var inBody = document.getElementsByTagName("body").item(0);

  // WAIT SPINNER
  
  var inSpinbox = document.createElement("div");
  inSpinbox.setAttribute('id', 'ZoomSpin');
  inSpinbox.style.position = 'absolute';
  inSpinbox.style.left = '10px';
  inSpinbox.style.top = '10px';
  inSpinbox.style.visibility = 'hidden';
  inSpinbox.style.zIndex = '5000';
  inBody.insertBefore(inSpinbox, inBody.firstChild);
  
  var inSpinImage = document.createElement("img");
  inSpinImage.setAttribute('id', 'SpinImage');
  inSpinImage.setAttribute('src', zoomImageURI+'zoom-spin-1.png');
  inSpinbox.appendChild(inSpinImage);

  // ZOOM IMAGE
  //
  // <div id="ZoomBox">
  //   <a href="javascript:zoomOut();"><img src="/images/spacer.gif" id="ZoomImage" border="0"></a> <!-- THE IMAGE -->
  //   <div id="ZoomClose">
  //     <a href="javascript:zoomOut();"><img src="/images/closebox.png" width="30" height="30" border="0"></a>
  //   </div>
  // </div>

  var inZoombox = document.createElement("div");
  inZoombox.setAttribute('id', 'ZoomBox');
  inZoombox.style.position = 'absolute'; 
  inZoombox.style.left = '10px';
  inZoombox.style.top = '10px';
  inZoombox.style.visibility = 'hidden';
  inZoombox.style.zIndex = '499';
  // inZoombox.style.background = 'white';           // DEBUG
  inBody.insertBefore(inZoombox, inSpinbox.nextSibling);

  var inLink1 = document.createElement("a");
  inLink1.setAttribute('href','javascript:zoomOut();');
  inZoombox.appendChild(inLink1);
  
  var inImage1 = document.createElement("img");
  inImage1.setAttribute('src',zoomImageURI+'spacer.gif');
  inImage1.setAttribute('id','ZoomImage');
  inImage1.setAttribute('border', '0');
  inImage1.setAttribute('onMouseOver', 'zoomMouseOver();')
  inImage1.setAttribute('onMouseOut', 'zoomMouseOut();')
  inImage1.style.display = 'block';
  inImage1.style.width = '10px';
  inImage1.style.height = '10px';
  inLink1.appendChild(inImage1);

  var inClosebox = document.createElement("div");
  inClosebox.setAttribute('id', 'ZoomClose');
  inClosebox.style.position = 'absolute';
  inClosebox.style.left = '-15px';
  inClosebox.style.top = '-15px';
  inClosebox.style.filter = 'alpha(opacity=0)';
  inClosebox.style.MozOpacity = '0';
  inClosebox.style.opacity = '0';
  inClosebox.style.visibility = 'hidden';
  inZoombox.appendChild(inClosebox);
  
  var inLink2 = document.createElement("a");
  inLink2.setAttribute('href','javascript:zoomOut(1);');
  inClosebox.appendChild(inLink2);
  var inImage2 = document.createElement("img");
  inImage2.setAttribute('src',zoomImageURI+'closebox.png');
  inImage2.setAttribute('width','30');
  inImage2.setAttribute('height','30');
  inImage2.setAttribute('border','0');
  inLink2.appendChild(inImage2);
  
  // SHADOW
  // Now, the.. shudder.. shadow table.
  
  // <div id="ShadowBox"><table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0"> X
  //   <tr height="25">
  //   <td width="27"><img src="/images/zoom-shadow1.png" width="27" height="25"></td>
  //   <td background="/images/zoom-shadow2.png">&nbsp;</td>
  //   <td width="27"><img src="/images/zoom-shadow3.png" width="27" height="25"></td>
  //   </tr>

  var inShadowbox = document.createElement("div");
  inShadowbox.setAttribute('id', 'ShadowBox');
  inShadowbox.style.position = 'absolute'; 
  inShadowbox.style.left = '50px';
  inShadowbox.style.top = '50px';
  inShadowbox.style.width = '100px';
  inShadowbox.style.height = '100px';
  inShadowbox.style.visibility = 'hidden';
  inShadowbox.style.zIndex = '45';
  inBody.insertBefore(inShadowbox, inZoombox.nextSibling);

  var BlackBackground = document.createElement("div");
  BlackBackground.setAttribute('id', 'BlackBackground');
  BlackBackground.style.left = '0';
  BlackBackground.style.top = '0';
  BlackBackground.style.width = '100%';
  BlackBackground.style.height = '100%';
  BlackBackground.style.visibility = 'hidden';
  BlackBackground.style.zIndex = '55';
  BlackBackground.onclick = function() {zoomOut(1);}
  inBody.insertBefore(BlackBackground, inZoombox.nextSibling);
  
  var PrevBtn = newElement({
		tag: "DIV",
		id: "PrevBtn",
		children: {
			tag:"a",
			children:" ",
			href: "javascript:zoomPrev()"
		}
	})
  inBody.insertBefore(PrevBtn, inZoombox.nextSibling);

  var NextBtn = newElement({
		tag: "DIV",
		id: "NextBtn",
		children: {
			tag:"a",
			children:" ",
			href: "javascript:zoomNext()"
		}
	})
  inBody.insertBefore(NextBtn, inZoombox.nextSibling);

  var inTable = document.createElement("table");
  inTable.setAttribute('border', '0');
  inTable.setAttribute('width', '100%');
  inTable.setAttribute('height', '100%');
  inTable.setAttribute('cellpadding', '0');
  inTable.setAttribute('cellspacing', '0');
  inShadowbox.appendChild(inTable);
  
  var inRow1 = document.createElement("tr");
  inRow1.style.height = '25px';
  inTable.appendChild(inRow1);
  
  var inCol1 = document.createElement("td");
  inCol1.style.width = '27px';
  inRow1.appendChild(inCol1);  
  var inShadowImg1 = document.createElement("img");
  inShadowImg1.setAttribute('src', zoomImageURI+'zoom-shadow1.png');
  inShadowImg1.setAttribute('width', '27');
  inShadowImg1.setAttribute('height', '25');
  inShadowImg1.style.display = 'block';
  inCol1.appendChild(inShadowImg1);

  var inCol2 = document.createElement("td");
  inCol2.setAttribute('background', zoomImageURI+'zoom-shadow2.png');
  inRow1.appendChild(inCol2);
  // inCol2.innerHTML = '<img src=';
  var inSpacer1 = document.createElement("img");
  inSpacer1.setAttribute('src',zoomImageURI+'spacer.gif');
  inSpacer1.setAttribute('height', '1');
  inSpacer1.setAttribute('width', '1');
  inSpacer1.style.display = 'block';
  inCol2.appendChild(inSpacer1);

  var inCol3 = document.createElement("td");
  inCol3.style.width = '27px';
  inRow1.appendChild(inCol3);  
  var inShadowImg3 = document.createElement("img");
  inShadowImg3.setAttribute('src', zoomImageURI+'zoom-shadow3.png');
  inShadowImg3.setAttribute('width', '27');
  inShadowImg3.setAttribute('height', '25');
  inShadowImg3.style.display = 'block';
  inCol3.appendChild(inShadowImg3);

  //   <tr>
  //   <td background="/images/zoom-shadow4.png">&nbsp;</td>
  //   <td bgcolor="#ffffff">&nbsp;</td>
  //   <td background="/images/zoom-shadow5.png">&nbsp;</td>
  //   </tr>

  inRow2 = document.createElement("tr");
  inTable.appendChild(inRow2);
  
  var inCol4 = document.createElement("td");
  inCol4.setAttribute('background', zoomImageURI+'zoom-shadow4.png');
  inRow2.appendChild(inCol4);
  // inCol4.innerHTML = '&nbsp;';
  var inSpacer2 = document.createElement("img");
  inSpacer2.setAttribute('src',zoomImageURI+'spacer.gif');
  inSpacer2.setAttribute('height', '1');
  inSpacer2.setAttribute('width', '1');
  inSpacer2.style.display = 'block';
  inCol4.appendChild(inSpacer2);
  
  var inCol5 = document.createElement("td");
  inCol5.setAttribute('bgcolor', '#ffffff');
  inRow2.appendChild(inCol5);
  // inCol5.innerHTML = '&nbsp;';
  var inSpacer3 = document.createElement("img");
  inSpacer3.setAttribute('src',zoomImageURI+'spacer.gif');
  inSpacer3.setAttribute('height', '1');
  inSpacer3.setAttribute('width', '1');
  inSpacer3.style.display = 'block';
  inCol5.appendChild(inSpacer3);
  
  var inCol6 = document.createElement("td");
  inCol6.setAttribute('background', zoomImageURI+'zoom-shadow5.png');
  inRow2.appendChild(inCol6);
  // inCol6.innerHTML = '&nbsp;';
  var inSpacer4 = document.createElement("img");
  inSpacer4.setAttribute('src',zoomImageURI+'spacer.gif');
  inSpacer4.setAttribute('height', '1');
  inSpacer4.setAttribute('width', '1');
  inSpacer4.style.display = 'block';
  inCol6.appendChild(inSpacer4);

  //   <tr height="26">
  //   <td width="27"><img src="/images/zoom-shadow6.png" width="27" height="26"</td>
  //   <td background="/images/zoom-shadow7.png">&nbsp;</td>
  //   <td width="27"><img src="/images/zoom-shadow8.png" width="27" height="26"></td>
  //   </tr>  
  // </table>

  var inRow3 = document.createElement("tr");
  inRow3.style.height = '26px';
  inTable.appendChild(inRow3);
  
  var inCol7 = document.createElement("td");
  inCol7.style.width = '27px';
  inRow3.appendChild(inCol7);
  var inShadowImg7 = document.createElement("img");
  inShadowImg7.setAttribute('src', zoomImageURI+'zoom-shadow6.png');
  inShadowImg7.setAttribute('width', '27');
  inShadowImg7.setAttribute('height', '26');
  inShadowImg7.style.display = 'block';
  inCol7.appendChild(inShadowImg7);

  var inCol8 = document.createElement("td");
  inCol8.setAttribute('background', zoomImageURI+'zoom-shadow7.png');
  inRow3.appendChild(inCol8);  
  // inCol8.innerHTML = '&nbsp;';
  var inSpacer5 = document.createElement("img");
  inSpacer5.setAttribute('src',zoomImageURI+'spacer.gif');
  inSpacer5.setAttribute('height', '1');
  inSpacer5.setAttribute('width', '1');
  inSpacer5.style.display = 'block';
  inCol8.appendChild(inSpacer5);

  var inCol9 = document.createElement("td");
  inCol9.style.width = '27px';
  inRow3.appendChild(inCol9);  
  var inShadowImg9 = document.createElement("img");
  inShadowImg9.setAttribute('src', zoomImageURI+'zoom-shadow8.png');
  inShadowImg9.setAttribute('width', '27');
  inShadowImg9.setAttribute('height', '26');
  inShadowImg9.style.display = 'block';
  inCol9.appendChild(inShadowImg9);

  if (includeCaption == 1) {

    // CAPTION
    //
    // <table border="1" cellpadding="0" cellspacing="0">
    // <tr height="26">
    // <td><img src="zoom-caption-l.png" width="13" height="26"></td>
    // <td rowspan="3" background="zoom-caption-fill.png"><div id="ZoomCaption"></div></td>
    // <td><img src="zoom-caption-r.png" width="13" height="26"></td>
    // </tr>
    // </table>
    
    var inCapDiv = document.createElement("div");
    inCapDiv.setAttribute('id', 'ZoomCapDiv');
    inCapDiv.style.display = 'none';
    inCapDiv.style.marginLeft = '13px';
    inCapDiv.style.marginRight = '13px';
    inShadowbox.appendChild(inCapDiv);
    
    var inCapTable = document.createElement("table");
    inCapTable.setAttribute('border', '0');
    inCapTable.setAttribute('cellpadding', '0');
    inCapTable.setAttribute('cellspacing', '0');
    inCapTable.setAttribute('align', 'center');
    inCapDiv.appendChild(inCapTable);
    
    var inCapRow1 = document.createElement("tr");
    inCapTable.appendChild(inCapRow1);
  
    var inCapCol1 = document.createElement("td");
    inCapRow1.appendChild(inCapCol1);
    var inCapImg1 = document.createElement("img");
    inCapImg1.setAttribute('src', zoomImageURI+'zoom-caption-l.png');
    inCapImg1.setAttribute('width', '13');
    inCapImg1.setAttribute('height', '26');
    inCapImg1.style.display = 'block';
    inCapCol1.appendChild(inCapImg1);
  
    var inCapCol2 = document.createElement("td");
    inCapCol2.setAttribute('background', zoomImageURI+'zoom-caption-fill.png');
    inCapCol2.setAttribute('id', 'ZoomCaption');
    inCapCol2.setAttribute('valign', 'middle');
    
    inCapCol2.style.fontSize = '14px';
    inCapCol2.style.fontFamily = 'Helvetica';
    inCapCol2.style.fontWeight = 'bold';
    inCapCol2.style.color = '#ffffff';
    inCapCol2.style.textShadow = '0px 2px 4px #000000';
    inCapCol2.style.whiteSpace = 'nowrap';
    
    inCapRow1.appendChild(inCapCol2);
  
    var inCapCol3 = document.createElement("td");
    inCapRow1.appendChild(inCapCol3);
    var inCapImg2 = document.createElement("img");
    inCapImg2.setAttribute('src', zoomImageURI+'zoom-caption-r.png');
    inCapImg2.setAttribute('width', '13');
    inCapImg2.setAttribute('height', '26');
    inCapImg2.style.display = 'block';
    inCapCol3.appendChild(inCapImg2);

  }
}
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('m 71={70:\'1.11\'};h $3z(X){c(X!=6N)};h $q(X){k(!$3z(X))c U;k(X.2A)c\'Q\';m q=3A X;k(q==\'2d\'&&X.7a){1y(X.3T){N 1:c\'Q\';N 3:c(/\\S/).2c(X.5v)?\'7b\':\'76\'}}k(q==\'2d\'||q==\'h\'){1y(X.6b){N 1s:c\'15\';N 4W:c\'4x\';N 1f:c\'4J\'}k(3A X.G==\'4i\'){k(X.1R)c\'7c\';k(X.6u)c\'L\'}}c q};h $2v(){m 2X={};F(m i=0;i<L.G;i++){F(m t 1j L[i]){m 3K=L[i][t];m 3G=2X[t];k(3G&&$q(3K)==\'2d\'&&$q(3G)==\'2d\')2X[t]=$2v(3G,3K);R 2X[t]=3K}}c 2X};m $M=h(){m P=L;k(!P[1])P=[7,P[0]];F(m t 1j P[1])P[0][t]=P[1][t];c P[0]};m $2z=h(){F(m i=0,l=L.G;i<l;i++){L[i].M=h(1e){F(m 1h 1j 1e){k(!7.1d[1h])7.1d[1h]=1e[1h];k(!7[1h])7[1h]=$2z.3h(1h)}}}};$2z.3h=h(1h){c h(J){c 7.1d[1h].2w(J,1s.1d.60.1x(L,1))}};$2z(4O,1s,4D,6n);h $3r(X){c!!(X||X===0)};h $4Y(X,5e){c $3z(X)?X:5e};h $4Q(2o,2J){c 1F.7o(1F.4Q()*(2J-2o+1)+2o)};h $21(){c T 7D().7v()};h $42(1D){7h(1D);7g(1D);c 1c};m 2B=h(X){X=X||{};X.M=$M;c X};m 7j=T 2B(B);m 7l=T 2B(O);O.63=O.2h(\'63\')[0];B.2f=!!(O.6E);k(B.7L)B.1T=B[B.7K?\'7J\':\'6k\']=12;R k(O.5C&&!O.7C&&!7B.7A)B.2W=B[B.2f?\'7E\':\'5O\']=12;R k(O.7F!=1c)B.47=12;B.7I=B.2W;7H.M=$M;k(3A 2O==\'6N\'){m 2O=h(){};k(B.2W)O.66("7U");2O.1d=(B.2W)?B["[[6R.1d]]"]:{}}2O.1d.2A=h(){};k(B.6k)3W{O.74("73",U,12)}45(e){};m 1f=h(1L){m 2P=h(){c(L[0]!==1c&&7.1N&&$q(7.1N)==\'h\')?7.1N.2w(7,L):7};$M(2P,7);2P.1d=1L;2P.6b=1f;c 2P};1f.25=h(){};1f.1d={M:h(1L){m 3O=T 7(1c);F(m t 1j 1L){m 6G=3O[t];3O[t]=1f.6O(6G,1L[t])}c T 1f(3O)},5U:h(){F(m i=0,l=L.G;i<l;i++)$M(7.1d,L[i])}};1f.6O=h(2b,1n){k(2b&&2b!=1n){m q=$q(1n);k(q!=$q(2b))c 1n;1y(q){N\'h\':m 4r=h(){7.1Z=L.6u.1Z;c 1n.2w(7,L)};4r.1Z=2b;c 4r;N\'2d\':c $2v(2b,1n)}}c 1n};m 5h=T 1f({6Z:h(u){7.2r=7.2r||[];7.2r.14(u);c 7},6K:h(){k(7.2r&&7.2r.G)7.2r.5c().1u(10,7)},6W:h(){7.2r=[]}});m 1M=T 1f({20:h(q,u){k(u!=1f.25){7.$H=7.$H||{};7.$H[q]=7.$H[q]||[];7.$H[q].4M(u)}c 7},22:h(q,P,1u){k(7.$H&&7.$H[q]){7.$H[q].1B(h(u){u.1E({\'J\':7,\'1u\':1u,\'L\':P})()},7)}c 7},4u:h(q,u){k(7.$H&&7.$H[q])7.$H[q].2m(u);c 7}});m 5g=T 1f({4f:h(){7.I=$2v.2w(1c,[7.I].M(L));k(7.20){F(m 2S 1j 7.I){k($q(7.I[2S]==\'h\')&&(/^4b[A-Z]/).2c(2S))7.20(2S,7.I[2S])}}c 7}});1s.M({3q:h(u,J){F(m i=0,j=7.G;i<j;i++)u.1x(J,7[i],i,7)},1O:h(u,J){m 2D=[];F(m i=0,j=7.G;i<j;i++){k(u.1x(J,7[i],i,7))2D.14(7[i])}c 2D},1V:h(u,J){m 2D=[];F(m i=0,j=7.G;i<j;i++)2D[i]=u.1x(J,7[i],i,7);c 2D},3s:h(u,J){F(m i=0,j=7.G;i<j;i++){k(!u.1x(J,7[i],i,7))c U}c 12},6Y:h(u,J){F(m i=0,j=7.G;i<j;i++){k(u.1x(J,7[i],i,7))c 12}c U},2G:h(1R,1a){m 2I=7.G;F(m i=(1a<0)?1F.2J(0,2I+1a):1a||0;i<2I;i++){k(7[i]===1R)c i}c-1},6i:h(1o,G){1o=1o||0;k(1o<0)1o=7.G+1o;G=G||(7.G-1o);m 4G=[];F(m i=0;i<G;i++)4G[i]=7[1o++];c 4G},2m:h(1R){m i=0;m 2I=7.G;6h(i<2I){k(7[i]===1R){7.3c(i,1);2I--}R{i++}}c 7},W:h(1R,1a){c 7.2G(1R,1a)!=-1},78:h(1i){m X={},G=1F.2o(7.G,1i.G);F(m i=0;i<G;i++)X[1i[i]]=7[i];c X},M:h(15){F(m i=0,j=15.G;i<j;i++)7.14(15[i]);c 7},2v:h(15){F(m i=0,l=15.G;i<l;i++)7.4M(15[i]);c 7},4M:h(1R){k(!7.W(1R))7.14(1R);c 7},77:h(){c 7[$4Q(0,7.G-1)]||1c},5x:h(){c 7[7.G-1]||1c}});1s.1d.1B=1s.1d.3q;1s.1B=1s.3q;h $A(15){c 1s.6i(15)};h $1B(2a,u,J){k(2a&&3A 2a.G==\'4i\'&&$q(2a)!=\'2d\'){1s.3q(2a,u,J)}R{F(m 1p 1j 2a)u.1x(J||2a,2a[1p],1p)}};1s.1d.2c=1s.1d.W;4D.M({2c:h(3t,6d){c(($q(3t)==\'1W\')?T 4W(3t,6d):3t).2c(7)},28:h(){c 2L(7,10)},6l:h(){c 4h(7)},4t:h(){c 7.2e(/-\\D/g,h(1S){c 1S.4R(1).6c()})},5B:h(){c 7.2e(/\\w[A-Z]/g,h(1S){c(1S.4R(0)+\'-\'+1S.4R(1).3n())})},5F:h(){c 7.2e(/\\b[a-z]/g,h(1S){c 1S.6c()})},4y:h(){c 7.2e(/^\\s+|\\s+$/g,\'\')},4U:h(){c 7.2e(/\\s{2,}/g,\' \').4y()},35:h(15){m 1K=7.1S(/\\d{1,3}/g);c(1K)?1K.35(15):U},3Z:h(15){m 2i=7.1S(/^#?(\\w{1,2})(\\w{1,2})(\\w{1,2})$/);c(2i)?2i.60(1).3Z(15):U},W:h(1W,s){c(s)?(s+7+s).2G(s+1W+s)>-1:7.2G(1W)>-1},6U:h(){c 7.2e(/([.*+?^${}()|[\\]\\/\\\\])/g,\'\\\\$1\')}});1s.M({35:h(15){k(7.G<3)c U;k(7.G==4&&7[3]==0&&!15)c\'6T\';m 2i=[];F(m i=0;i<3;i++){m 2F=(7[i]-0).6S(16);2i.14((2F.G==1)?\'0\'+2F:2F)}c 15?2i:\'#\'+2i.1U(\'\')},3Z:h(15){k(7.G!=3)c U;m 1K=[];F(m i=0;i<3;i++){1K.14(2L((7[i].G==1)?7[i]+7[i]:7[i],16))}c 15?1K:\'1K(\'+1K.1U(\',\')+\')\'}});4O.M({1E:h(I){m u=7;I=$2v({\'J\':u,\'r\':U,\'L\':1c,\'1u\':U,\'2s\':U,\'3i\':U},I);k($3r(I.L)&&$q(I.L)!=\'15\')I.L=[I.L];c h(r){m P;k(I.r){r=r||B.r;P=[(I.r===12)?r:T I.r(r)];k(I.L)P.M(I.L)}R P=I.L||L;m 1Y=h(){c u.2w($4Y(I.J,u),P)};k(I.1u)c 7G(1Y,I.1u);k(I.2s)c 7R(1Y,I.2s);k(I.3i)3W{c 1Y()}45(7T){c U};c 1Y()}},7P:h(P,J){c 7.1E({\'L\':P,\'J\':J})},3i:h(P,J){c 7.1E({\'L\':P,\'J\':J,\'3i\':12})()},J:h(J,P){c 7.1E({\'J\':J,\'L\':P})},7M:h(J,P){c 7.1E({\'J\':J,\'r\':12,\'L\':P})},1u:h(1u,J,P){c 7.1E({\'1u\':1u,\'J\':J,\'L\':P})()},2s:h(6o,J,P){c 7.1E({\'2s\':6o,\'J\':J,\'L\':P})()}});6n.M({28:h(){c 2L(7)},6l:h(){c 4h(7)},7O:h(2o,2J){c 1F.2o(2J,1F.2J(2o,7))},4S:h(31){31=1F.7m(10,31||0);c 1F.4S(7*31)/31},7i:h(u){F(m i=0;i<7;i++)u(i)}});m v=T 1f({1N:h(o,1e){k($q(o)==\'1W\'){k(B.1T&&1e&&(1e.1p||1e.q)){m 1p=(1e.1p)?\' 1p="\'+1e.1p+\'"\':\'\';m q=(1e.q)?\' q="\'+1e.q+\'"\':\'\';4d 1e.1p;4d 1e.q;o=\'<\'+o+1p+q+\'>\'}o=O.66(o)}o=$(o);c(!1e||!o)?o:o.2C(1e)}});m 1m=T 1f({1N:h(C){c(C)?$M(C,7):7}});1m.M=h(1e){F(m 1h 1j 1e){7.1d[1h]=1e[1h];7[1h]=$2z.3h(1h)}};h $(o){k(!o)c 1c;k(o.2A)c 1t.2y(o);k([B,O].W(o))c o;m q=$q(o);k(q==\'1W\'){o=O.3C(o);q=(o)?\'Q\':U}k(q!=\'Q\')c 1c;k(o.2A)c 1t.2y(o);k([\'2d\',\'7e\'].W(o.3L.3n()))c o;$M(o,v.1d);o.2A=h(){};c 1t.2y(o)};O.3D=O.2h;h $$(){m C=[];F(m i=0,j=L.G;i<j;i++){m 1b=L[i];1y($q(1b)){N\'Q\':C.14(1b);N\'7f\':1g;N U:1g;N\'1W\':1b=O.3D(1b,12);3U:C.M(1b)}}c $$.2M(C)};$$.2M=h(15){m C=[];F(m i=0,l=15.G;i<l;i++){k(15[i].$3l)59;m Q=$(15[i]);k(Q&&!Q.$3l){Q.$3l=12;C.14(Q)}}F(m n=0,d=C.G;n<d;n++)C[n].$3l=1c;c T 1m(C)};1m.6t=h(t){c h(){m P=L;m V=[];m C=12;F(m i=0,j=7.G,1Y;i<j;i++){1Y=7[i][t].2w(7[i],P);k($q(1Y)!=\'Q\')C=U;V.14(1Y)};c(C)?$$.2M(V):V}};v.M=h(1L){F(m t 1j 1L){2O.1d[t]=1L[t];v.1d[t]=1L[t];v[t]=$2z.3h(t);m 6L=(1s.1d[t])?t+\'1m\':t;1m.1d[6L]=1m.6t(t)}};v.M({2C:h(1e){F(m 1h 1j 1e){m 2Q=1e[1h];1y(1h){N\'54\':7.5K(2Q);1g;N\'H\':k(7.4p)7.4p(2Q);1g;N\'1L\':7.5o(2Q);1g;3U:7.34(1h,2Q)}}c 7},2j:h(o,6A){o=$(o);1y(6A){N\'5f\':o.1P.3X(7,o);1g;N\'52\':m 2V=o.5y();k(!2V)o.1P.4B(7);R o.1P.3X(7,2V);1g;N\'3M\':m 3Q=o.4F;k(3Q){o.3X(7,3Q);1g}3U:o.4B(7)}c 7},7s:h(o){c 7.2j(o,\'5f\')},5N:h(o){c 7.2j(o,\'52\')},7r:h(o){c 7.2j(o,\'5E\')},7q:h(o){c 7.2j(o,\'3M\')},5J:h(){m C=[];$1B(L,h(5b){C=C.4Z(5b)});$$(C).2j(7);c 7},2m:h(){c 7.1P.5n(7)},7p:h(5d){m o=$(7.7t(5d!==U));k(!o.$H)c o;o.$H={};F(m q 1j 7.$H)o.$H[q]={\'1i\':$A(7.$H[q].1i),\'2n\':$A(7.$H[q].2n)};c o.3g()},7u:h(o){o=$(o);7.1P.7x(o,7);c o},5m:h(23){7.4B(O.7w(23));c 7},4g:h(17){c 7.17.W(17,\' \')},58:h(17){k(!7.4g(17))7.17=(7.17+\' \'+17).4U();c 7},55:h(17){7.17=7.17.2e(T 4W(\'(^|\\\\s)\'+17+\'(?:\\\\s|$)\'),\'$1\').4U();c 7},7n:h(17){c 7.4g(17)?7.55(17):7.58(17)},2T:h(t,Y){1y(t){N\'1A\':c 7.5G(4h(Y));N\'7k\':t=(B.1T)?\'7y\':\'7z\'}t=t.4t();1y($q(Y)){N\'4i\':k(![\'7N\',\'5I\'].W(t))Y+=\'4j\';1g;N\'15\':Y=\'1K(\'+Y.1U(\',\')+\')\'}7.19[t]=Y;c 7},5K:h(26){1y($q(26)){N\'2d\':v.3f(7,\'2T\',26);1g;N\'1W\':7.19.51=26}c 7},5G:h(1A){k(1A==0){k(7.19.3u!="4c")7.19.3u="4c"}R{k(7.19.3u!="5H")7.19.3u="5H"}k(!7.36||!7.36.7Q)7.19.5I=1;k(B.1T)7.19.1O=(1A==1)?\'\':"7S(1A="+1A*7d+")";7.19.1A=7.$2g.1A=1A;c 7},1I:h(t){t=t.4t();m 18=7.19[t];k(!$3r(18)){k(t==\'1A\')c 7.$2g.1A;18=[];F(m 19 1j v.2E){k(t==19){v.2E[19].1B(h(s){m 19=7.1I(s);18.14(2L(19)?19:\'5Q\')},7);k(t==\'29\'){m 3s=18.3s(h(2F){c(2F==18[0])});c(3s)?18[0]:U}c 18.1U(\' \')}}k(t.W(\'29\')){k(v.2E.29.W(t)){c[\'5R\',\'75\',\'79\'].1V(h(p){c 7.1I(t+p)},7).1U(\' \')}R k(v.5P.W(t)){c[\'5T\',\'5k\',\'5X\',\'5W\'].1V(h(p){c 7.1I(\'29\'+p+t.2e(\'29\',\'\'))},7).1U(\' \')}}k(O.5u)18=O.5u.6V(7,1c).6X(t.5B());R k(7.36)18=7.36[t]}k(B.1T)18=v.5s(t,18,7);k(18&&t.2c(/41/i)&&18.W(\'1K\')){c 18.4C(\'1K\').3c(1,4).1V(h(41){c 41.35()}).1U(\' \')}c 18},5i:h(){c v.4s(7,\'1I\',L)},2N:h(33,1o){33+=\'72\';m o=(1o)?7[1o]:7[33];6h(o&&$q(o)!=\'Q\')o=o[33];c $(o)},8b:h(){c 7.2N(\'2b\')},5y:h(){c 7.2N(\'2V\')},9F:h(){c 7.2N(\'2V\',\'4F\')},5x:h(){c 7.2N(\'2b\',\'9B\')},9v:h(){c $(7.1P)},9S:h(){c $$(7.5C)},3R:h(o){c!!$A(7.2h(\'*\')).W(o)},3a:h(t){m 24=v.3p[t];k(24)c 7[24];m 4I=v.57[t]||0;k(!B.1T||4I)c 7.9V(t,4I);m 4H=7.9Q[t];c(4H)?4H.5v:1c},9t:h(t){m 24=v.3p[t];k(24)7[24]=\'\';R 7.9f(t);c 7},9W:h(){c v.4s(7,\'3a\',L)},34:h(t,Y){m 24=v.3p[t];k(24)7[24]=Y;R 7.9j(t,Y);c 7},5o:h(26){c v.3f(7,\'34\',26)},5t:h(){7.5p=$A(L).1U(\'\');c 7},9k:h(23){m 1Q=7.2U();k([\'19\',\'2H\'].W(1Q)){k(B.1T){k(1Q==\'19\')7.5l.51=23;R k(1Q==\'2H\')7.34(\'23\',23);c 7}R{7.5n(7.4F);c 7.5m(23)}}7[$3z(7.4V)?\'4V\':\'5q\']=23;c 7},9i:h(){m 1Q=7.2U();k([\'19\',\'2H\'].W(1Q)){k(B.1T){k(1Q==\'19\')c 7.5l.51;R k(1Q==\'2H\')c 7.3a(\'23\')}R{c 7.5p}}c($4Y(7.4V,7.5q))},2U:h(){c 7.3L.3n()},25:h(){1t.3x(7.2h(\'*\'));c 7.5t(\'\')}});v.5s=h(t,18,Q){k($3r(2L(18)))c 18;k([\'5r\',\'3E\'].W(t)){m 2n=(t==\'3E\')?[\'4A\',\'62\']:[\'3M\',\'5E\'];m 4o=0;2n.1B(h(Y){4o+=Q.1I(\'29-\'+Y+\'-3E\').28()+Q.1I(\'3S-\'+Y).28()});c Q[\'2k\'+t.5F()]-4o+\'4j\'}R k(t.2c(/29(.+)5R|1H|3S/)){c\'5Q\'}c 18};v.2E={\'29\':[],\'3S\':[],\'1H\':[]};[\'5T\',\'5k\',\'5X\',\'5W\'].1B(h(5V){F(m 19 1j v.2E)v.2E[19].14(19+5V)});v.5P=[\'9h\',\'9g\',\'9l\'];v.4s=h(o,2p,1i){m 18={};$1B(1i,h(1C){18[1C]=o[2p](1C)});c 18};v.3f=h(o,2p,4l){F(m 1C 1j 4l)o[2p](1C,4l[1C]);c o};v.3p=T 2B({\'4J\':\'17\',\'F\':\'9m\',\'9r\':\'9q\',\'9p\':\'9n\',\'9o\':\'9e\',\'9d\':\'93\',\'94\':\'92\',\'91\':\'8Z\',\'90\':\'95\',\'Y\':\'Y\',\'5M\':\'5M\',\'5L\':\'5L\',\'5Y\':\'5Y\',\'56\':\'56\'});v.57={\'96\':2,\'3J\':2};v.1G={3b:{2q:h(q,u){k(7.4e)7.4e(q,u,U);R 7.9b(\'4b\'+q,u);c 7},6m:h(q,u){k(7.53)7.53(q,u,U);R 7.9c(\'4b\'+q,u);c 7}}};B.M(v.1G.3b);O.M(v.1G.3b);v.M(v.1G.3b);m 1t={C:[],2y:h(o){k(!o.$2g){1t.C.14(o);o.$2g={\'1A\':1}}c o},3x:h(C){F(m i=0,j=C.G,o;i<j;i++){k(!(o=C[i])||!o.$2g)59;k(o.$H)o.22(\'3x\').3g();F(m p 1j o.$2g)o.$2g[p]=1c;F(m d 1j v.1d)o[d]=1c;1t.C[1t.C.2G(o)]=1c;o.2A=o.$2g=o=1c}1t.C.2m(1c)},25:h(){1t.2y(B);1t.2y(O);1t.3x(1t.C)}};B.2q(\'65\',h(){B.2q(\'4T\',1t.25);k(B.1T)B.2q(\'4T\',99)});m 1z=T 1f({1N:h(r){k(r&&r.$5a)c r;7.$5a=12;r=r||B.r;7.r=r;7.q=r.q;7.2x=r.2x||r.97;k(7.2x.3T==3)7.2x=7.2x.1P;7.5c=r.98;7.9s=r.9N;7.9O=r.9M;7.9L=r.9J;k([\'4v\',\'3y\'].W(7.q)){7.9K=(r.5j)?r.5j/9P:-(r.9U||0)/3}R k(7.q.W(\'1C\')){7.3v=r.6Q||r.9T;F(m 1p 1j 1z.1i){k(1z.1i[1p]==7.3v){7.1C=1p;1g}}k(7.q==\'61\'){m 3w=7.3v-9R;k(3w>0&&3w<13)7.1C=\'f\'+3w}7.1C=7.1C||4D.9I(7.3v).3n()}R k(7.q.2c(/(6D|9H|9y)/)){7.9z={\'x\':r.4K||r.5Z+O.6B.9x,\'y\':r.4X||r.6P+O.6B.9w};7.9u={\'x\':r.4K?r.4K-B.9G:r.5Z,\'y\':r.4X?r.4X-B.9E:r.6P};7.9C=(r.6Q==3)||(r.9D==2);1y(7.q){N\'49\':7.1k=r.1k||r.7V;1g;N\'3P\':7.1k=r.1k||r.9a}7.69()}c 7},30:h(){c 7.3j().3k()},3j:h(){k(7.r.3j)7.r.3j();R 7.r.8X=12;c 7},3k:h(){k(7.r.3k)7.r.3k();R 7.r.8Y=U;c 7}});1z.3m={1k:h(){k(7.1k&&7.1k.3T==3)7.1k=7.1k.1P},6a:h(){3W{1z.3m.1k.1x(7)}45(e){7.1k=7.2x}}};1z.1d.69=(B.47)?1z.3m.6a:1z.3m.1k;1z.1i=T 2B({\'8d\':13,\'8e\':38,\'8j\':40,\'4A\':37,\'62\':39,\'8o\':27,\'8l\':32,\'8c\':8,\'81\':9,\'4d\':46});v.1G.1M={20:h(q,u){7.$H=7.$H||{};7.$H[q]=7.$H[q]||{\'1i\':[],\'2n\':[]};k(7.$H[q].1i.W(u))c 7;7.$H[q].1i.14(u);m 3d=q;m 1q=v.1M[q];k(1q){k(1q.3Y)1q.3Y.1x(7,u);k(1q.1V)u=1q.1V;k(1q.q)3d=1q.q}k(!7.4e)u=u.1E({\'J\':7,\'r\':12});7.$H[q].2n.14(u);c(v.48.W(3d))?7.2q(3d,u):7},4u:h(q,u){k(!7.$H||!7.$H[q])c 7;m 3e=7.$H[q].1i.2G(u);k(3e==-1)c 7;m 1C=7.$H[q].1i.3c(3e,1)[0];m Y=7.$H[q].2n.3c(3e,1)[0];m 1q=v.1M[q];k(1q){k(1q.2m)1q.2m.1x(7,u);k(1q.q)q=1q.q}c(v.48.W(q))?7.6m(q,Y):7},4p:h(26){c v.3f(7,\'20\',26)},3g:h(q){k(!7.$H)c 7;k(!q){F(m 3o 1j 7.$H)7.3g(3o);7.$H=1c}R k(7.$H[q]){7.$H[q].1i.1B(h(u){7.4u(q,u)},7);7.$H[q]=1c}c 7},22:h(q,P,1u){k(7.$H&&7.$H[q]){7.$H[q].1i.1B(h(u){u.1E({\'J\':7,\'1u\':1u,\'L\':P})()},7)}c 7},64:h(1a,q){k(!1a.$H)c 7;k(!q){F(m 3o 1j 1a.$H)7.64(1a,3o)}R k(1a.$H[q]){1a.$H[q].1i.1B(h(u){7.20(q,u)},7)}c 7}};B.M(v.1G.1M);O.M(v.1G.1M);v.M(v.1G.1M);v.1M=T 2B({\'6w\':{q:\'49\',1V:h(r){r=T 1z(r);k(r.1k!=7&&!7.3R(r.1k))7.22(\'6w\',r)}},\'6s\':{q:\'3P\',1V:h(r){r=T 1z(r);k(r.1k!=7&&!7.3R(r.1k))7.22(\'6s\',r)}},\'3y\':{q:(B.47)?\'4v\':\'3y\'}});v.48=[\'6D\',\'82\',\'80\',\'7W\',\'3y\',\'4v\',\'49\',\'3P\',\'7X\',\'61\',\'7Y\',\'83\',\'68\',\'4T\',\'65\',\'84\',\'89\',\'8a\',\'86\',\'6H\',\'8N\',\'8O\',\'8M\',\'8L\',\'8J\',\'8K\',\'8P\'];4O.M({8Q:h(J,P){c 7.1E({\'J\':J,\'L\':P,\'r\':1z})}});1m.M({8V:h(1Q){c T 1m(7.1O(h(o){c(v.2U(o)==1Q)}))},6y:h(17,1r){m C=7.1O(h(o){c(o.17&&o.17.W(17,\' \'))});c(1r)?C:T 1m(C)},6v:h(2l,1r){m C=7.1O(h(o){c(o.2l==2l)});c(1r)?C:T 1m(C)},6F:h(1p,4E,Y,1r){m C=7.1O(h(o){m 1n=v.3a(o,1p);k(!1n)c U;k(!4E)c 12;1y(4E){N\'=\':c(1n==Y);N\'*=\':c(1n.W(Y));N\'^=\':c(1n.6j(0,Y.G)==Y);N\'$=\':c(1n.6j(1n.G-Y.G)==Y);N\'!=\':c(1n!=Y);N\'~=\':c 1n.W(Y,\' \')}c U});c(1r)?C:T 1m(C)}});h $E(1b,1O){c($(1O)||O).6g(1b)};h $8U(1b,1O){c($(1O)||O).3D(1b)};$$.1X={\'4x\':/^(\\w*|\\*)(?:#([\\w-]+)|\\.([\\w-]+))?(?:\\[(\\w+)(?:([!*^$]?=)["\']?([^"\'\\]]*)["\']?)?])?$/,\'2f\':{4w:h(V,1J,K,i){m 1v=[1J.8R?\'4N:\':\'\',K[1]];k(K[2])1v.14(\'[@2l="\',K[2],\'"]\');k(K[3])1v.14(\'[W(4Z(" ", @4J, " "), " \',K[3],\' ")]\');k(K[4]){k(K[5]&&K[6]){1y(K[5]){N\'*=\':1v.14(\'[W(@\',K[4],\', "\',K[6],\'")]\');1g;N\'^=\':1v.14(\'[8S-8I(@\',K[4],\', "\',K[6],\'")]\');1g;N\'$=\':1v.14(\'[8H(@\',K[4],\', 1W-G(@\',K[4],\') - \',K[6].G,\' + 1) = "\',K[6],\'"]\');1g;N\'=\':1v.14(\'[@\',K[4],\'="\',K[6],\'"]\');1g;N\'!=\':1v.14(\'[@\',K[4],\'!="\',K[6],\'"]\')}}R{1v.14(\'[@\',K[4],\']\')}}V.14(1v.1U(\'\'));c V},4P:h(V,1J,1r){m C=[];m 2f=O.6E(\'.//\'+V.1U(\'//\'),1J,$$.1X.6q,8x.8y,1c);F(m i=0,j=2f.8w;i<j;i++)C.14(2f.8v(i));c(1r)?C:T 1m(C.1V($))}},\'6f\':{4w:h(V,1J,K,i){k(i==0){k(K[2]){m o=1J.3C(K[2]);k(!o||((K[1]!=\'*\')&&(v.2U(o)!=K[1])))c U;V=[o]}R{V=$A(1J.2h(K[1]))}}R{V=$$.1X.2h(V,K[1]);k(K[2])V=1m.6v(V,K[2],12)}k(K[3])V=1m.6y(V,K[3],12);k(K[4])V=1m.6F(V,K[4],K[5],K[6],12);c V},4P:h(V,1J,1r){c(1r)?V:$$.2M(V)}},6q:h(67){c(67==\'4N\')?\'8G://8E.8D.8B/8C/4N\':U},2h:h(1J,3L){m 4L=[];F(m i=0,j=1J.G;i<j;i++)4L.M(1J[i].2h(3L));c 4L}};$$.1X.2p=(B.2f)?\'2f\':\'6f\';v.1G.43={3B:h(1b,1r){m V=[];1b=1b.4y().4C(\' \');F(m i=0,j=1b.G;i<j;i++){m 6e=1b[i];m K=6e.1S($$.1X.4x);k(!K)1g;K[1]=K[1]||\'*\';m 1v=$$.1X[$$.1X.2p].4w(V,7,K,i);k(!1v)1g;V=1v}c $$.1X[$$.1X.2p].4P(V,7,1r)},6g:h(1b){c $(7.3B(1b,12)[0]||U)},3D:h(1b,1r){m C=[];1b=1b.4C(\',\');F(m i=0,j=1b.G;i<j;i++)C=C.4Z(7.3B(1b[i],12));c(1r)?C:$$.2M(C)}};v.M({3C:h(2l){m o=O.3C(2l);k(!o)c U;F(m 1Z=o.1P;1Z!=7;1Z=1Z.1P){k(!1Z)c U}c o},8h:h(17){c 7.3B(\'.\'+17)}});O.M(v.1G.43);v.M(v.1G.43);v.1M.4k={3Y:h(u){k(B.3F){u.1x(7);c}m 2R=h(){k(B.3F)c;B.3F=12;B.1D=$42(B.1D);7.22(\'4k\')}.J(7);k(O.3I&&B.2W){B.1D=h(){k([\'3F\',\'6p\'].W(O.3I))2R()}.2s(50)}R k(O.3I&&B.1T){k(!$(\'4n\')){m 3J=(B.8F.8A==\'8z:\')?\'://0\':\'8u:8t(0)\';O.8T(\'<2H 2l="4n" 8W 3J="\'+3J+\'"><\\/2H>\');$(\'4n\').8s=h(){k(7.3I==\'6p\')2R()}}}R{B.2q("68",2R);O.2q("8r",2R)}}};B.85=h(u){c 7.20(\'4k\',u)};m 2Y={};2Y.44=T 1f({I:{6C:1f.25,3H:1f.25,6z:1f.25,6r:h(p){c-(1F.87(1F.88*p)-1)/2},4m:7Z,4z:\'4j\',6I:12,6x:50},1N:h(I){7.Q=7.Q||1c;7.4f(I);k(7.I.1N)7.I.1N.1x(7)},6M:h(){m 21=$21();k(21<7.21+7.I.4m){7.6J=7.I.6r((21-7.21)/7.I.4m);7.4q();7.4a()}R{7.30(12);7.2C(7.1w);7.22(\'3H\',7.Q,10);7.6K()}},2C:h(1w){7.2u=1w;7.4a();c 7},4q:h(){7.2u=7.3V(7.1a,7.1w)},3V:h(1a,1w){c(1w-1a)*7.6J+1a},1o:h(1a,1w){k(!7.I.6I)7.30();R k(7.1D)c 7;7.1a=1a;7.1w=1w;7.6H=7.1w-7.1a;7.21=$21();7.1D=7.6M.2s(1F.4S(8m/7.I.6x),7);7.22(\'6C\',7.Q);c 7},30:h(3N){k(!7.1D)c 7;7.1D=$42(7.1D);k(!3N)7.22(\'6z\',7.Q);c 7},1q:h(1a,1w){c 7.1o(1a,1w)},8n:h(3N){c 7.30(3N)}});2Y.44.5U(T 5h,T 1M,T 5g);2Y.8q=2Y.44.M({I:{1l:\'5S\'},1N:h(o,I){7.Q=$(o);7.2t=T v(\'8p\',{\'54\':$M(7.Q.5i(\'1H\'),{\'8k\':\'4c\'})}).5N(7.Q).5J(7.Q);7.Q.2T(\'1H\',0);7.4f(I);7.2u=[];7.1Z(7.I);7.2K=12;7.20(\'3H\',h(){7.2K=(7.2u[0]===0)});k(B.5O)7.20(\'3H\',h(){k(7.2K)7.Q.2m().2j(7.2t)})},4q:h(){F(m i=0;i<2;i++)7.2u[i]=7.3V(7.1a[i],7.1w[i])},5S:h(){7.1H=\'1H-3M\';7.2Z=\'5r\';7.2k=7.Q.5D},8f:h(){7.1H=\'1H-4A\';7.2Z=\'3E\';7.2k=7.Q.5A},5z:h(1l){7[1l||7.I.1l]();c 7.1o([7.Q.1I(7.1H).28(),7.2t.1I(7.2Z).28()],[0,7.2k])},5w:h(1l){7[1l||7.I.1l]();c 7.1o([7.Q.1I(7.1H).28(),7.2t.1I(7.2Z).28()],[-7.2k,0])},8g:h(1l){7[1l||7.I.1l]();7.2K=U;c 7.2C([-7.2k,0])},8i:h(1l){7[1l||7.I.1l]();7.2K=12;c 7.2C([0,7.2k])},9A:h(1l){k(7.2t.5D==0||7.2t.5A==0)c 7.5z(1l);c 7.5w(1l)},4a:h(){7.Q.2T(7.1H,7.2u[0]+7.I.4z);7.2t.2T(7.2Z,7.2u[1]+7.I.4z)}});',62,617,'|||||||this|||||return|||||function|||if||var||el||type|event||property|fn|Element||||||window|elements|||for|length|events|options|bind|param|arguments|extend|case|document|args|element|else||new|false|items|contains|obj|value||||true||push|array||className|result|style|from|selector|null|prototype|props|Class|break|prop|keys|in|relatedTarget|mode|Elements|current|start|name|custom|nocash|Array|Garbage|delay|temp|to|call|switch|Event|opacity|each|key|timer|create|Math|Methods|margin|getStyle|context|rgb|properties|Events|initialize|filter|parentNode|tag|item|match|ie|join|map|string|shared|returns|parent|addEvent|time|fireEvent|text|index|empty|source||toInt|border|iterable|previous|test|object|replace|xpath|tmp|getElementsByTagName|hex|inject|offset|id|remove|values|min|method|addListener|chains|periodical|wrapper|now|merge|apply|target|collect|native|htmlElement|Abstract|set|results|Styles|bit|indexOf|script|len|max|open|parseInt|unique|walk|HTMLElement|klass|val|domReady|option|setStyle|getTag|next|webkit|mix|Fx|layout|stop|precision||brother|setProperty|rgbToHex|currentStyle||||getProperty|Listeners|splice|realType|pos|setMany|removeEvents|generic|attempt|stopPropagation|preventDefault|included|fix|toLowerCase|evType|Properties|forEach|chk|every|regex|visibility|code|fKey|trash|mousewheel|defined|typeof|getElements|getElementById|getElementsBySelector|width|loaded|mp|onComplete|readyState|src|ap|tagName|top|end|proto|mouseout|first|hasChild|padding|nodeType|default|compute|try|insertBefore|add|hexToRgb||color|clear|Dom|Base|catch||gecko|NativeEvents|mouseover|increase|on|hidden|delete|addEventListener|setOptions|hasClass|parseFloat|number|px|domready|pairs|duration|ie_ready|size|addEvents|setNow|merged|getMany|camelCase|removeEvent|DOMMouseScroll|getParam|regexp|trim|unit|left|appendChild|split|String|operator|firstChild|newArray|node|flag|class|pageX|found|include|xhtml|Function|getItems|random|charAt|round|unload|clean|innerText|RegExp|pageY|pick|concat||cssText|after|removeEventListener|styles|removeClass|selected|PropertiesIFlag|addClass|continue|extended|argument|shift|contents|picked|before|Options|Chain|getStyles|wheelDelta|Right|styleSheet|appendText|removeChild|setProperties|innerHTML|textContent|height|fixStyle|setHTML|defaultView|nodeValue|slideOut|getLast|getNext|slideIn|offsetWidth|hyphenate|childNodes|offsetHeight|bottom|capitalize|setOpacity|visible|zoom|adopt|setStyles|checked|disabled|injectAfter|webkit419|borderShort|0px|Width|vertical|Top|implement|direction|Left|Bottom|multiple|clientX|slice|keydown|right|head|cloneEvents|beforeunload|createElement|prefix|load|fixRelatedTarget|relatedTargetGecko|constructor|toUpperCase|params|sel|normal|getElement|while|copy|substr|ie6|toFloat|removeListener|Number|interval|complete|resolver|transition|mouseleave|Multi|callee|filterById|mouseenter|fps|filterByClass|onCancel|where|documentElement|onStart|click|evaluate|filterByAttribute|pp|change|wait|delta|callChain|elementsProperty|step|undefined|Merge|clientY|which|DOMElement|toString|transparent|escapeRegExp|getComputedStyle|clearChain|getPropertyValue|some|chain|version|MooTools|Sibling|BackgroundImageCache|execCommand|Style|whitespace|getRandom|associate|Color|nodeName|textnode|collection|100|embed|boolean|clearInterval|clearTimeout|times|Window|float|Document|pow|toggleClass|floor|clone|injectTop|injectInside|injectBefore|cloneNode|replaceWith|getTime|createTextNode|replaceChild|styleFloat|cssFloat|taintEnabled|navigator|all|Date|webkit420|getBoxObjectFor|setTimeout|Object|khtml|ie7|XMLHttpRequest|ActiveXObject|bindAsEventListener|zIndex|limit|pass|hasLayout|setInterval|alpha|err|iframe|fromElement|mousedown|mousemove|keypress|500|mouseup|tab|dblclick|keyup|resize|onDomReady|blur|cos|PI|move|focus|getPrevious|backspace|enter|up|horizontal|hide|getElementsByClassName|show|down|overflow|space|1000|clearTimer|esc|div|Slide|DOMContentLoaded|onreadystatechange|void|javascript|snapshotItem|snapshotLength|XPathResult|UNORDERED_NODE_SNAPSHOT_TYPE|https|protocol|org|1999|w3|www|location|http|substring|with|abort|contextmenu|error|select|submit|reset|scroll|bindWithEvent|namespaceURI|starts|write|ES|filterByTag|defer|cancelBubble|returnValue|readOnly|frameborder|readonly|maxLength|tabIndex|maxlength|frameBorder|href|srcElement|shiftKey|CollectGarbage|toElement|attachEvent|detachEvent|tabindex|accessKey|removeAttribute|borderStyle|borderWidth|getText|setAttribute|setText|borderColor|htmlFor|rowSpan|accesskey|rowspan|colSpan|colspan|control|removeProperty|client|getParent|scrollTop|scrollLeft|menu|page|toggle|lastChild|rightClick|button|pageYOffset|getFirst|pageXOffset|mouse|fromCharCode|metaKey|wheel|meta|altKey|ctrlKey|alt|120|attributes|111|getChildren|keyCode|detail|getAttribute|getProperties'.split('|'),0,{}))
