var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""
//Loading Anim
var loading_gif = new Image();
loading_gif.src = 'img/loading.gif';
function replace_html(id, mainContent) {
    document.getElementById(id).innerHTML = mainContent;
}
function show_loading(id) {
    replace_html(id, '<div id="loading" align="center"><img src="img/loading.gif" border="0" alt="Loading, please wait..." /></div>');
}
//End Loading Anim
//Groovy AJAX client check, and http-request
function ajaxpage(url, containerid){
    var page_request = false
    if (window.XMLHttpRequest) // if Mozilla, Safari etc
        page_request = new XMLHttpRequest()
    else if (window.ActiveXObject){ // if IE
        try {
            page_request = new ActiveXObject("Msxml2.XMLHTTP")
        }
        catch (e){
            try{
                page_request = new ActiveXObject("Microsoft.XMLHTTP")
            }
            catch (e){}
        }
    }
    else
        return false
    page_request.onreadystatechange=function(){
        loadpage(page_request, containerid)
    }
    if (bustcachevar) //if bust caching of external page
        bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
    page_request.open('GET', url+bustcacheparameter, true)
    page_request.send(null)
}

function loadpage(page_request, containerid){
    show_loading('mainContent');
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
        document.getElementById(containerid).innerHTML=page_request.responseText;
    //var PhotoNav = new Tips($$('.thumbnail'));
    //var PhotoTip = new Tips($$('.photo'));
    Slimbox.scanPage();
//var scrollBox1 = new MooScroll({selector:'.html'});
//var scrollBox2 = new MooScroll({selector:'.body'});
}

function loadobjs(){
    if (!document.getElementById)
        return
    for (i=0; i<arguments.length; i++){
        var file=arguments[i]
        var fileref=""
        if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
            if (file.indexOf(".js")!=-1){ //If object is a js file
                fileref=document.createElement('script')
                fileref.setAttribute("type","text/javascript");
                fileref.setAttribute("src", file);
            }
            else if (file.indexOf(".css")!=-1){ //If object is a css file
                fileref=document.createElement("link")
                fileref.setAttribute("rel", "stylesheet");
                fileref.setAttribute("type", "text/css");
                fileref.setAttribute("href", file);
            }
        }
        if (fileref!=""){
            document.getElementsByTagName("head").item(0).appendChild(fileref)
            loadedobjects+=file+" " //Remember this object as being already added to page
        }
    }
}
var Static=new Native({
    name:"Static",
    initialize:function(b){
        var a=Class(b);return new a
    }
});

var linksFloat=new Static({
    init:function(){
        if($("links")){
            Weather.init();Weather.random()
        }
    }
});

var Weather=new Static({
    Implements:[Events,Options],
    options:{
        checkPause:30000
    },
    types:Browser.Engine.trident4?["cloudy","cloudyRainy"]:["cloudy","cloudyRainy"],
    init:function(b){
        this.setOptions(b);
    },
    checkPause:function(){
        if(!this.current){
            return
        }this.pause();if(!this.pauseEvent){
            $(document.body).addEvent("mousemove",function(){
                this.resume();$(document.body).removeEvents("mousemove");this.pauseEvent=false
            }.bind(this));this.pauseEvent=true
        }
    },
    pause:function(){
        this.current.pause();return this
    },
    resume:function(){
        this.current.resume();return this
    },
    //set boundries in following function for height of bounding
    set:function(type){
        this.cancel();var klass=eval(type.capitalize()+"Weather");this.current=new klass("mainContainer",{
            boundaries:[120,400]
        });
    },
    random:function(){
        this.set(this.types.getRandom())
    },
    setIntensity:function(a){
        this.current.setIntensity(a);this.fireEvent("intensityChange")
    },
    cancel:function(){
        if(this.current){
            this.current.destroy()
        }this.current=null
    }
});

var WeatherType=new Class({
    Implements:[Options,Events],
    options:{
        intensity:5
    },
    setIntensity:function(a){
        this.options.intensity=a
    },
    destroy:function(){},
    pause:function(){},
    resume:function(){}
});

