function ImageFlow()
{this.defaults={animationSpeed:50,aspectRatio:1.964,buttons:false,captions:true,circular:false,imageCursor:'default',ImageFlowID:'imageflow',imageFocusM:1.0,imageFocusMax:4,imagePath:'',imageScaling:true,imagesHeight:0.67,imagesM:1.0,onClick:function(){document.location=this.url;},opacity:false,opacityArray:[10,8,6,4,2],percentLandscape:118,percentOther:100,preloadImages:true,reflections:true,reflectionGET:'',reflectionP:0.5,reflectionPNG:false,reflectPath:'',scrollbarP:0.6,slider:true,sliderCursor:'e-resize',sliderWidth:14,slideshow:false,slideshowSpeed:1500,slideshowAutoplay:false,startID:1,glideToStartID:true,startAnimation:false,xStep:150,onPrimaryImageChange:function(){alert('primary image');}};var my=this;this.init=function(options)
{for(var name in my.defaults)
{this[name]=(options!==undefined&&options[name]!==undefined)?options[name]:my.defaults[name];}
var ImageFlowDiv=document.getElementById(my.ImageFlowID);if(ImageFlowDiv)
{ImageFlowDiv.style.visibility='visible';this.ImageFlowDiv=ImageFlowDiv;if(this.createStructure())
{this.imagesDiv=document.getElementById(my.ImageFlowID+'_images');this.captionDiv=document.getElementById(my.ImageFlowID+'_caption');this.navigationDiv=document.getElementById(my.ImageFlowID+'_navigation');this.scrollbarDiv=document.getElementById(my.ImageFlowID+'_scrollbar');this.sliderDiv=document.getElementById(my.ImageFlowID+'_slider');this.buttonNextDiv=document.getElementById(my.ImageFlowID+'_next');this.buttonPreviousDiv=document.getElementById(my.ImageFlowID+'_previous');this.buttonSlideshow=document.getElementById(my.ImageFlowID+'_slideshow');this.indexArray=[];this.current=0;this.imageID=0;this.target=0;this.memTarget=0;this.firstRefresh=true;this.firstCheck=true;this.busy=false;var width=this.ImageFlowDiv.offsetWidth;var height=Math.round(width/my.aspectRatio);document.getElementById(my.ImageFlowID+'_loading_txt').style.paddingTop=((height*0.5)-22)+'px';ImageFlowDiv.style.height=height+'px';this.loadingProgress();}}};this.createStructure=function()
{var imagesDiv=my.Helper.createDocumentElement('div','images');var node,version,src,imageNode;var max=my.ImageFlowDiv.childNodes.length;for(var index=0;index<max;index++)
{node=my.ImageFlowDiv.childNodes[index];if(node&&node.nodeType==1&&node.nodeName=='IMG')
{if(my.reflections===true)
{version=(my.reflectionPNG)?'3':'2';src=my.imagePath+node.getAttribute('src',2);src=my.reflectPath+'reflect'+version+'.php?img='+src+my.reflectionGET;node.setAttribute('src',src);}
imageNode=node.cloneNode(true);imagesDiv.appendChild(imageNode);}}
if(my.circular)
{var first=my.Helper.createDocumentElement('div','images');var last=my.Helper.createDocumentElement('div','images');max=imagesDiv.childNodes.length;if(max<my.imageFocusMax)
{my.imageFocusMax=max;}
if(max>1)
{var i;for(i=0;i<max;i++)
{node=imagesDiv.childNodes[i];if(i<my.imageFocusMax)
{imageNode=node.cloneNode(true);first.appendChild(imageNode);}
if(max-i<my.imageFocusMax+1)
{imageNode=node.cloneNode(true);last.appendChild(imageNode);}}
for(i=0;i<max;i++)
{node=imagesDiv.childNodes[i];imageNode=node.cloneNode(true);last.appendChild(imageNode);}
for(i=0;i<my.imageFocusMax;i++)
{node=first.childNodes[i];imageNode=node.cloneNode(true);last.appendChild(imageNode);}
imagesDiv=last;}}
if(my.slideshow)
{var slideshowButton=my.Helper.createDocumentElement('div','slideshow');imagesDiv.appendChild(slideshowButton);}
var loadingP=my.Helper.createDocumentElement('p','loading_txt');var loadingText=document.createTextNode(' ');loadingP.appendChild(loadingText);var loadingDiv=my.Helper.createDocumentElement('div','loading');var loadingBarDiv=my.Helper.createDocumentElement('div','loading_bar');loadingDiv.appendChild(loadingBarDiv);var captionDiv=my.Helper.createDocumentElement('div','caption');var scrollbarDiv=my.Helper.createDocumentElement('div','scrollbar');var sliderDiv=my.Helper.createDocumentElement('div','slider');scrollbarDiv.appendChild(sliderDiv);if(my.buttons)
{var buttonPreviousDiv=my.Helper.createDocumentElement('div','previous','button');var buttonNextDiv=my.Helper.createDocumentElement('div','next','button');scrollbarDiv.appendChild(buttonPreviousDiv);scrollbarDiv.appendChild(buttonNextDiv);}
var navigationDiv=my.Helper.createDocumentElement('div','navigation');navigationDiv.appendChild(captionDiv);navigationDiv.appendChild(scrollbarDiv);var success=false;if(my.ImageFlowDiv.appendChild(imagesDiv)&&my.ImageFlowDiv.appendChild(loadingP)&&my.ImageFlowDiv.appendChild(loadingDiv)&&my.ImageFlowDiv.appendChild(navigationDiv))
{max=my.ImageFlowDiv.childNodes.length;for(index=0;index<max;index++)
{node=my.ImageFlowDiv.childNodes[index];if(node&&node.nodeType==1&&node.nodeName=='IMG')
{my.ImageFlowDiv.removeChild(node);}}
success=true;}
return success;};this.loadingProgress=function()
{var p=my.loadingStatus();if((p<100||my.firstCheck)&&my.preloadImages)
{if(my.firstCheck&&p==100)
{my.firstCheck=false;window.setTimeout(my.loadingProgress,100);}
else
{window.setTimeout(my.loadingProgress,40);}}
else
{document.getElementById(my.ImageFlowID+'_loading_txt').style.display='none';document.getElementById(my.ImageFlowID+'_loading').style.display='none';window.setTimeout(my.Helper.addResizeEvent,1000);my.refresh();if(my.max>1)
{my.MouseWheel.init();my.MouseDrag.init();my.Touch.init();my.Key.init();if(my.slideshow)
{my.Slideshow.init();}
if(my.slider)
{my.scrollbarDiv.style.visibility='visible';}}}};this.loadingStatus=function()
{var max=my.imagesDiv.childNodes.length;var i=0,completed=0;var image=null;for(var index=0;index<max;index++)
{image=my.imagesDiv.childNodes[index];if(image&&image.nodeType==1&&image.nodeName=='IMG')
{if(image.complete)
{completed++;}
i++;}}
var finished=Math.round((completed/i)*100);var loadingBar=document.getElementById(my.ImageFlowID+'_loading_bar');loadingBar.style.width=finished+'%';if(my.circular)
{i=i-(my.imageFocusMax*2);completed=(finished<1)?0:Math.round((i/100)*finished);}
var loadingP=document.getElementById(my.ImageFlowID+'_loading_txt');var loadingTxt=document.createTextNode('loading images '+completed+'/'+i);loadingP.replaceChild(loadingTxt,loadingP.firstChild);return finished;};this.refresh=function()
{this.imagesDivWidth=my.imagesDiv.offsetWidth+my.imagesDiv.offsetLeft;this.maxHeight=Math.round(my.imagesDivWidth/my.aspectRatio);this.maxFocus=my.imageFocusMax*my.xStep;this.size=my.imagesDivWidth*0.5;this.sliderWidth=my.sliderWidth*0.5;this.scrollbarWidth=(my.imagesDivWidth-(Math.round(my.sliderWidth)*2))*my.scrollbarP;this.imagesDivHeight=Math.round(my.maxHeight*my.imagesHeight);my.ImageFlowDiv.style.height=my.maxHeight+'px';my.imagesDiv.style.height=my.imagesDivHeight+'px';my.navigationDiv.style.height=(my.maxHeight-my.imagesDivHeight)+'px';my.captionDiv.style.width=my.imagesDivWidth+'px';my.captionDiv.style.paddingTop=Math.round(my.imagesDivWidth*0.02)+'px';my.scrollbarDiv.style.width=my.scrollbarWidth+'px';my.scrollbarDiv.style.marginTop=Math.round(my.imagesDivWidth*0.02)+'px';my.scrollbarDiv.style.marginLeft=Math.round(my.sliderWidth+((my.imagesDivWidth-my.scrollbarWidth)/2))+'px';my.sliderDiv.style.cursor=my.sliderCursor;my.sliderDiv.onmousedown=function(){my.MouseDrag.start(this);return false;};if(my.buttons)
{my.buttonPreviousDiv.onclick=function(){my.MouseWheel.handle(1);};my.buttonNextDiv.onclick=function(){my.MouseWheel.handle(-1);};}
var multi=(my.reflections===true)?my.reflectionP+1:1;var max=my.imagesDiv.childNodes.length;var i=0;var image=null;for(var index=0;index<max;index++)
{image=my.imagesDiv.childNodes[index];if(image!==null&&image.nodeType==1&&image.nodeName=='IMG')
{this.indexArray[i]=index;image.url=image.getAttribute('longdesc');image.xPosition=(-i*my.xStep);image.i=i;if(my.firstRefresh)
{if(image.getAttribute('width')!==null&&image.getAttribute('height')!==null)
{image.w=image.getAttribute('width');image.h=image.getAttribute('height')*multi;}
else{image.w=image.width;image.h=image.height;}}
if((image.w)>(image.h/(my.reflectionP+1)))
{image.pc=my.percentLandscape;image.pcMem=my.percentLandscape;}
else
{image.pc=my.percentOther;image.pcMem=my.percentOther;}
if(my.imageScaling===false)
{image.style.position='relative';image.style.display='inline';}
image.style.cursor=my.imageCursor;i++;}}
this.max=my.indexArray.length;if(my.imageScaling===false)
{image=my.imagesDiv.childNodes[my.indexArray[0]];this.totalImagesWidth=image.w*my.max;image.style.paddingLeft=(my.imagesDivWidth/2)+(image.w/2)+'px';my.imagesDiv.style.height=image.h+'px';my.navigationDiv.style.height=(my.maxHeight-image.h)+'px';}
if(my.firstRefresh)
{my.firstRefresh=false;my.imageID=my.startID-1;if(my.imageID<0)
{my.imageID=0;}
if(my.circular)
{my.imageID=my.imageID+my.imageFocusMax;}
maxId=(my.circular)?(my.max-(my.imageFocusMax))-1:my.max-1;if(my.imageID>maxId)
{my.imageID=maxId;}
if(my.glideToStartID===false)
{my.moveTo(-my.imageID*my.xStep);}
if(my.startAnimation)
{my.moveTo(5000);}}
if(my.max>1)
{my.glideTo(my.imageID);}
my.moveTo(my.current);};this.moveTo=function(x)
{this.current=x;this.zIndex=my.max;for(var index=0;index<my.max;index++)
{var image=my.imagesDiv.childNodes[my.indexArray[index]];var currentImage=index*-my.xStep;if(my.imageScaling)
{if((currentImage+my.maxFocus)<my.memTarget||(currentImage-my.maxFocus)>my.memTarget)
{image.style.visibility='hidden';image.style.display='none';}
else
{var z=(Math.sqrt(10000+x*x)+100)*my.imagesM;var xs=x/z*my.size+my.size;image.style.display='block';var newImageH=(image.h/image.w*image.pc)/z*my.size;var newImageW=0;switch(newImageH>my.maxHeight)
{case false:newImageW=image.pc/z*my.size;break;default:newImageH=my.maxHeight;newImageW=image.w*newImageH/image.h;break;}
var newImageTop=(my.imagesDivHeight-newImageH)+((newImageH/(my.reflectionP+1))*my.reflectionP);image.style.left=xs-(image.pc/2)/z*my.size+'px';if(newImageW&&newImageH)
{image.style.height=newImageH+'px';image.style.width=newImageW+'px';image.style.top=newImageTop+'px';}
image.style.visibility='visible';switch(x<0)
{case true:this.zIndex++;break;default:this.zIndex=my.zIndex-1;break;}
switch(image.i==my.imageID)
{case false:image.onclick=function(){my.glideTo(this.i);};break;default:this.zIndex=my.zIndex+1;if(image.url!=='')
{image.onclick=my.onClick;}
break;}
image.style.zIndex=my.zIndex;}}
else
{if((currentImage+my.maxFocus)<my.memTarget||(currentImage-my.maxFocus)>my.memTarget)
{image.style.visibility='hidden';}
else
{image.style.visibility='visible';switch(image.i==my.imageID)
{case false:image.onclick=function(){my.glideTo(this.i);};break;default:if(image.url!=='')
{image.onclick=my.onClick;}
break;}}
my.imagesDiv.style.marginLeft=(x-my.totalImagesWidth)+'px';}
x+=my.xStep;}};this.glideTo=function(imageID)
{var jumpTarget,clonedImageID;if(my.circular)
{if(imageID+1===my.imageFocusMax)
{clonedImageID=my.max-my.imageFocusMax;jumpTarget=-clonedImageID*my.xStep;imageID=clonedImageID-1;}
if(imageID===(my.max-my.imageFocusMax))
{clonedImageID=my.imageFocusMax-1;jumpTarget=-clonedImageID*my.xStep;imageID=clonedImageID+1;}}
var x=-imageID*my.xStep;this.target=x;this.memTarget=x;this.imageID=imageID;var caption=my.imagesDiv.childNodes[imageID].getAttribute('alt');if(caption===''||my.captions===false)
{caption=' ';if(my.onPrimaryImageChange!=null)
{my.onPrimaryImageChange(imageID);}}
my.captionDiv.innerHTML=caption;if(my.MouseDrag.busy===false)
{if(my.circular)
{this.newSliderX=((imageID-my.imageFocusMax)*my.scrollbarWidth)/(my.max-(my.imageFocusMax*2)-1)-my.MouseDrag.newX;}
else
{this.newSliderX=(imageID*my.scrollbarWidth)/(my.max-1)-my.MouseDrag.newX;}
my.sliderDiv.style.marginLeft=(my.newSliderX-my.sliderWidth)+'px';}
if(my.opacity===true||my.imageFocusM!==my.defaults.imageFocusM)
{my.Helper.setOpacity(my.imagesDiv.childNodes[imageID],my.opacityArray[0]);my.imagesDiv.childNodes[imageID].pc=my.imagesDiv.childNodes[imageID].pc*my.imageFocusM;var opacityValue=0;var rightID=0;var leftID=0;var last=my.opacityArray.length;for(var i=1;i<(my.imageFocusMax+1);i++)
{if((i+1)>last)
{opacityValue=my.opacityArray[last-1];}
else
{opacityValue=my.opacityArray[i];}
rightID=imageID+i;leftID=imageID-i;if(rightID<my.max)
{my.Helper.setOpacity(my.imagesDiv.childNodes[rightID],opacityValue);my.imagesDiv.childNodes[rightID].pc=my.imagesDiv.childNodes[rightID].pcMem;}
if(leftID>=0)
{my.Helper.setOpacity(my.imagesDiv.childNodes[leftID],opacityValue);my.imagesDiv.childNodes[leftID].pc=my.imagesDiv.childNodes[leftID].pcMem;}}}
if(jumpTarget)
{my.moveTo(jumpTarget);}
if(my.busy===false)
{my.busy=true;my.animate();}};this.animate=function()
{switch(my.target<my.current-1||my.target>my.current+1)
{case true:my.moveTo(my.current+(my.target-my.current)/3);window.setTimeout(my.animate,my.animationSpeed);my.busy=true;break;default:my.busy=false;break;}};this.glideOnEvent=function(imageID)
{if(my.slideshow)
{my.Slideshow.interrupt();}
my.glideTo(imageID);};this.Slideshow={direction:1,init:function()
{(my.slideshowAutoplay)?my.Slideshow.start():my.Slideshow.stop();},interrupt:function()
{my.Helper.removeEvent(my.ImageFlowDiv,'click',my.Slideshow.interrupt);my.Slideshow.stop();},addInterruptEvent:function()
{my.Helper.addEvent(my.ImageFlowDiv,'click',my.Slideshow.interrupt);},start:function()
{my.Helper.setClassName(my.buttonSlideshow,'slideshow pause');my.buttonSlideshow.onclick=function(){my.Slideshow.stop();};my.Slideshow.action=window.setInterval(my.Slideshow.slide,my.slideshowSpeed);window.setTimeout(my.Slideshow.addInterruptEvent,100);},stop:function()
{my.Helper.setClassName(my.buttonSlideshow,'slideshow play');my.buttonSlideshow.onclick=function(){my.Slideshow.start();};window.clearInterval(my.Slideshow.action);},slide:function()
{var newImageID=my.imageID+my.Slideshow.direction;var reverseDirection=false;if(newImageID===my.max)
{my.Slideshow.direction=-1;reverseDirection=true;}
if(newImageID<0)
{my.Slideshow.direction=1;reverseDirection=true;}
(reverseDirection)?my.Slideshow.slide():my.glideTo(newImageID);}};this.MouseWheel={init:function()
{if(window.addEventListener)
{my.ImageFlowDiv.addEventListener('DOMMouseScroll',my.MouseWheel.get,false);}
my.Helper.addEvent(my.ImageFlowDiv,'mousewheel',my.MouseWheel.get);},get:function(event)
{var delta=0;if(!event)
{event=window.event;}
if(event.wheelDelta)
{delta=event.wheelDelta/120;}
else if(event.detail)
{delta=-event.detail/3;}
if(delta)
{my.MouseWheel.handle(delta);}
my.Helper.suppressBrowserDefault(event);},handle:function(delta)
{var change=false;var newImageID=0;if(delta>0)
{if(my.imageID>=1)
{newImageID=my.imageID-1;change=true;}}
else
{if(my.imageID<(my.max-1))
{newImageID=my.imageID+1;change=true;}}
if(change)
{my.glideOnEvent(newImageID);}}};this.MouseDrag={object:null,objectX:0,mouseX:0,newX:0,busy:false,init:function()
{my.Helper.addEvent(my.ImageFlowDiv,'mousemove',my.MouseDrag.drag);my.Helper.addEvent(my.ImageFlowDiv,'mouseup',my.MouseDrag.stop);my.Helper.addEvent(document,'mouseup',my.MouseDrag.stop);my.ImageFlowDiv.onselectstart=function()
{var selection=true;if(my.MouseDrag.busy)
{selection=false;}
return selection;};},start:function(o)
{my.MouseDrag.object=o;my.MouseDrag.objectX=my.MouseDrag.mouseX-o.offsetLeft+my.newSliderX;},stop:function()
{my.MouseDrag.object=null;my.MouseDrag.busy=false;},drag:function(e)
{var posx=0;if(!e)
{e=window.event;}
if(e.pageX)
{posx=e.pageX;}
else if(e.clientX)
{posx=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;}
my.MouseDrag.mouseX=posx;if(my.MouseDrag.object!==null)
{var newX=(my.MouseDrag.mouseX-my.MouseDrag.objectX)+my.sliderWidth;if(newX<(-my.newSliderX))
{newX=-my.newSliderX;}
if(newX>(my.scrollbarWidth-my.newSliderX))
{newX=my.scrollbarWidth-my.newSliderX;}
var step,imageID;if(my.circular)
{step=(newX+my.newSliderX)/(my.scrollbarWidth/(my.max-(my.imageFocusMax*2)-1));imageID=Math.round(step)+my.imageFocusMax;}
else
{step=(newX+my.newSliderX)/(my.scrollbarWidth/(my.max-1));imageID=Math.round(step);}
my.MouseDrag.newX=newX;my.MouseDrag.object.style.left=newX+'px';if(my.imageID!==imageID)
{my.glideOnEvent(imageID);}
my.MouseDrag.busy=true;}}};this.Touch={x:0,startX:0,stopX:0,busy:false,first:true,init:function()
{my.Helper.addEvent(my.navigationDiv,'touchstart',my.Touch.start);my.Helper.addEvent(document,'touchmove',my.Touch.handle);my.Helper.addEvent(document,'touchend',my.Touch.stop);},isOnNavigationDiv:function(e)
{var state=false;if(e.touches)
{var target=e.touches[0].target;if(target===my.navigationDiv||target===my.sliderDiv||target===my.scrollbarDiv)
{state=true;}}
return state;},getX:function(e)
{var x=0;if(e.touches)
{x=e.touches[0].pageX;}
return x;},start:function(e)
{my.Touch.startX=my.Touch.getX(e);my.Touch.busy=true;my.Helper.suppressBrowserDefault(e);},isBusy:function()
{var busy=false;if(my.Touch.busy)
{busy=true;}
return busy;},handle:function(e)
{if(my.Touch.isBusy&&my.Touch.isOnNavigationDiv(e))
{var max=(my.circular)?(my.max-(my.imageFocusMax*2)-1):(my.max-1);if(my.Touch.first)
{my.Touch.stopX=(max-my.imageID)*(my.imagesDivWidth/max);my.Touch.first=false;}
var newX=-(my.Touch.getX(e)-my.Touch.startX-my.Touch.stopX);if(newX<0)
{newX=0;}
if(newX>my.imagesDivWidth)
{newX=my.imagesDivWidth;}
my.Touch.x=newX;var imageID=Math.round(newX/(my.imagesDivWidth/max));imageID=max-imageID;if(my.imageID!==imageID)
{if(my.circular)
{imageID=imageID+my.imageFocusMax;}
my.glideOnEvent(imageID);}
my.Helper.suppressBrowserDefault(e);}},stop:function()
{my.Touch.stopX=my.Touch.x;my.Touch.busy=false;}};this.Key={init:function()
{document.onkeydown=function(event){my.Key.handle(event);};},handle:function(event)
{var charCode=my.Key.get(event);switch(charCode)
{case 39:my.MouseWheel.handle(-1);break;case 37:my.MouseWheel.handle(1);break;}},get:function(event)
{event=event||window.event;return event.keyCode;}};this.Helper={addEvent:function(obj,type,fn)
{if(obj.addEventListener)
{obj.addEventListener(type,fn,false);}
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]);}},removeEvent:function(obj,type,fn)
{if(obj.removeEventListener)
{obj.removeEventListener(type,fn,false);}
else if(obj.detachEvent)
{if(obj[type+fn]===undefined)
{alert('Helper.removeEvent » Pointer to detach event is undefined - perhaps you are trying to detach an unattached event?');}
obj.detachEvent('on'+type,obj[type+fn]);obj[type+fn]=null;obj['e'+type+fn]=null;}},setOpacity:function(object,value)
{if(my.opacity===true)
{object.style.opacity=value/10;object.style.filter='alpha(opacity='+value*10+')';}},createDocumentElement:function(type,id,optionalClass)
{var element=document.createElement(type);element.setAttribute('id',my.ImageFlowID+'_'+id);if(optionalClass!==undefined)
{id+=' '+optionalClass;}
my.Helper.setClassName(element,id);return element;},setClassName:function(element,className)
{if(element)
{element.setAttribute('class',className);element.setAttribute('className',className);}},suppressBrowserDefault:function(e)
{if(e.preventDefault)
{e.preventDefault();}
else
{e.returnValue=false;}
return false;},addResizeEvent:function()
{var otherFunctions=window.onresize;if(typeof window.onresize!='function')
{window.onresize=function()
{my.refresh();};}
else
{window.onresize=function(){if(otherFunctions)
{otherFunctions();}
my.refresh();};}}};}
var domReadyEvent={name:"domReadyEvent",events:{},domReadyID:1,bDone:false,DOMContentLoadedCustom:null,add:function(handler)
{if(!handler.$$domReadyID)
{handler.$$domReadyID=this.domReadyID++;if(this.bDone)
{handler();}
this.events[handler.$$domReadyID]=handler;}},remove:function(handler)
{if(handler.$$domReadyID)
{delete this.events[handler.$$domReadyID];}},run:function()
{if(this.bDone)
{return;}
this.bDone=true;for(var i in this.events)
{this.events[i]();}},schedule:function()
{if(this.bDone)
{return;}
if(/KHTML|WebKit/i.test(navigator.userAgent))
{if(/loaded|complete/.test(document.readyState))
{this.run();}
else
{setTimeout(this.name+".schedule()",100);}}
else if(document.getElementById("__ie_onload"))
{return true;}
if(typeof this.DOMContentLoadedCustom==="function")
{if(typeof document.getElementsByTagName!=='undefined'&&(document.getElementsByTagName('body')[0]!==null||document.body!==null))
{if(this.DOMContentLoadedCustom())
{this.run();}
else
{setTimeout(this.name+".schedule()",250);}}}
return true;},init:function()
{if(document.addEventListener)
{document.addEventListener("DOMContentLoaded",function(){domReadyEvent.run();},false);}
setTimeout("domReadyEvent.schedule()",100);function run()
{domReadyEvent.run();}
if(typeof addEvent!=="undefined")
{addEvent(window,"load",run);}
else if(document.addEventListener)
{document.addEventListener("load",run,false);}
else if(typeof window.onload==="function")
{var oldonload=window.onload;window.onload=function()
{domReadyEvent.run();oldonload();};}
else
{window.onload=run;}}};var domReady=function(handler){domReadyEvent.add(handler);};domReadyEvent.init();
/*
  Watermark v3.0.6 (June 21, 2010) plugin for jQuery
  http://jquery-watermark.googlecode.com/
  Copyright (c) 2009-2010 Todd Northrop
  http://www.speednet.biz/
  Dual licensed under the MIT or GPL Version 2 licenses.
*/
/*(function(b){var l="function",j="password",d="maxLength",f="type",c=true,a="",e=false,t="watermark",u,m=t,i="watermarkClass",q="watermarkFocus",k="watermarkSubmit",o="watermarkMaxLength",h="watermarkPassword",g="watermarkText",s=":data("+m+")",n=":text,:password,:search,textarea",p=["Page_ClientValidate"],r=e;b.extend(b.expr[":"],{search:function(b){return "search"===(b.type||a)},data:function(g,i,h){var f,d=/^((?:[^=!^$*]|[!^$*](?!=))+)(?:([!^$*]?=)(.*))?$/.exec(h[3]);if(d){f=b(g).data(d[1]);if(f!==u){if(d[2]){f=a+f;switch(d[2]){case "=":return f==d[3];case "!=":return f!=d[3];case "^=":return f.slice(0,d[3].length)==d[3];case "$=":return f.slice(-d[3].length)==d[3];case "*=":return f.indexOf(d[3])!==-1}}return c}}return e}});b.watermark={version:"3.0.6",options:{className:t,useNative:c},hide:function(a){b(a).filter(s).each(function(){b.watermark._hide(b(this))})},_hide:function(b,n){var m=b.val()||a,k=b.data(g)||a,l=b.data(o)||0,j=b.data(i);if(k.length&&m==k){b.val(a);if(b.data(h))if((b.attr(f)||a)==="text"){var e=b.data(h)||[],c=b.parent()||[];if(e.length&&c.length){c[0].removeChild(b[0]);c[0].appendChild(e[0]);b=e}}if(l){b.attr(d,l);b.removeData(o)}if(n){b.attr("autocomplete","off");window.setTimeout(function(){b.select()},1)}}j&&b.removeClass(j)},show:function(a){b(a).filter(s).each(function(){b.watermark._show(b(this))})},_show:function(e){var t=e.val()||a,k=e.data(g)||a,p=e.attr(f)||a,s=e.data(i);if((t.length==0||t==k)&&!e.data(q)){r=c;if(e.data(h))if(p===j){var n=e.data(h)||[],m=e.parent()||[];if(n.length&&m.length){m[0].removeChild(e[0]);m[0].appendChild(n[0]);e=n;e.attr(d,k.length)}}if(p==="text"||p==="search"){var l=e.attr(d)||0;if(l>0&&k.length>l){e.data(o,l);e.attr(d,k.length)}}s&&e.addClass(s);e.val(k)}else b.watermark._hide(e)},hideAll:function(){if(r){b.watermark.hide(n);r=e}},showAll:function(){b.watermark.show(n)}};b.fn.watermark=function(r,o){var p="string";if(!this.length)return this;var s=e,t=typeof r===p;if(typeof o==="object"){s=typeof o.className===p;o=b.extend({},b.watermark.options,o)}else if(typeof o===p){s=c;o=b.extend({},b.watermark.options,{className:o})}else o=b.watermark.options;if(typeof o.useNative!==l)o.useNative=o.useNative?function(){return c}:function(){return e};return this.each(function(){var v="dragleave",u="dragenter",x=this,e=b(x);if(!e.is(n))return;if(e.data(m)){if(t||s){b.watermark._hide(e);t&&e.data(g,r);s&&e.data(i,o.className)}}else{if(o.useNative.call(x,e))if((a+e.css("-webkit-appearance")).replace("undefined",a)!==a&&(e.attr("tagName")||a)!=="TEXTAREA"){t&&e.attr("placeholder",r);return}e.data(g,t?r:a);e.data(i,o.className);e.data(m,1);if((e.attr(f)||a)===j){var y=e.wrap("<span>").parent(),l=b(y.html().replace(/type=["']?password["']?/i,'type="text"'));l.data(g,e.data(g));l.data(i,e.data(i));l.data(m,1);l.attr(d,r.length);l.focus(function(){b.watermark._hide(l,c)}).bind(u,function(){b.watermark._hide(l)}).bind("dragend",function(){window.setTimeout(function(){l.blur()},1)});e.blur(function(){b.watermark._show(e)}).bind(v,function(){b.watermark._show(e)});l.data(h,e);e.data(h,l)}else e.focus(function(){e.data(q,1);b.watermark._hide(e,c)}).blur(function(){e.data(q,0);b.watermark._show(e)}).bind(u,function(){b.watermark._hide(e)}).bind(v,function(){b.watermark._show(e)}).bind("dragend",function(){window.setTimeout(function(){b.watermark._show(e)},1)}).bind("drop",function(c){var b=c.originalEvent.dataTransfer.getData("Text");e.val().replace(b,a)===e.data(g)&&e.val(b);e.focus()});if(x.form){var p=x.form,w=b(p);if(!w.data(k)){w.submit(b.watermark.hideAll);if(p.submit){w.data(k,p.submit);p.submit=function(c,a){return function(){var d=a.data(k);b.watermark.hideAll();if(d.apply)d.apply(c,Array.prototype.slice.call(arguments));else d()}}(p,w)}else{w.data(k,1);p.submit=function(a){return function(){b.watermark.hideAll();delete a.submit;a.submit()}}(p)}}}}b.watermark._show(e)})};p.length&&b(function(){for(var a,c,d=p.length-1;d>=0;d--){a=p[d];c=window[a];if(typeof c===l)window[a]=function(a){return function(){b.watermark.hideAll();return a.apply(null,Array.prototype.slice.call(arguments))}}(c)}})})(jQuery);
*/
(function($){var
undefined,dataFlag="watermark",dataClass="watermarkClass",dataFocus="watermarkFocus",dataFormSubmit="watermarkSubmit",dataMaxLen="watermarkMaxLength",dataPassword="watermarkPassword",dataText="watermarkText",selWatermarkDefined=":data("+dataFlag+")",selWatermarkAble=":text,:password,:search,textarea",triggerFns=["Page_ClientValidate"],pageDirty=false;$.extend($.expr[":"],{"search":function(elem){return"search"===(elem.type||"");},"data":function(element,index,matches,set){var data,parts=/^((?:[^=!^$*]|[!^$*](?!=))+)(?:([!^$*]?=)(.*))?$/.exec(matches[3]);if(parts){data=$(element).data(parts[1]);if(data!==undefined){if(parts[2]){data=""+data;switch(parts[2]){case"=":return(data==parts[3]);case"!=":return(data!=parts[3]);case"^=":return(data.slice(0,parts[3].length)==parts[3]);case"$=":return(data.slice(-parts[3].length)==parts[3]);case"*=":return(data.indexOf(parts[3])!==-1);}}
return true;}}
return false;}});$.watermark={version:"3.0.6",options:{className:"watermark",useNative:true},hide:function(selector){$(selector).filter(selWatermarkDefined).each(function(){$.watermark._hide($(this));});},_hide:function($input,focus){var inputVal=$input.val()||"",inputWm=$input.data(dataText)||"",maxLen=$input.data(dataMaxLen)||0,className=$input.data(dataClass);if((inputWm.length)&&(inputVal==inputWm)){$input.val("");if($input.data(dataPassword)){if(($input.attr("type")||"")==="text"){var $pwd=$input.data(dataPassword)||[],$wrap=$input.parent()||[];if(($pwd.length)&&($wrap.length)){$wrap[0].removeChild($input[0]);$wrap[0].appendChild($pwd[0]);$input=$pwd;}}}
if(maxLen){$input.attr("maxLength",maxLen);$input.removeData(dataMaxLen);}
if(focus){$input.attr("autocomplete","off");window.setTimeout(function(){$input.select();},1);}}
className&&$input.removeClass(className);},show:function(selector){$(selector).filter(selWatermarkDefined).each(function(){$.watermark._show($(this));});},_show:function($input){var val=$input.val()||"",text=$input.data(dataText)||"",type=$input.attr("type")||"",className=$input.data(dataClass);if(((val.length==0)||(val==text))&&(!$input.data(dataFocus))){pageDirty=true;if($input.data(dataPassword)){if(type==="password"){var $pwd=$input.data(dataPassword)||[],$wrap=$input.parent()||[];if(($pwd.length)&&($wrap.length)){$wrap[0].removeChild($input[0]);$wrap[0].appendChild($pwd[0]);$input=$pwd;$input.attr("maxLength",text.length);}}}
if((type==="text")||(type==="search")){var maxLen=$input.attr("maxLength")||0;if((maxLen>0)&&(text.length>maxLen)){$input.data(dataMaxLen,maxLen);$input.attr("maxLength",text.length);}}
className&&$input.addClass(className);$input.val(text);}
else{$.watermark._hide($input);}},hideAll:function(){if(pageDirty){$.watermark.hide(selWatermarkAble);pageDirty=false;}},showAll:function(){$.watermark.show(selWatermarkAble);}};$.fn.watermark=function(text,options){if(!this.length){return this;}
var hasClass=false,hasText=(typeof(text)==="string");if(typeof(options)==="object"){hasClass=(typeof(options.className)==="string");options=$.extend({},$.watermark.options,options);}
else if(typeof(options)==="string"){hasClass=true;options=$.extend({},$.watermark.options,{className:options});}
else{options=$.watermark.options;}
if(typeof(options.useNative)!=="function"){options.useNative=options.useNative?function(){return true;}:function(){return false;};}
return this.each(function(){var $input=$(this);if(!$input.is(selWatermarkAble)){return;}
if($input.data(dataFlag)){if(hasText||hasClass){$.watermark._hide($input);if(hasText){$input.data(dataText,text);}
if(hasClass){$input.data(dataClass,options.className);}}}
else{if(options.useNative.call(this,$input)){if(((""+$input.css("-webkit-appearance")).replace("undefined","")!=="")&&(($input.attr("tagName")||"")!=="TEXTAREA")){if(hasText){$input.attr("placeholder",text);}
return;}}
$input.data(dataText,hasText?text:"");$input.data(dataClass,options.className);$input.data(dataFlag,1);if(($input.attr("type")||"")==="password"){var $wrap=$input.wrap("<span>").parent(),$wm=$($wrap.html().replace(/type=["']?password["']?/i,'type="text"'));$wm.data(dataText,$input.data(dataText));$wm.data(dataClass,$input.data(dataClass));$wm.data(dataFlag,1);$wm.attr("maxLength",text.length);$wm.focus(function(){$.watermark._hide($wm,true);}).bind("dragenter",function(){$.watermark._hide($wm);}).bind("dragend",function(){window.setTimeout(function(){$wm.blur();},1);});$input.blur(function(){$.watermark._show($input);}).bind("dragleave",function(){$.watermark._show($input);});$wm.data(dataPassword,$input);$input.data(dataPassword,$wm);}
else{$input.focus(function(){$input.data(dataFocus,1);$.watermark._hide($input,true);}).blur(function(){$input.data(dataFocus,0);$.watermark._show($input);}).bind("dragenter",function(){$.watermark._hide($input);}).bind("dragleave",function(){$.watermark._show($input);}).bind("dragend",function(){window.setTimeout(function(){$.watermark._show($input);},1);}).bind("drop",function(evt){var dropText=evt.originalEvent.dataTransfer.getData("Text");if($input.val().replace(dropText,"")===$input.data(dataText)){$input.val(dropText);}
$input.focus();});}
if(false&&this.form){var form=this.form,$form=$(form);if(!$form.data(dataFormSubmit)){$form.submit($.watermark.hideAll);if(form.submit){$form.data(dataFormSubmit,form.submit);form.submit=(function(f,$f){return function(){var nativeSubmit=$f.data(dataFormSubmit);$.watermark.hideAll();if(nativeSubmit.apply){nativeSubmit.apply(f,Array.prototype.slice.call(arguments));}
else{nativeSubmit();}};})(form,$form);}
else{$form.data(dataFormSubmit,1);form.submit=(function(f){return function(){$.watermark.hideAll();delete f.submit;f.submit();};})(form);}}}}
$.watermark._show($input);});};if(triggerFns.length){$(function(){var i,name,fn;for(i=triggerFns.length-1;i>=0;i--){name=triggerFns[i];fn=window[name];if(typeof(fn)==="function"){window[name]=(function(origFn){return function(){$.watermark.hideAll();return origFn.apply(null,Array.prototype.slice.call(arguments));};})(fn);}}});}})(jQuery);


/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);


$(document).ready(function(){
  //watermarks
  $('#contactus-name').watermark('Your Name');
  $('#contactus-email').watermark('Your Email');
  $('#contactus-subject').watermark('Subject');
  $('#contactus-message').watermark('Your Message');
  
  // submenu handling
  $('li.has-child-page').hover(function(){
    $(this).find('ul').stop(true, true).fadeIn('fast').end().addClass('active');
  }, function(){
    $(this).find('ul').stop(true, true).fadeOut('fast').end().removeClass('active');
  });

  // scroll contact link in header to footer contact form
  $('#contact-menu-link').click(function(e){
    e.preventDefault();

  	$.scrollTo('#footer-contact-us-form-container', 2000);
  });

  $('#footer-challeges-box').click(function(){
    $('#contactus-name').focus();
  });

  function submitContactForm(e)
  {
  	$.ajax({
      url: '/contact.php',
      data: $('#footer-contact-form').serialize(),
      type: 'post',
      cache: false,
      dataType: 'json',
      success: function () {
        $('#footer-contact-form').html('Thanks for taking the time to reach out! <br />We will be in touch soon.');
      }
    });
  }

  $('#footer-contact-form').submit(function(e){
  	e.preventDefault();

    submitContactForm(e);
  });

  $('#submit-contact-us').click(function(e){
    e.preventDefault();

    submitContactForm();
  });

  $('#footer-site-links').click(function(e){
    e.preventDefault();

	$('#site-links-container').fadeIn('fast');
  });
  $('#site-links-container-close').click(function(e){
    e.preventDefault();

	$('#site-links-container').fadeOut('slow');
  });
    
  if ($('#homepage').size() > 0)
  {
    // homepage slideshow
    var image_flow = new ImageFlow();
    image_flow.init({ ImageFlowID: 'slideshow-content', 
    startID:  1,
    aspectRatio: 3.5,
    imageFocusM: 2,
    slideshowSpeed: 10000,
    captions: false,
    slider: false,
    percentLandscape: 101,
    button: true,
    circular: true,
    reflections: false,
    xStep: 90,
    imageCursor: 'pointer',
    onClick: function(){ $.scrollTo('#footer-contact-us-form-container', 2000);},
    onPrimaryImageChange: function(imageIndexP) { 
      var image = $('#slideshow-content img').get(imageIndexP); 
      if (image != null)
      {
      $slide_caption = $('#slideshow_caption');
      var content_items = $slide_caption.find('h3, p');
      content_items.stop(true, true).fadeOut(500, function(){
        $slide_caption.find('p').text($(image).attr('longdesc'));
        $slide_caption.find('h3').text(image.alt);
        content_items.fadeIn(500);        
      });
      }     
    }    
   });
   $('#slideshow-page-left').click(function(e){
     e.preventDefault();
     image_flow.MouseWheel.handle(1);
   });
   $('#slideshow-page-right').click(function(e){
     e.preventDefault();
     image_flow.MouseWheel.handle(-1);
   });
  }

});