
function RegisterNamespace(namespacePath)
{var rootObject=window;var namespaceParts=namespacePath.split('.');for(var i=0;i<namespaceParts.length;i++)
{var currentPart=namespaceParts[i];if(!rootObject[currentPart])
{rootObject[currentPart]=new Object();}
rootObject=rootObject[currentPart];}}
RegisterNamespace('FreshLogicStudios.Scripts');FreshLogicStudios.Scripts.Command=function(_action)
{var action=_action;var enabled=true;var self=this;this.Events=new FreshLogicStudios.Scripts.EventCollection();this.Disable=function()
{self.SetEnabled(false);}
this.Enable=function()
{self.SetEnabled(true);}
this.Execute=function()
{if(enabled)
{action();}}
this.IsEnabled=function()
{return enabled;}
this.SetEnabled=function(value)
{if(enabled!=value)
{enabled=value;self.Events.Fire('EnabledChanged',self);}}}
FreshLogicStudios.Scripts.Console=function(){}
FreshLogicStudios.Scripts.Console.In=null;FreshLogicStudios.Scripts.Console.Out=null;FreshLogicStudios.Scripts.Console.Clear=function()
{if(FreshLogicStudios.Scripts.Console.Out)
{FreshLogicStudios.Scripts.Console.Out.innerHTML='';}}
FreshLogicStudios.Scripts.Console.ReadLine=function()
{if(FreshLogicStudios.Scripts.Console.In)
{try
{FreshLogicStudios.Scripts.Console.WriteLine(eval(FreshLogicStudios.Scripts.Console.In.value));}
catch(ex)
{FreshLogicStudios.Scripts.Console.WriteLine(FreshLogicStudios.Scripts.String.Format('<span style="color:Red;">{0}: {1}</span>',ex.name,ex.message));}}}
FreshLogicStudios.Scripts.Console.SetIn=function(element)
{FreshLogicStudios.Scripts.Console.In=element;}
FreshLogicStudios.Scripts.Console.SetOut=function(element)
{FreshLogicStudios.Scripts.Console.Out=element;}
FreshLogicStudios.Scripts.Console.Write=function(object)
{if(FreshLogicStudios.Scripts.Console.Out&&object&&(object!=undefined))
{FreshLogicStudios.Scripts.Console.Out.innerHTML=FreshLogicStudios.Scripts.String.Format('<span>{0}</span>{1}',object.toString(),FreshLogicStudios.Scripts.Console.Out.innerHTML);}}
FreshLogicStudios.Scripts.Console.WriteLine=function(object)
{if(FreshLogicStudios.Scripts.Console.Out&&object&&(object!=undefined))
{FreshLogicStudios.Scripts.Console.Out.innerHTML=FreshLogicStudios.Scripts.String.Format('<span>{0}</span><br />{1}',object.toString(),FreshLogicStudios.Scripts.Console.Out.innerHTML);}}
FreshLogicStudios.Scripts.DateTime=function(year,month,day,hour,minute,second,millisecond)
{var self=this;var date=new Date(year,month-1,day,hour||0,minute||0,second||0,millisecond||0);function FromJavaScriptDate(value)
{return new FreshLogicStudios.Scripts.DateTime(value.getFullYear(),value.getMonth()+1,value.getDate(),value.getHours(),value.getMinutes(),value.getSeconds(),value.getMilliseconds());}
function GetDayName(value)
{switch(value)
{case 0:return'Sunday';break;case 1:return'Monday';break;case 2:return'Tuesday';break;case 3:return'Wednesday';break;case 4:return'Thursday';break;case 5:return'Friday';break;case 6:return'Saturday';break;}}
function GetMeridiem()
{return(date.getHours()<=10)?'AM':'PM';}
function GetMeridiemHours()
{if(date.getHours()%12==0)
{return 12;}
return date.getHours()%12;}
function GetMonthName(value)
{switch(value)
{case 1:return'January';break;case 2:return'February';break;case 3:return'March';break;case 4:return'April';break;case 5:return'May';break;case 6:return'June';break;case 7:return'July';break;case 8:return'August';break;case 9:return'September';break;case 10:return'October';break;case 11:return'November';break;case 12:return'December';break;}}
function PadLeft(value,totalWidth,paddingChar)
{paddingChar=paddingChar||' ';while(value.length<totalWidth)
{value=paddingChar+value;}
return value.substr(value.length-totalWidth);}
this.AddDays=function(value)
{var myDate=new Date(date);myDate.setDate(myDate.getDate()+value);return FromJavaScriptDate(myDate);}
this.AddHours=function(value)
{var myDate=new Date(date);myDate.setHours(myDate.getHours()+value);return FromJavaScriptDate(myDate);}
this.AddMilliseconds=function(value)
{var myDate=new Date(date);myDate.setMilliseconds(myDate.getMilliseconds()+value);return FromJavaScriptDate(myDate);}
this.AddMinutes=function(value)
{var myDate=new Date(date);myDate.setMinutes(myDate.getMinutes()+value);return FromJavaScriptDate(myDate);}
this.AddMonths=function(value)
{var myDate=new Date(date);myDate.setMonths(myDate.getMonths()+value);return FromJavaScriptDate(myDate);}
this.AddSeconds=function(value)
{var myDate=new Date(date);myDate.setSeconds(myDate.getSeconds()+value);return FromJavaScriptDate(myDate);}
this.GetDate=function()
{return new FreshLogicStudios.Scripts.DateTime(self.GetYear(),self.GetMonth(),self.GetDay());}
this.GetDay=function()
{return date.getDate();}
this.GetDayOfWeek=function()
{return date.getDay();}
this.GetHour=function()
{return date.getHours();}
this.GetMillisecond=function()
{return date.getMilliseconds();}
this.GetMinute=function()
{return date.getMinutes();}
this.GetMonth=function()
{return date.getMonth()+1;}
this.GetSecond=function()
{return date.getSeconds();}
this.GetYear=function()
{return date.getFullYear();}
this.ToLongDateString=function()
{return self.ToString('D');}
this.ToLongTimeString=function()
{return self.ToString('T');}
this.ToShortDateString=function()
{return self.ToString('d');}
this.ToShortTimeString=function()
{return self.ToString('t');}
this.toString=function()
{return self.ToString('G');}
this.ToString=function(format)
{format=format||'G';switch(format)
{case'd':return FreshLogicStudios.Scripts.String.Format('{0}/{1}/{2}',self.GetMonth(),self.GetDay(),PadLeft(self.GetYear().toString(),4,'0'));break;case'D':return FreshLogicStudios.Scripts.String.Format('{0}, {1} {2}, {3}',GetDayName(self.GetDayOfWeek()),GetMonthName(self.GetMonth()),PadLeft(self.GetDay().toString(),2,'0'),PadLeft(self.GetYear().toString(),4,'0'));break;case't':return FreshLogicStudios.Scripts.String.Format('{0}:{1} {2}',GetMeridiemHours(),PadLeft(self.GetMinute().toString(),2,'0'),GetMeridiem());break;case'T':return FreshLogicStudios.Scripts.String.Format('{0}:{1}:{2} {3}',GetMeridiemHours(),PadLeft(self.GetMinute().toString(),2,'0'),PadLeft(self.GetSecond().toString(),2,'0'),GetMeridiem());break;case'f':return FreshLogicStudios.Scripts.String.Format('{0}, {1} {2}, {3} {4}:{5} {6}',GetDayName(self.GetDayOfWeek()),GetMonthName(self.GetMonth()),PadLeft(self.GetDay().toString(),2,'0'),PadLeft(self.GetYear().toString(),4,'0'),GetMeridiemHours(),PadLeft(self.GetMinute().toString(),2,'0'),GetMeridiem());break;case'F':return FreshLogicStudios.Scripts.String.Format('{0}, {1} {2}, {3} {4}:{5}:{6} {7}',GetDayName(self.GetDayOfWeek()),GetMonthName(self.GetMonth()),PadLeft(self.GetDay().toString(),2,'0'),PadLeft(self.GetYear().toString(),4,'0'),GetMeridiemHours(),PadLeft(self.GetMinute().toString(),2,'0'),PadLeft(self.GetSecond().toString(),2,'0'),GetMeridiem());break;case'g':return FreshLogicStudios.Scripts.String.Format('{0}/{1}/{2} {3}:{4} {5}',self.GetMonth(),self.GetDay(),PadLeft(self.GetYear().toString(),4,'0'),GetMeridiemHours(),PadLeft(self.GetMinute().toString(),2,'0'),GetMeridiem());break;case'G':return FreshLogicStudios.Scripts.String.Format('{0}/{1}/{2} {3}:{4}:{5} {6}',self.GetMonth(),self.GetDay(),PadLeft(self.GetYear().toString(),4,'0'),GetMeridiemHours(),PadLeft(self.GetMinute().toString(),2,'0'),PadLeft(self.GetSecond().toString(),2,'0'),GetMeridiem());break;case'M':return FreshLogicStudios.Scripts.String.Format('{0} {1}',GetMonthName(self.GetMonth()),PadLeft(self.GetDay().toString(),2,'0'));break;case's':return FreshLogicStudios.Scripts.String.Format('{0}-{1}-{2}T{3}:{4}:{5}',PadLeft(self.GetYear().toString(),4,'0'),PadLeft(self.GetMonth().toString(),2,'0'),PadLeft(self.GetDay().toString(),2,'0'),PadLeft(self.GetHour().toString(),2,'0'),PadLeft(self.GetMinute().toString(),2,'0'),PadLeft(self.GetSecond().toString(),2,'0'));break;case'Y':return FreshLogicStudios.Scripts.String.Format('{0}, {1}',GetMonthName(self.GetMonth()),PadLeft(self.GetYear().toString(),4,'0'));break;default:return self.ToString('G');break;}}}
FreshLogicStudios.Scripts.DateTime.MaxValue=new FreshLogicStudios.Scripts.DateTime(9999,12,31,23,59,59,999);FreshLogicStudios.Scripts.DateTime.MinValue=new FreshLogicStudios.Scripts.DateTime(1,1,1,0,0,0,0);FreshLogicStudios.Scripts.DateTime.Now=function()
{var date=new Date();return new FreshLogicStudios.Scripts.DateTime(date.getFullYear(),date.getMonth()+1,date.getDate(),date.getHours(),date.getMinutes(),date.getSeconds(),date.getMilliseconds());}
FreshLogicStudios.Scripts.DateTime.Today=function()
{var date=new Date();return new FreshLogicStudios.Scripts.DateTime(date.getFullYear(),date.getMonth()+1,date.getDate());}
FreshLogicStudios.Scripts.EventCollection=function()
{this.Events=[];}
FreshLogicStudios.Scripts.EventCollection.prototype.Add=function(_event)
{this.Events[this.Events.length]=_event;}
FreshLogicStudios.Scripts.EventCollection.prototype.Clear=function()
{for(var i=this.Events.length-1;i>=0;i--)
{delete this.Events[i];}}
FreshLogicStudios.Scripts.EventCollection.prototype.Remove=function(_event)
{for(var i=this.Events.length-1;i>=0;i--)
{if(this.Events[i].Equals(_event))
{delete this.Events[i];}}}
FreshLogicStudios.Scripts.EventCollection.prototype.Fire=function(eventName,args)
{for(var i=0;i<this.Events.length;i++)
{if(this.Events[i].Name==eventName)
{this.Events[i].Fire(args);}}}
var Events=new FreshLogicStudios.Scripts.EventCollection();FreshLogicStudios.Scripts.Event=function(name,handler)
{this.Name=name;this.Handler=handler;}
FreshLogicStudios.Scripts.Event.prototype.Equals=function(_event)
{return(this.Name==_event.Name&&this.Handler==_event.Handler);}
FreshLogicStudios.Scripts.Event.prototype.Fire=function(args)
{this.Handler(args);}
function AddEvent(targetObject,eventType,functionPointer)
{if(targetObject.addEventListener)
{targetObject.addEventListener(eventType,functionPointer,true);return true;}
else if(targetObject.attachEvent)
{var r=targetObject.attachEvent("on"+eventType,functionPointer);return r;}
else
{return false;}}
function RemoveEvent(targetObject,eventType,functionPointer)
{if(targetObject.removeEventListener)
{targetObject.removeEventListener(eventType,functionPointer,true);return true;}
else if(targetObject.detachEvent)
{var r=targetObject.detachEvent("on"+eventType,functionPointer);return r;}
else
{return false;}}
FreshLogicStudios.Scripts.Guid=function(g)
{var self=this;var guid=g||'00000000-0000-0000-0000-000000000000';this.CompareTo=function(value)
{if(guid<value.ToString())
{return-1;}
else if(guid>value.ToString())
{return 1;}
return 0;}
this.Equals=function(g)
{return(guid==g.ToString());}
this.toString=function()
{return guid;}
this.ToString=function()
{return guid;}}
FreshLogicStudios.Scripts.Guid.Empty=new FreshLogicStudios.Scripts.Guid('00000000-0000-0000-0000-000000000000');FreshLogicStudios.Scripts.Guid.NewGuid=function()
{var guid="";var characters="0123456789abcdef";var parts=[8,4,4,4,12];for(var i=0;i<parts.length;++i)
{for(var j=0;j<parts[i];++j)
{var index=Math.round(Math.random()*16);guid+=characters.charAt(index);}
if(i!=parts.length-1)
{guid+="-"}}
return new FreshLogicStudios.Scripts.Guid(guid);}
function RegisterNamespace(namespacePath)
{var rootObject=window;var namespaceParts=namespacePath.split('.');for(var i=0;i<namespaceParts.length;i++)
{var currentPart=namespaceParts[i];if(!rootObject[currentPart])
{rootObject[currentPart]=new Object();}
rootObject=rootObject[currentPart];}}
RegisterNamespace('FreshLogicStudios.Scripts');FreshLogicStudios.Scripts.String=function(){}
FreshLogicStudios.Scripts.String.Empty='';FreshLogicStudios.Scripts.String.Format=function()
{var params=FreshLogicStudios.Scripts.String.Format.arguments;var myString=params[0];for(var i=1;i<params.length;i++)
{var regex=new RegExp('\\{'+(i-1)+'\\}','g');myString=myString.replace(regex,params[i].toString());}
return myString;}
FreshLogicStudios.Scripts.String.IsNullOrEmpty=function(value)
{return(value==null||value=='');}
FreshLogicStudios.Scripts.Uri=function(uriString)
{var self=this;var absoluteUri=uriString;var regex=/(\w+):\/\/([\w:.]+)\/(\S*)/;function GetDefaultPort(scheme)
{switch(scheme)
{case'file':return'';case'ftp':return 21;case'gopher':return 70;case'http':return 80;case'https':return 443;case'mailto':return 25;case'news':return 119;case'nntp':return 119;default:return'';}}
this.GetAbsolutePath=function()
{return absoluteUri.match(regex)[3];}
this.GetAbsoluteUri=function()
{return absoluteUri;}
this.GetAuthority=function()
{var authority=self.GetHost();if(!self.IsDefaultPort())
{authority+=':'+self.GetPort();}
return authority;}
this.GetFragment=function()
{return absoluteUri.substring(absoluteUri.indexOf('#'));}
this.GetHost=function()
{return absoluteUri.match(regex)[2].split(':')[0];}
this.GetPathAndQuery=function()
{return self.GetAbsolutePath()+self.GetQuery();}
this.GetPort=function()
{if(absoluteUri.match(regex)[2].split(':')[1])
{return parseInt(absoluteUri.match(regex)[2].split(':')[1]);}
else
{return GetDefaultPort(self.GetScheme());}}
this.GetQuery=function()
{return absoluteUri.substring(absoluteUri.indexOf('?'));}
this.GetQueryParameters=function()
{var parameters={};var myUri=absoluteUri;var q=myUri.indexOf("?");if(q==-1)
{return parameters;}
myUri=myUri.substring(q+1);var pairs=myUri.split("&");for(var i=0;i<pairs.length;i++)
{var keyval=pairs[i].split("=");parameters[keyval[0]]=decodeURIComponent(keyval[1]);}
return parameters;}
this.GetScheme=function()
{return absoluteUri.match(regex)[1].toLowerCase();}
this.IsDefaultPort=function()
{return(self.GetPort()==GetDefaultPort(self.GetScheme()));}
this.IsFile=function()
{return(self.GetScheme()=='file');}
this.IsLoopback=function()
{var host=self.GetHost();if(host=='127.0.0.1'||host=='loopback'||host=='localhost')
{return true;}
return false;}}
RegisterNamespace('FreshLogicStudios.Scripts.Html');FreshLogicStudios.Scripts.Html.HtmlElement=function(){}
FreshLogicStudios.Scripts.Html.HtmlElement.Show=function(element)
{element.style.display='block';}
FreshLogicStudios.Scripts.Html.HtmlElement.Hide=function(element)
{element.style.display='none';}
FreshLogicStudios.Scripts.Html.HtmlElement.Toggle=function(element)
{if(element.style.display!='none')
{FreshLogicStudios.Scripts.Html.HtmlElement.Hide(element);}
else
{FreshLogicStudios.Scripts.Html.HtmlElement.Show(element);}}
FreshLogicStudios.Scripts.Html.HtmlElement.HideChildren=function(parentElement)
{for(var i=0;i<parentElement.childNodes.length;i++)
{if(parentElement==parentElement.childNodes[i].parentNode&&parentElement.childNodes[i].tagName)
{FreshLogicStudios.Scripts.Html.HtmlElement.Hide(parentElement.childNodes[i]);}}}
FreshLogicStudios.Scripts.Html.HtmlElement.ShowSingleChild=function(element)
{FreshLogicStudios.Scripts.Html.HtmlElement.HideChildren(element.parentNode);FreshLogicStudios.Scripts.Html.HtmlElement.Show(element);}
FreshLogicStudios.Scripts.Html.HtmlElement.SetBackgroundImage=function(element,imageUrl)
{if(imageUrl.indexOf('.png')!=-1&&document.body.style.filter!=undefined)
{element.style.backgroundImage='none';element.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+imageUrl+'", sizingMethod="scale")';}
else
{element.style.backgroundImage='url("'+imageUrl+'")';}}
RegisterNamespace('FreshLogicStudios.Scripts.Drawing.Image');FreshLogicStudios.Scripts.Drawing.Image=function(){}
FreshLogicStudios.Scripts.Drawing.Image.FixBackgroundImages=function()
{if(document.body.style.filter!=undefined)
{for(i=0;i<document.styleSheets.length;i++)
{try
{for(j=0;j<document.styleSheets[i].rules.length;j++)
{if(document.styleSheets[i].rules.item(j).style.backgroundImage.indexOf('.png')!=-1)
{var imageUrl=document.styleSheets[i].rules.item(j).style.backgroundImage;imageUrl=imageUrl.substring(imageUrl.indexOf('(')+1,imageUrl.lastIndexOf(')'));document.styleSheets[i].rules.item(j).style.backgroundImage='none';document.styleSheets[i].rules.item(j).style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+imageUrl+'", sizingMethod="scale")';}}}
catch(e)
{}}}}
RegisterNamespace('FreshLogicStudios.Scripts.Drawing');FreshLogicStudios.Scripts.Drawing.Point=function(x,y)
{var self=this;this.X=x||0;this.Y=y||0;this.Clone=function()
{return new FreshLogicStudios.Scripts.Drawing.Point(self.X,self.Y);}
this.IsEmpty=function()
{return(self.X==0&&self.Y==0);}
this.Offset=function(dx,dy)
{self.X+=dx;self.Y+=dy;}}
RegisterNamespace('FreshLogicStudios.Scripts.Drawing');FreshLogicStudios.Scripts.Drawing.Rectangle=function(location,size)
{var self=this;this.Location=location||new FreshLogicStudios.Scripts.Drawing.Point(0,0);this.Size=size||new FreshLogicStudios.Scripts.Drawing.Size(0,0);this.Clone=function()
{return new FreshLogicStudios.Scripts.Drawing.Rectangle(self.Location.Clone(),self.Size.Clone());}
this.Contains=function(pt)
{if(((self.GetX()<=pt.X)&&(pt.X<(self.GetX()+self.GetWidth())))&&(self.GetY()<=pt.Y))
{return(pt.Y<(self.GetY()+self.GetHeight()));}
return false;}
this.GetBottom=function()
{return self.Location.Y+self.Size.Height;}
this.GetHeight=function()
{return self.Size.Height;}
this.GetLeft=function()
{return self.Location.X;}
this.GetRight=function()
{return self.Location.X+self.Size.Width;}
this.GetTop=function()
{return self.Location.Y;}
this.GetWidth=function()
{return self.Size.Width;}
this.GetX=function()
{return self.Location.X;}
this.GetY=function()
{return self.Location.Y;}
this.Inflate=function(size)
{this.SetX(this.GetX()-size.Width);this.SetY(this.Gety()-size.Height);this.SetWidth(this.GetWidth()+(2*size.Width));this.SetHeight(this.GetHeight()+(2*size.Height));}
this.Intersect=function(rect)
{var x=Math.max(a.GetX(),b.GetX());var num2=Math.min(a.GetX()+a.GetWidth(),b.GetX()+b.GetWidth());var y=Math.max(a.GetY(),b.GetY());var num4=Math.min(a.GetY()+a.GetHeight(),b.GetY()+b.GetHeight());if((num2>=x)&&(num4>=y))
{this.Location=new FreshLogicStudios.Scripts.Drawing.Point(x,y);this.Size=new FreshLogicStudios.Scripts.Drawing.Size(num2-x,num4-y);}
else
{this.Location=new FreshLogicStudios.Scripts.Drawing.Point(0,0);this.Size=new FreshLogicStudios.Scripts.Drawing.Size(0,0);}}
this.IntersectsWith=function(rect)
{if(((rect.GetX()<(self.GetX()+self.GetWidth()))&&(self.GetX()<(rect.GetX()+rect.GetWidth())))&&(rect.GetY()<(self.GetY()+self.GetHeight())))
{return(self.GetY()<(rect.GetY()+rect.GetHeight()));}
return false;}
this.IsEmpty=function()
{return(self.Location.IsEmpty()&&self.Size.IsEmpty());}
this.Offset=function(pos)
{self.Location.Offset(pos);}
this.SetHeight=function(height)
{self.Size.Height=height;}
this.SetWidth=function(width)
{self.Size.Width=width;}
this.SetX=function(x)
{self.Location.X=x;}
this.SetY=function(y)
{self.Location.Y=y;}}
FreshLogicStudios.Scripts.Drawing.Rectangle.FromLTRB=function(left,top,right,bottom)
{var location=new FreshLogicStudios.Scripts.Drawing.Point(left,top);var size=new FreshLogicStudios.Scripts.Drawing.Size(right-left,bottom-top);return new FreshLogicStudios.Scripts.Drawing.Rectangle(location,size);}
FreshLogicStudios.Scripts.Drawing.Rectangle.Union=function(a,b)
{var x=Math.min(a.GetX(),b.GetX());var num2=Math.max(a.GetX()+a.GetWidth(),b.GetX()+b.GetWidth());var y=Math.min(a.GetY(),b.GetY());var num4=Math.max(a.GetY()+a.GetHeight(),b.GetY()+b.GetHeight());return new FreshLogicStudios.Scripts.Drawing.Rectangle(new FreshLogicStudios.Scripts.Drawing.Point(x,y),new FreshLogicStudios.Scripts.Drawing.Size(num2-x,num4-y));}
RegisterNamespace('FreshLogicStudios.Scripts.Drawing');FreshLogicStudios.Scripts.Drawing.Size=function(width,height)
{var self=this;this.Height=height||0;this.Width=width||0;this.Clone=function()
{return new FreshLogicStudios.Scripts.Drawing.Size(self.Width,self.Height);}
this.IsEmpty=function()
{return(self.Width==0&&self.Height==0);}}
RegisterNamespace('FreshLogicStudios.Scripts.Configuration.Settings');FreshLogicStudios.Scripts.Configuration.Settings=function(){}
FreshLogicStudios.Scripts.Configuration.Settings.Defaults=[];FreshLogicStudios.Scripts.Configuration.Settings.Load=function()
{FreshLogicStudios.Scripts.Configuration.Settings.LoadDefaults();for(var settingName in FreshLogicStudios.Scripts.Configuration.Settings.Defaults)
{FreshLogicStudios.Scripts.Configuration.Settings[settingName]=FreshLogicStudios.Scripts.Configuration.Settings.ReadCookie(settingName)||FreshLogicStudios.Scripts.Configuration.Settings.Defaults[settingName];}}
FreshLogicStudios.Scripts.Configuration.Settings.LoadDefaults=function(){}
FreshLogicStudios.Scripts.Configuration.Settings.Reset=function()
{for(var settingName in Settings)
{if(typeof Settings[settingName]!='function'&&Settings.Defaults[settingName])
{FreshLogicStudios.Scripts.Configuration.Settings[settingName]=FreshLogicStudios.Scripts.Configuration.Settings.Defaults[settingName];}}}
FreshLogicStudios.Scripts.Configuration.Settings.Save=function()
{for(var settingName in FreshLogicStudios.Scripts.Configuration.Settings)
{if(typeof FreshLogicStudios.Scripts.Configuration.Settings[settingName]!='function')
{FreshLogicStudios.Scripts.Configuration.Settings.CreateCookie(settingName,FreshLogicStudios.Scripts.Configuration.Settings[settingName],365);}}}
FreshLogicStudios.Scripts.Configuration.Settings.CreateCookie=function(name,value,days)
{if(days)
{var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires='; expires='+date.toGMTString();}
else
{expires='';}
document.cookie=name+'='+value+expires+'; path=/';}
FreshLogicStudios.Scripts.Configuration.Settings.DeleteCookie=function(name)
{FreshLogicStudios.Scripts.Configuration.Settings.CreateCookie(name,'',-1);}
FreshLogicStudios.Scripts.Configuration.Settings.ReadCookie=function(name)
{var nameEQ=name+'=';var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++)
{var c=ca[i];while(c.charAt(0)==' ')
{c=c.substring(1,c.length);}
if(c.indexOf(nameEQ)==0)
{return c.substring(nameEQ.length,c.length);}}
return null;}
RegisterNamespace('FreshLogicStudios.Scripts.Collections');FreshLogicStudios.Scripts.Collections.ArrayList=function()
{var self=this;var items=new Array();this.Events=new FreshLogicStudios.Scripts.EventCollection();function add(value)
{return items.push(value);}
function insert(index,value)
{if(index>-1&&index<=items.length)
{switch(index)
{case 0:items.unshift(value);break;case items.length:items.push(value);break;default:var head=items.slice(0,index-1);var tail=items.slice(index);items=items.concat(tail.unshift(value));break;}}}
function removeAt(index)
{if(items.length>0&&index>-1&&index<items.length)
{switch(index)
{case 0:items.shift();break;case items.length-1:items.pop();break;default:var head=items.slice(0,index);var tail=items.slice(index+1);items=head.concat(tail);break;}}}
this.Add=function(value)
{self.Events.Fire('AddingNew');var index=add(value);self.Events.Fire('ListChanged');return index;}
this.AddRange=function(value)
{self.Events.Fire('AddingNew');for(var i=0;i<value.length;i++)
{add(value[i]);}
self.Events.Fire('ListChanged');}
this.Clear=function()
{items=new Array();self.Events.Fire('ListChanged');}
this.Clone=function()
{var myArrayList=new FreshLogicStudios.Scripts.Collections.ArrayList();for(var i=0;i<items.length;i++)
{myArrayList.Add(items[i]);}
return myArrayList;}
this.Contains=function(object)
{return(self.IndexOf(object)!=-1);}
this.CopyTo=function(array)
{for(var i=0;i<items.length;i++)
{if(i<array.length)
{array[i]=items[i];}
else
{array.push(items[i]);}}}
this.GetCount=function()
{return items.length;}
this.GetItem=function(index)
{if(index>-1&&index<items.length)
{return items[index];}
else
{return undefined;}}
this.GetRange=function(index,count)
{var myArrayList=new FreshLogicStudios.Scripts.Collections.ArrayList();for(var i=index;i<items.length;i++)
{if(myArrayList.GetCount()==count)
{break;}
myArrayList.Add(items[i]);}
return myArrayList;}
this.IndexOf=function(value)
{var index=-1;for(var i=0;i<items.length;i++)
{if(items[i]==value)
{index=i;break;}}
return index;}
this.Insert=function(index,value)
{insert(index,value);self.Events.Fire('ListChanged');}
this.InsertRange=function(index,value)
{for(var i=value.length-1;i>=0;i--)
{insert(index,value[i]);}
self.Events.Fire('ListChanged');}
this.LastIndexOf=function(value)
{var index=-1;for(var i=items.length-1;i>=0;i--)
{if(items[i]==object)
{index=i;break;}}
return index;}
this.Remove=function(obj)
{var index=self.IndexOf(obj);if(index>=0)
{removeAt(index);self.Events.Fire('ListChanged');}}
this.RemoveAt=function(index)
{removeAt(index);self.Events.Fire('ListChanged');}
this.RemoveRange=function(index,count)
{for(var i=0;i<count;i++)
{removeAt(index);}
self.Events.Fire('ListChanged');}
this.Reverse=function()
{items.reverse();self.Events.Fire('ListChanged');}
this.SetItem=function(index,value)
{if(index>-1&&index<items.length)
{items[index]=value;self.Events.Fire('ListChanged');}}
this.SetRange=function(index,value)
{for(var i=0;i<value.length;i++)
{var setAt=index+i;if(setAt<items.length)
{items[setAt]=value[i];}
else
{add(value[i]);}}
self.Events.Fire('ListChanged');}
this.Sort=function(comparer)
{if(comparer)
{items.sort(comparer);}
else
{items.sort();}
self.Events.Fire('ListChanged');}
this.ToArray=function()
{var array=new Array();for(var i=0;i<items.length;i++)
{array.push(items[i]);}
return array;}
this.toString=function()
{return self.ToString();}
this.ToString=function(seperator)
{return self.ToArray().join(seperator);}}
// -----------------------------------------------------------------------------------
//
//	Lightbox v2.03.3
//	by Lokesh Dhakar - http://www.huddletogether.com
//	5/21/06
//
//	For more information on this script, visit:
//	http://huddletogether.com/projects/lightbox2/
//
//	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//	
//	Credit also due to those who have helped, inspired, and made their code available to the public.
//	Including: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), Thomas Fuchs(mir.aculo.us), and others.
//
//
// -----------------------------------------------------------------------------------
/*

	Table of Contents
	-----------------
	Configuration
	Global Variables

	Extending Built-in Objects	
	- Object.extend(Element)
	- Array.prototype.removeDuplicates()
	- Array.prototype.empty()

	Lightbox Class Declaration
	- initialize()
	- updateImageList()
	- start()
	- changeImage()
	- resizeImageContainer()
	- showImage()
	- updateDetails()
	- updateNav()
	- enableKeyboardNav()
	- disableKeyboardNav()
	- keyboardAction()
	- preloadNeighborImages()
	- end()
	
	Miscellaneous Functions
	- getPageScroll()
	- getPageSize()
	- getKey()
	- listenKey()
	- showSelectBoxes()
	- hideSelectBoxes()
	- showFlash()
	- hideFlash()
	- pause()
	- initLightbox()
	
	Function Calls
	- addLoadEvent(initLightbox)
	
*/
// -----------------------------------------------------------------------------------