var CloudyWeather=new Class({
    Extends:WeatherType,
    description:"Cloudy",
    clouds:[],
    options:{
        boundaries:[0,10],
        cloudStyles:["fat","long","itunes","jb","myspace","tux","rabbit","kiss"]
    },
    initialize:function(a,b){
        this.setOptions(b);this.container=$(a);this.width=this.container.offsetWidth;this.options.intensity.times(this.addCloud,this)
    },
    setIntensity:function(a){
        if(a>this.options.intensity){
            (a-this.options.intensity).times(function(){
                this.addCloud()
            },this)
        }else{
            if(a!=this.options.intensity){
                (this.options.intensity-a).times(function(){
                    this.destroyCloud(this.clouds.getRandom())
                },this)
            }
        }this.parent()
    },
    addCloud:function(d){
        var b=this.options.cloudStyles.getRandom();var a=new Element("div",$merge({
            id:"weather-cloud-"+this.clouds.length,
            "class":"weather-element weather-cloud weather-cloud-"+b,
            styles:{
                top:$random.run(this.options.boundaries)
            }
        },d||{})).inject(this.container).store("cloudstyle",b);if(!Browser.Engine.trident){
            a.set("opacity",0.8)
        }a.setStyle("left",$random(0,this.width-a.offsetWidth)).store("fx1",new Fx.Tween(a,{
            onComplete:function(){
                this.animate(a)
            }.bind(this),
            transition:Fx.Transitions.Sine.easeInOut,
            duration:$random(15000,30000)
        })).addEvent("click",function(){
            this.destroyCloud(a)
        }.bind(this)).makeDraggable({
            onStart:function(){
                a.retrieve("fx1").cancel();if(!Browser.Engine.trident){
                    a.set("opacity",0.5)
                }
            },
            onComplete:function(){
                if(!Browser.Engine.trident){
                    a.set("opacity",0.8)
                }this.dragged=true;this.animate(a)
            }.bind(this)
        });this.clouds.push(a);this.animate(a);this.intensity=this.clouds.length;this.fireEvent("intensityChange");return a
    },
    animate:function(a){
        a.retrieve("fx1").start("left",null,$random(0,this.width-a.offsetWidth))
    },
    destroyCloud:function(a){
        if(this.dragged){
            this.dragged=false;return false
        }if($type(a)=="element"){
            a=this.clouds.indexOf(a)
        }c=this.clouds[a];c.retrieve("fx1").cancel();c.morph({
            opacity:0,
            "margin-top":-20
        }).get("morph").chain(function(){
            c.destroy()
        });delete this.clouds[a];this.intensity=this.clouds.length;this.fireEvent("intensityChange")
    },
    destroy:function(){
        this.clouds.each(function(a){
            this.destroyCloud(a)
        },this)
    },
    pause:function(){
        this.clouds.each(function(a){
            a.retrieve("fx1").pause()
        })
    },
    resume:function(){
        this.clouds.each(function(a){
            a.retrieve("fx1").resume()
        })
    }
});

var CloudyRainyWeather=new Class({
    Extends:CloudyWeather,
    description:"Cloudy and rainy",
    options:{
        rainPadding:15
    },
    addCloud:function(b){
        var a=this.parent(b);a.addEvents({
            mouseenter:function(){
                this.rain(a)
            }.bind(this),
            mouseleave:function(){
                this.rainClear(a)
            }.bind(this)
        });return a
    },
    rain:function(b){
        if(!b.retrieve("raining")){
            b.store("raining",this.rain.periodical(250,this,b))
        }var a=b.getCoordinates(this.container);$random(0,5).times(function(){
            var d=new Element("div",{
                "class":"weather-element weather-raindrop"
            }).inject(this.container);d.set("styles",{
                left:$random(a.left+this.options.rainPadding,a.right-this.options.rainPadding),
                top:a.bottom-d.offsetHeight
            });d.set("tween",{
                duration:$random(500,700)
            });d.tween("margin-top",$random(50,100));if(Browser.Engine.trident){
                d.PNGFix();(function(){
                    d.setStyle("display","none")
                }).delay(300)
            }else{
                d.morph({
                    opacity:0
                }).get("morph").chain(function(){
                    d.destroy()
                })
            }
        },this)
    },
    rainClear:function(a){
        $clear(a.retrieve("raining"));a.store("raining",false)
    },
    destroyCloud:function(a){
        if($type(a)=="element"){
            a=this.clouds.indexOf(a)
        }c=this.clouds[a];this.rainClear(c);this.parent(a)
    }
});

