
var HOME;if(!HOME)HOME={};else if(typeof HOME!="object")
throw new Error("HOME already exists and is not an object!!!");HOME.LastSelectedImageButton=null;HOME.PreLoadedImages=Array();HOME.Gallery_Credits=Array();HOME.Gallery_Credits[1]="Photo Taken by Areti Antonakopoulou";HOME.Gallery_Credits[2]="Photo Taken by Areti Antonakopoulou";HOME.Gallery_Credits[3]="Photo Taken by Janie Shen";HOME.Gallery_Credits[4]="Photo Taken by Janie Shen";HOME.Gallery_Credits[5]="Photo Taken by Ellie McDowall";HOME.Gallery_Credits[6]="Photo Taken by Fran E. Piddlesden";HOME.Gallery_Credits[7]="Photo Taken by Fran E. Piddlesden";HOME.Gallery_Credits[8]="Photo Taken by Shaz";HOME.Gallery_Credits[9]="Photo Taken at WSAF 2006";HOME.Gallery_Credits[10]="Photo Taken by Ellie McDowall";HOME.DayChangerLoading=null;HOME.init=function(){Handler.add($("Gallery_Control_Buttons"),"click",HOME.Change_Mini_Gallery_Photo);HOME.LastSelectedImageButton=$("Gallery_Start");HOME.PreLoad_Gallery_Images();$("LeftArrow").childNodes[0].href='javascript:void 0;';Handler.add($("LeftArrow"),"click",HOME.Event_Day_Changer);Handler.add($("RightArrow"),"click",HOME.Event_Day_Changer);$("RightArrow").childNodes[0].href='javascript:void 0;';}
HOME.PreLoad_Gallery_Images=function(){if(HOME.PreLoadedImages.length<9){var nextPhoto=HOME.PreLoadedImages.length+2;$("Gallery_Hidden_Photo").src="home/media/Photo"+nextPhoto+".JPG";HOME.PreLoadedImages.push("done");setTimeout("HOME.PreLoad_Gallery_Images()",1000);}}
HOME.Change_Mini_Gallery_Photo=function(event){var picNumber=parseInt(event.target.innerHTML);$("Gallery_Photo").src="home/media/Photo"+picNumber+".JPG";$("Gallery_Photo").title=HOME.Gallery_Credits[picNumber];event.target.className="selected";if(HOME.LastSelectedImageButton!=null){HOME.LastSelectedImageButton.className="";}
HOME.LastSelectedImageButton=event.target;}
SPLAT.initFunctions.push(HOME.init);var TIMER={interval:1000,timer:null,outputStr:null,endDate:new Date(2009,05,21,12,30),start:function(){if($("clock_days")!=undefined){TIMER.timer=setInterval(TIMER.createOutput,TIMER.interval);TIMER.createOutput();}},createOutput:function(){var now=new Date();var diff=TIMER.endDate-now;if(diff>0){var decDays=(diff/1000/60/60/24);var days=Math.floor(decDays);var decHours=(decDays-days)*24;var hours=Math.floor(decHours);var decMinutes=(decHours-hours)*60;var minutes=Math.floor(decMinutes);var seconds=Math.floor((decMinutes-minutes)*60);}else{var days=0;var hours=0;var minutes="00";var seconds="00";};$("clock_days").innerHTML=days+"<br/><p class='description'>DAYS</p>";$("clock_hours").innerHTML=hours+"<br/><p class='description'>HRS</p>";$("clock_mins").innerHTML=minutes+"<br/><p class='description'>MINS</p>";$("clock_secs").innerHTML=seconds+"<br/><p class='description'>SECS</p>";}};SPLAT.initFunctions.push(TIMER.start);function box(element){this.element=element;this.id=element.id;}
box.sortHypotenuse=function(a,b){return a.getHypotenuseDistance()-b.getHypotenuseDistance();}
box.prototype.getElement=function(){return this.element;}
box.prototype.getId=function(){return this.id;}
box.prototype.setVerticalDistance=function(vertical){this.verticalPos=vertical;}
box.prototype.getVerticalDistance=function(){return this.verticalPos;}
box.prototype.getRealVerticalDistance=function(){return this.realVerticalPos;}
box.prototype.getHorizontalDistance=function(){return this.horizontalPos;}
box.prototype.getHypotenuseDistance=function(){return this.hypotenusePos;}
box.prototype.getAboveMe=function(){return this.aboveMe;}
box.prototype.getPositionChanged=function(){return this.positionChanged;}
box.prototype.distanceToBox=function(el){this.positionChanged=false;var elRect=Rect.createRectFromElement(el);var boxRect=Rect.createRectFromElement(this.element);this.verticalPos=(boxRect.getY()+boxRect.getHeight()/2)-(elRect.getY()+30);this.realVerticalPos=(boxRect.getY())-(elRect.getY());this.horizontalPos=(boxRect.getX()+boxRect.getWidth()/2)-(elRect.getX()+elRect.getWidth()/2);this.hypotenusePos=Math.sqrt(Math.pow(this.verticalPos,2)+Math.pow(this.horizontalPos,2));if(this.id==el.id){this.hypotenusePos=0;}
if(this.verticalPos>0){if(this.aboveMe==false){this.positionChanged=true;}
this.aboveMe=true;}else{if(this.aboveMe==true){this.positionChanged=true;}
this.aboveMe=false;}
if((this.element.id=="LeftColPad")||(this.element.id=="RightColPad")){this.aboveMe=true;}}
function Rect(x,y,width,height)
{this.x=x;this.y=y;this.width=width;this.height=height;}
Rect.clone=function(fromRect)
{return new Rect(fromRect.x,fromRect.y,fromRect.width,fromRect.height);}
Rect.prototype.clone=function()
{return new Rect(this.x,this.y,this.width,this.height);}
Rect.prototype.copy=function(rect)
{this.x=rect.x;this.y=rect.y;this.width=rect.width;this.height=rect.height;}
Rect.prototype.equals=function(rect)
{if(this.x==rect.x&&this.y==rect.y&&this.width==rect.width&&this.height==rect.height)
{return true;}
else
{return false;}}
Rect.prototype.equals=function(x,y,width,height)
{if(this.x==x&&this.y==y&&this.width==width&&this.height==height)
{return true;}
else
{return false;}}
Rect.prototype.offset=function(x,y)
{this.x=this.x+x;this.y=this.y+y;}
Rect.prototype.getBottom=function()
{return this.y+this.height;}
Rect.prototype.getRight=function()
{return this.x+this.width;}
Rect.prototype.toString=function()
{return"(Rect: x="+this.x+", y="+this.y+", width="+this.width+", height="+this.height+")";}
Rect.prototype.getX=function()
{return this.x;}
Rect.prototype.getY=function()
{return this.y;}
Rect.prototype.getWidth=function()
{return this.width;}
Rect.prototype.getHeight=function()
{return this.height;}
Rect.prototype.setX=function(x)
{this.x=x;}
Rect.prototype.setY=function(y)
{this.y=y;}
Rect.prototype.setWidth=function(width)
{this.width=width;}
Rect.prototype.setHeight=function(height)
{this.height=height;}
Rect.prototype.set=function(x,y,width,height)
{this.x=x;this.y=y;this.width=width;this.height=height;}
Rect.prototype.positionElement=function(element)
{element.style.left=this.x+"px";element.style.top=this.y+"px";element.style.width=Math.max(0,this.width)+"px";element.style.height=Math.max(0,this.height)+"px";}
Rect.prototype.contains=function(x,y)
{if(this.x<=x&&x<=this.getRight()&&this.y<=y&&y<=this.getBottom())
{return true;}
else
{return false;}}
Rect.prototype.inflate=function(dx,dy)
{this.x-=dx;this.y-=dy;this.width=Math.max(0,this.width+dx*2);this.height=Math.max(0,this.height+dy*2);}
Rect.prototype.offset=function(dx,dy)
{this.x+=dx;this.y+=dy;}
Rect.prototype.getDockLocation=function(x,y)
{if(this.x<=x&&x<=this.getRight()&&this.y<=y&&y<=this.getBottom())
{return true;}
else
{return false;}}
Rect.createRectFromElement=function(el){var elPos=Rect.getComponentPosition(el);var newRect=new Rect(elPos[0],elPos[1],el.offsetWidth,el.offsetHeight);return newRect;}
Rect.getComponentPosition=function(component){var boxX,boxY;boxX=boxY=0;var parentEl=component;do{boxX+=parentEl.offsetLeft;boxY+=parentEl.offsetTop;}while(parentEl=parentEl.offsetParent);return Array(boxX,boxY);}
var WIDGET;if(!WIDGET)WIDGET={};else if(typeof WIDGET!="object")
throw new Error("WIDGET already exists and is not an object!!!");WIDGET.containers=Array();WIDGET.ResizeFunctions=Array();WIDGET.currentWidget=null;WIDGET.currentWidgetResize=null;WIDGET.widgets=Array();WIDGET.offsetX=0;WIDGET.offsetY=0;WIDGET.init=function(){var allDivs=document.getElementsByTagName("div");for(var i=0;i<allDivs.length;i++){if(allDivs[i].className=="widget"){var children=allDivs[i].childNodes;for(var a=0;a<children.length;a++){if(children[a].nodeType==1){if(children[a].tagName=="H2"){Handler.add(children[a],"mousedown",WIDGET.dragStart);}}}
if((allDivs[i].id==undefined)||(allDivs[i].id=="")){allDivs[i].id="widget"+i;}
WIDGET.widgets.push(new box(allDivs[i]));}else if(allDivs[i].className=="container"){WIDGET.containers.push(allDivs[i]);}}
WIDGET.ResizeFunctions["Widget_Literature"]=WIDGET.Resize_Literature;WIDGET.ResizeFunctions["Widget_Photos"]=WIDGET.Resize_Photos;}
WIDGET.dragStart=function(e){var targetEl=(e.srcElement==undefined)?e.target:e.srcElement;targetEl=targetEl.parentNode;if((targetEl.tagName!="DIV")||(WIDGET.currentWidget!=null)){return;}
if(e.pageX||e.pageY){startX=e.pageX;startY=e.pageY;}else if(e.clientX||e.clientY){startX=e.clientX+document.body.scrollLeft
+document.documentElement.scrollLeft;startY=e.clientY+document.body.scrollTop
+document.documentElement.scrollTop;}
var elPos=WIDGET.getComponentPosition(targetEl);WIDGET.offsetX=startX-elPos[0];WIDGET.offsetY=startY-elPos[1];WIDGET.currentWidget=targetEl;var ghostEl=WIDGET.createGhost();targetEl.parentNode.insertBefore(ghostEl,targetEl);targetEl.style.width=targetEl.offsetWidth+"px";targetEl.parentNode.removeChild(targetEl);document.body.appendChild(targetEl);targetEl.style.position="absolute";var newPosX=startX-WIDGET.offsetX;var newPosY=startY-WIDGET.offsetY;WIDGET.currentWidget.style.left=newPosX+"px";WIDGET.currentWidget.style.top=newPosY+"px";WIDGET._ChangeOpacity(targetEl,0.70);if(!browser.isSafari){$("carousel1").style.display="none";$("carousel1_reserve").style.display="block";}
var ghostBox=new box(ghostEl);WIDGET.widgets.push(ghostBox);for(var i=0;i<WIDGET.widgets.length;i++){disableSelection(WIDGET.widgets[i].getElement());}
Handler.add(document,"mousemove",WIDGET.drag);Handler.add(document,"mouseup",WIDGET.dragEnd);}
WIDGET.createGhost=function(){var ghostEl=document.createElement("div");ghostEl.style.border="#666666 dashed 2px";ghostEl.style.height=WIDGET.currentWidget.offsetHeight+"px";ghostEl.style.marginBottom="10px";ghostEl.style.marginTop="10px";ghostEl.id="ghost";return ghostEl;}
WIDGET.getComponentPosition=function(component){var boxX,boxY;boxX=boxY=0;var parentEl=component;do{boxX+=parentEl.offsetLeft;boxY+=parentEl.offsetTop;}while(parentEl=parentEl.offsetParent);return Array(boxX,boxY);}
WIDGET.dragEnd=function(event){Handler.remove(document,"mousemove",WIDGET.drag);Handler.remove(document,"mouseup",WIDGET.dragEnd);for(var i=0;i<WIDGET.widgets.length;i++){WIDGET.widgets[i].distanceToBox(WIDGET.currentWidget);}
WIDGET.widgets.sort(box.sortHypotenuse);if($("ghost")){WIDGET.moveToLocation(WIDGET.currentWidget.id,10);}
$("carousel1").style.display="block";$("carousel1_reserve").style.display="none";for(var i=0;i<WIDGET.widgets.length;i++){enableSelection(WIDGET.widgets[i].getElement());}
WIDGET.unselect_Selection();if(event.stopPropagation)event.stopPropagation();else event.cancelBubble=true;}
WIDGET.unselect_Selection=function(){if(!browser.isFirefox){oTextRange=document.selection.createRange()
oTextRange.expand("word")
oTextRange.execCommand("unselect")}
else{oTextRange=window.getSelection()
oTextRange.collapseToStart()}}
WIDGET.drag=function(e){var DISTANCE_UNKNOWN=1000000;if(e.pageX||e.pageY){mouseX=e.pageX;mouseY=e.pageY;}else if(e.clientX||e.clientY){mouseX=e.clientX+document.body.scrollLeft
+document.documentElement.scrollLeft;mouseY=e.clientY+document.body.scrollTop
+document.documentElement.scrollTop;}
var newPosX=mouseX-WIDGET.offsetX;var newPosY=mouseY-WIDGET.offsetY;WIDGET.currentWidget.style.left=newPosX+"px";WIDGET.currentWidget.style.top=newPosY+"px";var widgetRect=Rect.createRectFromElement(WIDGET.currentWidget);for(var i=0;i<WIDGET.widgets.length;i++){WIDGET.widgets[i].distanceToBox(WIDGET.currentWidget);}
var ghostEl=WIDGET.createGhost();WIDGET.widgets.sort(box.sortHypotenuse);if(WIDGET.widgets[1].getId()!="ghost"){var posOfGhost=WIDGET.findWidgetByID("ghost");if(WIDGET.widgets[posOfGhost].getElement().parentNode==null){}else{if(WIDGET.widgets[1].getAboveMe()==true){if((WIDGET.widgets[1].getElement().previousSibling!=null)&&(WIDGET.widgets[1].getElement().previousSibling.id=="ghost")){WIDGET.widgets[1].getElement().parentNode.insertBefore(ghostEl,WIDGET.widgets[1].getElement().nextSibling);}else{WIDGET.widgets[1].getElement().parentNode.insertBefore(ghostEl,WIDGET.widgets[1].getElement());}}else{WIDGET.widgets[1].getElement().parentNode.insertBefore(ghostEl,WIDGET.widgets[1].getElement().nextSibling);}
WIDGET.widgets[posOfGhost].getElement().parentNode.removeChild(WIDGET.widgets[posOfGhost].getElement());WIDGET.widgets.splice(posOfGhost,1);var newBox=new box(ghostEl);WIDGET.widgets.push(newBox);WIDGET.resizeWidget();}}else if((WIDGET.widgets[1].getId()=="ghost")&&(WIDGET.widgets[1].getPositionChanged()==true)){if(WIDGET.widgets[1].getAboveMe()==true){WIDGET.widgets[1].getElement().parentNode.insertBefore(ghostEl,WIDGET.widgets[1].getElement().nextSibling);}else{if(WIDGET.widgets[1].getElement().nextSibling==null){WIDGET.widgets[1].getElement().parentNode.insertBefore(ghostEl,WIDGET.widgets[1].getElement().nextSibling);}else{WIDGET.widgets[1].getElement().parentNode.insertBefore(ghostEl,WIDGET.widgets[1].getElement().nextSibling.nextSibling);}}
WIDGET.widgets[1].getElement().parentNode.removeChild(WIDGET.widgets[1].getElement());WIDGET.widgets.splice(1,1);var newBox=new box(ghostEl);WIDGET.widgets.push(newBox);WIDGET.resizeWidget();}
if(e.stopPropagation)e.stopPropagation();else e.cancelBubble=true;}
WIDGET.findWidgetByID=function(widgetID){for(var i=0;i<WIDGET.widgets.length;i++){if(WIDGET.widgets[i].getId()==widgetID){return i;}}}
WIDGET._ChangeOpacity=function(element,newValue){element.style.opacity=String(newValue);element.style.MozOpacity=newValue;element.style.KhtmlOpacity=newValue;element.style.filter="alpha(opacity="+(newValue*100)+")";}
WIDGET.resizeWidget=function(){if((WIDGET.currentWidget==null)||(WIDGET.currentWidget==undefined)){clearTimeout(WIDGET.currentWidgetResize);return false;}
var ghostWidth=$("ghost").offsetWidth;var widgetWidth=WIDGET.currentWidget.offsetWidth;if(widgetWidth<ghostWidth){var diff=ghostWidth-widgetWidth;if(diff>50){WIDGET.currentWidget.style.width=widgetWidth+50+"px";}else{WIDGET.currentWidget.style.width=widgetWidth+diff+"px";}
clearTimeout(WIDGET.currentWidgetResize);WIDGET.currentWidgetResize=setTimeout("WIDGET.resizeWidget()",100);}else if(widgetWidth>ghostWidth){var diff=widgetWidth-ghostWidth;if(diff>50){WIDGET.currentWidget.style.width=widgetWidth-50+"px";}else{WIDGET.currentWidget.style.width=widgetWidth-diff+"px";}
clearTimeout(WIDGET.currentWidgetResize);WIDGET.currentWidgetResize=setTimeout("WIDGET.resizeWidget()",100);}
if(WIDGET.ResizeFunctions[WIDGET.currentWidget.id]!=undefined){WIDGET.ResizeFunctions[WIDGET.currentWidget.id](ghostWidth);}}
WIDGET.moveToLocation=function(elementID,count){var element=$(elementID);var elRect=Rect.createRectFromElement(element);var ghostRect=Rect.createRectFromElement($("ghost"));var changeMade=true;if(elRect.getX()<ghostRect.getX()){element.style.left=elRect.getX()+((ghostRect.getX()-elRect.getX())/count)+"px";}else if(elRect.getX()>ghostRect.getX()){element.style.left=elRect.getX()-((elRect.getX()-ghostRect.getX())/count)+"px";}else{changeMade=false;}
if((elRect.getY()-10)<ghostRect.getY()){element.style.top=elRect.getY()-10+((ghostRect.getY()-elRect.getY())/count)+"px";}else if(elRect.getY()>ghostRect.getY()){element.style.top=elRect.getY()-10-((elRect.getY()-ghostRect.getY())/count)+"px";}else{changeMade=false;}
if((changeMade)&&(count>1)){count--;setTimeout("WIDGET.moveToLocation('"+elementID+"', "+count+")",50);}else{element.parentNode.removeChild(element);var tempEl=$("ghost").parentNode.insertBefore(element,$("ghost"));$("ghost").parentNode.removeChild($("ghost"));element.style.width="";element.style.position="static";WIDGET._ChangeOpacity(element,1);WIDGET.currentWidget=null;if(WIDGET.ResizeFunctions[elementID]!=undefined){WIDGET.ResizeFunctions[elementID](ghostRect.getWidth());}
var cookieVal="";var leftPanelChildren=$("LeftPanel").childNodes;for(var i=0;i<leftPanelChildren.length;i++){if(leftPanelChildren[i].nodeType==1){if(leftPanelChildren[i].className=="widget"){cookieVal+=leftPanelChildren[i].id+",";}}}
var rightPanelChildren=$("RightPanel").childNodes;for(var i=0;i<rightPanelChildren.length;i++){if(rightPanelChildren[i].nodeType==1){if(rightPanelChildren[i].className=="widget"){cookieVal+=rightPanelChildren[i].id+",";}}}
var date=new Date();date.setTime(date.getTime()+(365*24*60*60*1000));document.cookie="HomePageWidgets="+cookieVal+"; expires="+date.toGMTString()+"; path=/";}}
WIDGET.Resize_Literature=function(newWidth){var element=$("Widget_Literature");if(newWidth<350){$("Widget_Literature_Text").style.width="300px";$("Literature_Links").style.width="100%";$("Widget_Literature_Content").style.height="200px";}else{$("Widget_Literature_Text").style.width="354px";$("Literature_Links").style.width="210px";$("Widget_Literature_Content").style.height="116px";}}
WIDGET.Resize_Photos=function(newWidth){var element=$("Widget_Literature");if(newWidth<350){$("Widget_Photos_Links").style.display="none";}else{$("Widget_Photos_Links").style.display="block";}}
function disableSelection(target){if(typeof target.style.MozUserSelect!=undefined)
target.style.MozUserSelect="none"
else if(typeof target.onselectstart!=undefined)
target.onselectstart=function(){return false}
else
target.onmousedown=function(){return false}
target.style.cursor="default"}
function enableSelection(target){if(typeof target.style.MozUserSelect!=undefined)
target.style.MozUserSelect="";else if(typeof target.onselectstart!=undefined)
target.onselectstart=null;else
target.onmousedown=null;target.style.cursor="";}
HOME.Event_Day_Changer=function(e){var targetEl=(e.srcElement==undefined)?e.target:e.srcElement;var POSTArray=Array();POSTArray["Filter"]=targetEl.id;var url="../events/ajax/events.php?request=Home_Page_Viewer";HOME.DayChangerLoading=setTimeout("$('EventsViewer').innerHTML = '<p class=\"EventsLoading\">Loading...</p>'",600);AJAX.post(url,POSTArray,HOME.Event_Day_Changer_Success,HOME.Event_Day_Changer_Failure);}
HOME.Event_Day_Changer_Success=function(returnObj){clearTimeout(HOME.DayChangerLoading);$("Widget_Events_Content").innerHTML=returnObj.responseText;$("LeftArrow").childNodes[0].href='javascript:void 0;';Handler.add($("LeftArrow"),"click",HOME.Event_Day_Changer);Handler.add($("RightArrow"),"click",HOME.Event_Day_Changer);$("RightArrow").childNodes[0].href='javascript:void 0;';}
HOME.Event_Day_Changer_Failure=function(){}
SPLAT.initFunctions.push(WIDGET.init);