//
//	Configuration
//
var fileLoadingImage = "http://www.nuparadigm.com/Images/Lightbox/loading.gif";		
var fileBottomNavCloseImage = "http://www.nuparadigm.com/Images/Lightbox/closelabel.gif";

var overlayOpacity = 0.8;	// controls transparency of shadow overlay

var animate = true;			// toggles resizing animations
var resizeSpeed = 7;		// controls the speed of the image resizing animations (1=slowest and 10=fastest)

var borderSize = 10;		//if you adjust the padding in the CSS, you will need to update this variable

// -----------------------------------------------------------------------------------

//
//	Global Variables
//
var imageArray = new Array;
var activeImage;

if(animate == true){
	overlayDuration = 0.2;	// shadow fade in/out duration
	if(resizeSpeed > 10){ resizeSpeed = 10;}
	if(resizeSpeed < 1){ resizeSpeed = 1;}
	resizeDuration = (11 - resizeSpeed) * 0.15;
} else { 
	overlayDuration = 0;
	resizeDuration = 0;
}

// -----------------------------------------------------------------------------------

//
//	Additional methods for Element added by SU, Couloir
//	- further additions by Lokesh Dhakar (huddletogether.com)
//
Object.extend(Element, {
	getWidth: function(element) {
	   	element = $(element);
	   	return element.offsetWidth; 
	},
	setWidth: function(element,w) {
	   	element = $(element);
    	element.style.width = w +"px";
	},
	setHeight: function(element,h) {
   		element = $(element);
    	element.style.height = h +"px";
	},
	setTop: function(element,t) {
	   	element = $(element);
    	element.style.top = t +"px";
	},
	setLeft: function(element,l) {
	   	element = $(element);
    	element.style.left = l +"px";
	},
	setSrc: function(element,src) {
    	element = $(element);
    	element.src = src; 
	},
	setHref: function(element,href) {
    	element = $(element);
    	element.href = href; 
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});

// -----------------------------------------------------------------------------------

//
//	Extending built-in Array object
//	- array.removeDuplicates()
//	- array.empty()
//
Array.prototype.removeDuplicates = function () {
    for(i = 0; i < this.length; i++){
        for(j = this.length-1; j>i; j--){        
            if(this[i][0] == this[j][0]){
                this.splice(j,1);
            }
        }
    }
}

// -----------------------------------------------------------------------------------

Array.prototype.empty = function () {
	for(i = 0; i <= this.length; i++){
		this.shift();
	}
}

// -----------------------------------------------------------------------------------

//
//	Lightbox Class Declaration
//	- initialize()
//	- start()
//	- changeImage()
//	- resizeImageContainer()
//	- showImage()
//	- updateDetails()
//	- updateNav()
//	- enableKeyboardNav()
//	- disableKeyboardNav()
//	- keyboardNavAction()
//	- preloadNeighborImages()
//	- end()
//
//	Structuring of code inspired by Scott Upton (http://www.uptonic.com/)
//
var Lightbox = Class.create();

Lightbox.prototype = {
	
	// initialize()
	// Constructor runs on completion of the DOM loading. Calls updateImageList and then
	// the function inserts html at the bottom of the page which is used to display the shadow 
	// overlay and the image container.
	//
	initialize: function() {	
		
		this.updateImageList();

		// Code inserts html at the bottom of the page that looks similar to this:
		//
		//	<div id="overlay"></div>
		//	<div id="lightbox">
		//		<div id="outerImageContainer">
		//			<div id="imageContainer">
		//				<img id="lightboxImage">
		//				<div style="" id="hoverNav">
		//					<a href="#" id="prevLink"></a>
		//					<a href="#" id="nextLink"></a>
		//				</div>
		//				<div id="loading">
		//					<a href="#" id="loadingLink">
		//						<img src="images/loading.gif">
		//					</a>
		//				</div>
		//			</div>
		//		</div>
		//		<div id="imageDataContainer">
		//			<div id="imageData">
		//				<div id="imageDetails">
		//					<span id="caption"></span>
		//					<span id="numberDisplay"></span>
		//				</div>
		//				<div id="bottomNav">
		//					<a href="#" id="bottomNavClose">
		//						<img src="images/close.gif">
		//					</a>
		//				</div>
		//			</div>
		//		</div>
		//	</div>


		var objBody = document.getElementsByTagName("body").item(0);
		
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.style.display = 'none';
		objOverlay.onclick = function() { myLightbox.end(); }
		objBody.appendChild(objOverlay);
		
		var objLightbox = document.createElement("div");
		objLightbox.setAttribute('id','lightbox');
		objLightbox.style.display = 'none';
		objLightbox.onclick = function(e) {	// close Lightbox is user clicks shadow overlay
			if (!e) var e = window.event;
			var clickObj = Event.element(e).id;
			if ( clickObj == 'lightbox') {
				myLightbox.end();
			}
		};
		objBody.appendChild(objLightbox);
			
		var objOuterImageContainer = document.createElement("div");
		objOuterImageContainer.setAttribute('id','outerImageContainer');
		objLightbox.appendChild(objOuterImageContainer);

		// When Lightbox starts it will resize itself from 250 by 250 to the current image dimension.
		// If animations are turned off, it will be hidden as to prevent a flicker of a
		// white 250 by 250 box.
		if(animate){
			Element.setWidth('outerImageContainer', 250);
			Element.setHeight('outerImageContainer', 250);			
		} else {
			Element.setWidth('outerImageContainer', 1);
			Element.setHeight('outerImageContainer', 1);			
		}

		var objImageContainer = document.createElement("div");
		objImageContainer.setAttribute('id','imageContainer');
		objOuterImageContainer.appendChild(objImageContainer);
	
		var objLightboxImage = document.createElement("img");
		objLightboxImage.setAttribute('id','lightboxImage');
		objImageContainer.appendChild(objLightboxImage);
	
		var objHoverNav = document.createElement("div");
		objHoverNav.setAttribute('id','hoverNav');
		objImageContainer.appendChild(objHoverNav);
	
		var objPrevLink = document.createElement("a");
		objPrevLink.setAttribute('id','prevLink');
		objPrevLink.setAttribute('href','#');
		objHoverNav.appendChild(objPrevLink);
		
		var objNextLink = document.createElement("a");
		objNextLink.setAttribute('id','nextLink');
		objNextLink.setAttribute('href','#');
		objHoverNav.appendChild(objNextLink);
	
		var objLoading = document.createElement("div");
		objLoading.setAttribute('id','loading');
		objImageContainer.appendChild(objLoading);
	
		var objLoadingLink = document.createElement("a");
		objLoadingLink.setAttribute('id','loadingLink');
		objLoadingLink.setAttribute('href','#');
		objLoadingLink.onclick = function() { myLightbox.end(); return false; }
		objLoading.appendChild(objLoadingLink);
	
		var objLoadingImage = document.createElement("img");
		objLoadingImage.setAttribute('src', fileLoadingImage);
		objLoadingLink.appendChild(objLoadingImage);

		var objImageDataContainer = document.createElement("div");
		objImageDataContainer.setAttribute('id','imageDataContainer');
		objLightbox.appendChild(objImageDataContainer);

		var objImageData = document.createElement("div");
		objImageData.setAttribute('id','imageData');
		objImageDataContainer.appendChild(objImageData);
	
		var objImageDetails = document.createElement("div");
		objImageDetails.setAttribute('id','imageDetails');
		objImageData.appendChild(objImageDetails);
	
		var objCaption = document.createElement("span");
		objCaption.setAttribute('id','caption');
		objImageDetails.appendChild(objCaption);
	
		var objNumberDisplay = document.createElement("span");
		objNumberDisplay.setAttribute('id','numberDisplay');
		objImageDetails.appendChild(objNumberDisplay);
		
		var objBottomNav = document.createElement("div");
		objBottomNav.setAttribute('id','bottomNav');
		objImageData.appendChild(objBottomNav);
	
		var objBottomNavCloseLink = document.createElement("a");
		objBottomNavCloseLink.setAttribute('id','bottomNavClose');
		objBottomNavCloseLink.setAttribute('href','#');
		objBottomNavCloseLink.onclick = function() { myLightbox.end(); return false; }
		objBottomNav.appendChild(objBottomNavCloseLink);
	
		var objBottomNavCloseImage = document.createElement("img");
		objBottomNavCloseImage.setAttribute('src', fileBottomNavCloseImage);
		objBottomNavCloseLink.appendChild(objBottomNavCloseImage);
	},


	//
	// updateImageList()
	// Loops through anchor tags looking for 'lightbox' references and applies onclick
	// events to appropriate links. You can rerun after dynamically adding images w/ajax.
	//
	updateImageList: function() {	
		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName('a');
		var areas = document.getElementsByTagName('area');

		// loop through all anchor tags
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			
			var relAttribute = String(anchor.getAttribute('rel'));
			
			// use the string.match() method to catch 'lightbox' references in the rel attribute
			if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
				anchor.onclick = function () {myLightbox.start(this); return false;}
			}
		}

		// loop through all area tags
		// todo: combine anchor & area tag loops
		for (var i=0; i< areas.length; i++){
			var area = areas[i];
			
			var relAttribute = String(area.getAttribute('rel'));
			
			// use the string.match() method to catch 'lightbox' references in the rel attribute
			if (area.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
				area.onclick = function () {myLightbox.start(this); return false;}
			}
		}
	},
	
	
	//
	//	start()
	//	Display overlay and lightbox. If image is part of a set, add siblings to imageArray.
	//
	start: function(imageLink) {	

		hideSelectBoxes();
		hideFlash();

		// stretch overlay to fill page and fade in
		var arrayPageSize = getPageSize();
		Element.setWidth('overlay', arrayPageSize[0]);
		Element.setHeight('overlay', arrayPageSize[1]);

		new Effect.Appear('overlay', { duration: overlayDuration, from: 0.0, to: overlayOpacity });

		imageArray = [];
		imageNum = 0;		

		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName( imageLink.tagName);

		// if image is NOT part of a set..
		if((imageLink.getAttribute('rel') == 'lightbox')){
			// add single image to imageArray
			imageArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title')));			
		} else {
		// if image is part of a set..

			// loop through anchors, find other images in set, and add them to imageArray
			for (var i=0; i<anchors.length; i++){
				var anchor = anchors[i];
				if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))){
					imageArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));
				}
			}
			imageArray.removeDuplicates();
			while(imageArray[imageNum][0] != imageLink.getAttribute('href')) { imageNum++;}
		}

		// calculate top and left offset for the lightbox 
		var arrayPageScroll = getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
		var lightboxLeft = arrayPageScroll[0];
		Element.setTop('lightbox', lightboxTop);
		Element.setLeft('lightbox', lightboxLeft);
		
		Element.show('lightbox');
		
		this.changeImage(imageNum);
	},

	//
	//	changeImage()
	//	Hide most elements and preload image in preparation for resizing image container.
	//
	changeImage: function(imageNum) {	
		
		activeImage = imageNum;	// update global var

		// hide elements during transition
		if(animate){ Element.show('loading');}
		Element.hide('lightboxImage');
		Element.hide('hoverNav');
		Element.hide('prevLink');
		Element.hide('nextLink');
		Element.hide('imageDataContainer');
		Element.hide('numberDisplay');		
		
		imgPreloader = new Image();
		
		// once image is preloaded, resize image container
		imgPreloader.onload=function(){
			Element.setSrc('lightboxImage', imageArray[activeImage][0]);
			myLightbox.resizeImageContainer(imgPreloader.width, imgPreloader.height);
			
			imgPreloader.onload=function(){};	//	clear onLoad, IE behaves irratically with animated gifs otherwise 
		}
		imgPreloader.src = imageArray[activeImage][0];
	},

	//
	//	resizeImageContainer()
	//
	resizeImageContainer: function( imgWidth, imgHeight) {

		// get curren width and height
		this.widthCurrent = Element.getWidth('outerImageContainer');
		this.heightCurrent = Element.getHeight('outerImageContainer');

		// get new width and height
		var widthNew = (imgWidth  + (borderSize * 2));
		var heightNew = (imgHeight  + (borderSize * 2));

		// scalars based on change from old to new
		this.xScale = ( widthNew / this.widthCurrent) * 100;
		this.yScale = ( heightNew / this.heightCurrent) * 100;

		// calculate size difference between new and old image, and resize if necessary
		wDiff = this.widthCurrent - widthNew;
		hDiff = this.heightCurrent - heightNew;

		if(!( hDiff == 0)){ new Effect.Scale('outerImageContainer', this.yScale, {scaleX: false, duration: resizeDuration, queue: 'front'}); }
		if(!( wDiff == 0)){ new Effect.Scale('outerImageContainer', this.xScale, {scaleY: false, delay: resizeDuration, duration: resizeDuration}); }

		// if new and old image are same size and no scaling transition is necessary, 
		// do a quick pause to prevent image flicker.
		if((hDiff == 0) && (wDiff == 0)){
			if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);} 
		}

		Element.setHeight('prevLink', imgHeight);
		Element.setHeight('nextLink', imgHeight);
		Element.setWidth( 'imageDataContainer', widthNew);

		this.showImage();
	},
	
	//
	//	showImage()
	//	Display image and begin preloading neighbors.
	//
	showImage: function(){
		Element.hide('loading');
		new Effect.Appear('lightboxImage', { duration: resizeDuration, queue: 'end', afterFinish: function(){	myLightbox.updateDetails(); } });
		this.preloadNeighborImages();
	},

	//
	//	updateDetails()
	//	Display caption, image number, and bottom nav.
	//
	updateDetails: function() {
	
		// if caption is not null
		if(imageArray[activeImage][1]){
			Element.show('caption');
			Element.setInnerHTML( 'caption', imageArray[activeImage][1]);
		}
		
		// if image is part of set display 'Image x of x' 
		if(imageArray.length > 1){
			Element.show('numberDisplay');
			Element.setInnerHTML( 'numberDisplay', "Image " + eval(activeImage + 1) + " of " + imageArray.length);
		}

		new Effect.Parallel(
			[ new Effect.SlideDown( 'imageDataContainer', { sync: true, duration: resizeDuration, from: 0.0, to: 1.0 }), 
			  new Effect.Appear('imageDataContainer', { sync: true, duration: resizeDuration }) ], 
			{ duration: resizeDuration, afterFinish: function() {
				// update overlay size and update nav
				var arrayPageSize = getPageSize();
				Element.setHeight('overlay', arrayPageSize[1]);
				myLightbox.updateNav();
				}
			} 
		);
	},

	//
	//	updateNav()
	//	Display appropriate previous and next hover navigation.
	//
	updateNav: function() {

		Element.show('hoverNav');				

		// if not first image in set, display prev image button
		if(activeImage != 0){
			Element.show('prevLink');
			document.getElementById('prevLink').onclick = function() {
				myLightbox.changeImage(activeImage - 1); return false;
			}
		}

		// if not last image in set, display next image button
		if(activeImage != (imageArray.length - 1)){
			Element.show('nextLink');
			document.getElementById('nextLink').onclick = function() {
				myLightbox.changeImage(activeImage + 1); return false;
			}
		}
		
		this.enableKeyboardNav();
	},

	//
	//	enableKeyboardNav()
	//
	enableKeyboardNav: function() {
		document.onkeydown = this.keyboardAction; 
	},

	//
	//	disableKeyboardNav()
	//
	disableKeyboardNav: function() {
		document.onkeydown = '';
	},

	//
	//	keyboardAction()
	//
	keyboardAction: function(e) {
		if (e == null) { // ie
			keycode = event.keyCode;
			escapeKey = 27;
		} else { // mozilla
			keycode = e.keyCode;
			escapeKey = e.DOM_VK_ESCAPE;
		}

		key = String.fromCharCode(keycode).toLowerCase();
		
		if((key == 'x') || (key == 'o') || (key == 'c') || (keycode == escapeKey)){	// close lightbox
			myLightbox.end();
		} else if((key == 'p') || (keycode == 37)){	// display previous image
			if(activeImage != 0){
				myLightbox.disableKeyboardNav();
				myLightbox.changeImage(activeImage - 1);
			}
		} else if((key == 'n') || (keycode == 39)){	// display next image
			if(activeImage != (imageArray.length - 1)){
				myLightbox.disableKeyboardNav();
				myLightbox.changeImage(activeImage + 1);
			}
		}

	},

	//
	//	preloadNeighborImages()
	//	Preload previous and next images.
	//
	preloadNeighborImages: function(){

		if((imageArray.length - 1) > activeImage){
			preloadNextImage = new Image();
			preloadNextImage.src = imageArray[activeImage + 1][0];
		}
		if(activeImage > 0){
			preloadPrevImage = new Image();
			preloadPrevImage.src = imageArray[activeImage - 1][0];
		}
	
	},

	//
	//	end()
	//
	end: function() {
		this.disableKeyboardNav();
		Element.hide('lightbox');
		new Effect.Fade('overlay', { duration: overlayDuration});
		showSelectBoxes();
		showFlash();
	}
}