/*
	Slimbox v1.7 - The ultimate lightweight Lightbox clone
	(c) 2007-2009 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
var Slimbox=(function(){
    var F=window,n=Browser.Engine.trident4,u,g,G=-1,o,w,E,v,y,M,s,m={},t=new Image(),K=new Image(),I,a,h,q,J,e,H,c,A,L,x,i,d,C;F.addEvent("domready",function(){
        $(document.body).adopt($$(I=new Element("div",{
            id:"lbOverlay",
            events:{
                click:D
            }
        }),a=new Element("div",{
            id:"lbCenter"
        }),H=new Element("div",{
            id:"lbBottomContainer"
        })).setStyle("display","none"));h=new Element("div",{
            id:"lbImage"
        }).injectInside(a).adopt(q=new Element("div",{
            styles:{
                position:"relative"
            }
        }).adopt(J=new Element("a",{
            id:"lbPrevLink",
            href:"#",
            events:{
                click:B
            }
        }),e=new Element("a",{
            id:"lbNextLink",
            href:"#",
            events:{
                click:f
            }
        })));c=new Element("div",{
            id:"lbBottom"
        }).injectInside(H).adopt(new Element("a",{
            id:"lbCloseLink",
            href:"#",
            events:{
                click:D
            }
        }),A=new Element("div",{
            id:"lbCaption"
        }),L=new Element("div",{
            id:"lbNumber"
        }),new Element("div",{
            styles:{
                clear:"both"
            }
        }))
    });function z(){
        var N=F.getScroll(),O=F.getSize();$$(a,H).setStyle("left",N.x+(O.x/2));if(v){
            I.setStyles({
                left:N.x,
                top:N.y,
                width:O.x,
                height:O.y
            })
        }
    }function l(N){
        ["object",n?"select":"embed"].forEach(function(P){
            Array.forEach(document.getElementsByTagName(P),function(Q){
                if(N){
                    Q._slimbox=Q.style.visibility
                }Q.style.visibility=N?"hidden":Q._slimbox
            })
        });I.style.display=N?"":"none";var O=N?"addEvent":"removeEvent";F[O]("scroll",z)[O]("resize",z);document[O]("keydown",p)
    }function p(O){
        var N=O.code;return u.closeKeys.contains(N)?D():u.nextKeys.contains(N)?f():u.previousKeys.contains(N)?B():false
    }function B(){
        return b(w)
    }function f(){
        return b(E)
    }function b(N){
        if(N>=0){
            G=N;o=g[N][0];w=(G||(u.loop?g.length:0))-1;E=((G+1)%g.length)||(u.loop?0:-1);r();a.className="lbLoading";m=new Image();m.onload=k;m.src=o
        }return false
    }function k(){
        a.className="";d.set(0);h.setStyles({
            backgroundImage:"url("+o+")",
            display:""
        });q.setStyle("width",m.width);$$(q,J,e).setStyle("height",m.height);A.set("html",g[G][1]||"");L.set("html",(((g.length>1)&&u.counterText)||"").replace(/{x}/,G+1).replace(/{y}/,g.length));if(w>=0){
            t.src=g[w][0]
        }if(E>=0){
            K.src=g[E][0]
        }M=h.offsetWidth;s=h.offsetHeight;var P=Math.max(0,y-(s/2)),N=0,O;if(a.offsetHeight!=s){
            N=i.start({
                height:s,
                top:P
            })
        }if(a.offsetWidth!=M){
            N=i.start({
                width:M,
                marginLeft:-M/2
            })
        }O=function(){
            H.setStyles({
                width:M,
                top:P+s,
                marginLeft:-M/2,
                visibility:"hidden",
                display:""
            });d.start(1)
        };if(N){
            i.chain(O)
        }else{
            O()
        }
    }function j(){
        if(w>=0){
            J.style.display=""
        }if(E>=0){
            e.style.display=""
        }C.set(-c.offsetHeight).start(0);H.style.visibility=""
    }function r(){
        m.onload=$empty;m.src=t.src=K.src=o;i.cancel();d.cancel();C.cancel();$$(J,e,h,H).setStyle("display","none")
    }function D(){
        if(G>=0){
            r();G=w=E=-1;a.style.display="none";x.cancel().chain(l).start(0)
        }return false
    }Element.implement({
        slimbox:function(N,O){
            $$(this).slimbox(N,O);return this
        }
    });Elements.implement({
        slimbox:function(N,Q,P){
            Q=Q||function(R){
                return[R.href,R.title]
            };P=P||function(){
                return true
            };var O=this;O.removeEvents("click").addEvent("click",function(){
                var R=O.filter(P,this);return Slimbox.open(R.map(Q),R.indexOf(this),N)
            });return O
        }
    });return{
        open:function(P,O,N){
            u=$extend({
                loop:false,
                overlayOpacity:0.8,
                overlayFadeDuration:400,
                resizeDuration:400,
                resizeTransition:false,
                initialWidth:250,
                initialHeight:250,
                imageFadeDuration:400,
                captionAnimationDuration:400,
                counterText:"Image {x} of {y}",
                closeKeys:[27,88,67],
                previousKeys:[37,80],
                nextKeys:[39,78]
            },N||{});x=new Fx.Tween(I,{
                property:"opacity",
                duration:u.overlayFadeDuration
            });i=new Fx.Morph(a,$extend({
                duration:u.resizeDuration,
                link:"chain"
            },u.resizeTransition?{
                transition:u.resizeTransition
            }:{}));d=new Fx.Tween(h,{
                property:"opacity",
                duration:u.imageFadeDuration,
                onComplete:j
            });C=new Fx.Tween(c,{
                property:"margin-top",
                duration:u.captionAnimationDuration
            });if(typeof P=="string"){
                P=[[P,O]];O=0
            }y=F.getScrollTop()+(F.getHeight()/2);M=u.initialWidth;s=u.initialHeight;a.setStyles({
                top:Math.max(0,y-(s/2)),
                width:M,
                height:s,
                marginLeft:-M/2,
                display:""
            });v=n||(I.currentStyle&&(I.currentStyle.position!="fixed"));if(v){
                I.style.position="absolute"
            }x.set(0).start(u.overlayOpacity);z();l(1);g=P;u.loop=u.loop&&(g.length>1);return b(O)
        }
    }
})();

// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
Slimbox.scanPage = function() {
    $$(document.links).filter(function(el) {
        return el.rel && el.rel.test(/^lightbox/i);
    }).slimbox({/* Put custom options here */}, null, function(el) {
        return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
    });
};
//window.addEvent("domready", Slimbox.scanPage);