// -----------------------------------------------------------------------------------

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.com
//
function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

// -----------------------------------------------------------------------------------

//
// getKey(key)
// Gets keycode. If 'x' is pressed then it hides the lightbox.
//
function getKey(e){
	if (e == null) { // ie
		keycode = event.keyCode;
	} else { // mozilla
		keycode = e.which;
	}
	key = String.fromCharCode(keycode).toLowerCase();
	
	if(key == 'x'){
	}
}

// -----------------------------------------------------------------------------------

//
// listenKey()
//
function listenKey () {	document.onkeypress = getKey; }
	
// ---------------------------------------------------

function showSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

// ---------------------------------------------------

function showFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "visible";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "hidden";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "hidden";
	}

}


// ---------------------------------------------------

//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Help from Ran Bar-On [ran2103@gmail.com]
//

function pause(ms){
	var date = new Date();
	curDate = null;
	do{var curDate = new Date();}
	while( curDate - date < ms);
}
/*
function pause(numberMillis) {
	var curently = new Date().getTime() + sender;
	while (new Date().getTime();	
}
*/
// ---------------------------------------------------



function initLightbox() { myLightbox = new Lightbox(); }
//Event.observe(window, 'load', initLightbox, false);
RegisterNamespace('MainMenu');

MainMenu.Element = null;
MainMenu.HeaderElement = null;
MainMenu.HeaderPosition = null;
MainMenu.MenuItems = new Array();

MainMenu.Initialize = function()
{
    MainMenu.Element = $('MainMenu');
    MainMenu.HeaderElement = $('Header');
    MainMenu.HeaderPosition = MainMenu.Element.positionedOffset();
    var mainMenuItems = MainMenu.Element.childElements();
        
    for(var i = 0, length = mainMenuItems.length; i < length; ++i)
    {
        MainMenu.MenuItems.push(new MainMenu.MenuItem(mainMenuItems[i]));
    }
}

MainMenu.MenuItem = function(element)
{
    // Private Members
    var currentEffect = null;
    var hoverElement = null; 
    var leftPosition = '';
    var self = this;
    
    
    // Public Properties
    this.Element = element;
    
    
    // Private Methods
    function Constructor()
    {
        var elementWidth = FreshLogicStudios.Scripts.String.Format('{0}px', self.Element.getWidth());
        var elementColor = FreshLogicStudios.Scripts.String.Format('rgb({0}, {1}, {2})', Math.floor(Math.random()*130), Math.floor(Math.random()*130), Math.floor(Math.random()*130));
        var elementLeft = self.Element.positionedOffset().left;
        
        leftPosition = elementLeft + MainMenu.HeaderPosition.left;
        hoverElement = new Element('div', {'class': 'HeaderHoverItem'}).setStyle({backgroundColor:elementColor, width:elementWidth, left:FreshLogicStudios.Scripts.String.Format('{0}px', leftPosition)});
        MainMenu.HeaderElement.appendChild(hoverElement);
        
        hoverElement.setStyle({left:FreshLogicStudios.Scripts.String.Format('{0}px', leftPosition)});
    
        AddEvent(self.Element, 'mouseover', OnMouseOver);
        AddEvent(self.Element, 'mouseout', OnMouseOut);
    }
    
    function OnMouseOver()
    {
        if(currentEffect)
        {
            currentEffect.cancel();
        }
        
        currentEffect = new Effect.Move(hoverElement, {duration:0.3, fps:90, x:leftPosition, y:0, mode:'absolute', afterFinish:function(){currentEffect = null;}});
    }
    
    function OnMouseOut()
    {
        if(currentEffect)
        {
            currentEffect.cancel();
        }
        
        currentEffect = new Effect.Move(hoverElement, {duration:0.3, fps:90, x:leftPosition, y:83, mode:'absolute', afterFinish:function(){currentEffect = null;}});
    }
    
    Constructor();
}
// Event Handlers
function Page_Load()
{
    // Add element for dropshadow style
    var dropShadow = document.createElement('div');
    dropShadow.className = 'DropShadow';
    document.body.appendChild(dropShadow);
    
    // Add element for clearing floating content so the footer is positioned on the bottom of all the content
    var contentClearingDiv = document.createElement('div');
    contentClearingDiv.style.clear = 'both';
    document.getElementById('Page').appendChild(contentClearingDiv);    
    
    // Add styling elements to the "side" menu
    var menu = $('Menu');    
    var menuHeader = new Element('div', {'class':'Header'});
    var menuFooter = new Element('div', {'class':'Footer'});
    
    if(menu.childNodes.length > 0)
    {
        menu.insertBefore(menuHeader, menu.childNodes[0]);
    }
    else
    {
        menu.appendChild(menuHeader);
    }
    
    menu.appendChild(menuFooter);

    // Initialize the main menu
    MainMenu.Initialize();
    
    // Initialize the lightbox
    initLightbox();
}

function RepaintMenu()
{
    try
    {
        var menu = $('Menu');
        var menuChildren = menu.childElements();
        var menuFooter = menuChildren[menuChildren.length - 1];
        
        menuFooter.style.display = 'none';
        menuFooter.style.display = 'block';
    }
    catch(e)
    {
        // error occurred during the repaint
    }
}

AddEvent(window, 'load', Page_Load);
