﻿///<reference path="mootools-1.2.js" />
var scollMainContent = new Class({
    initialize : function () {
     this.c = $("mainHolder");
     if(!$chk(this.c)) return;
     var t = this.c.getScrollSize().y / this.c.getSize().y;
     if(t <= 1) return;
     t = Math.round(t);
     this.f = new Fx.Scroll(this.c, {"duration" : (t*1500)});
     this.ff = new Fx.Scroll(this.c, {"duration" : (t*400)});
     this.c.setStyles({"overflow": "hidden"});
     this.u = new Element("a", {"class" : "up"}).addEvent("mouseleave",this.cancel.bindWithEvent(this)).addEvent("mouseenter",this.goUp.bindWithEvent(this, this.f)).addEvent("mousedown",this.goUp.bindWithEvent(this, this.ff)).inject($("mainTop"));
     this.d = new Element("a", {"class" : "down"}).addEvent("mouseleave",this.cancel.bindWithEvent(this)).addEvent("mouseenter",this.goDown.bindWithEvent(this, this.f)).addEvent("mousedown",this.goDown.bindWithEvent(this, this.ff)).inject($("mainBottom"));
     this.c.addEvent("mousewheel",this.wheel.bindWithEvent(this));
    },
    wheel : function(ev) {
        this.cancel();
        this.f.set(0, this.c.getScroll().y - 5*ev.wheel);
    },
    goUp : function (ev, ef) {
        this.cancel();
        ef.toTop();
    },
    goDown : function (ev, ef) {
        this.cancel();
        ef.toBottom();
    },
    cancel : function () {
        this.f.cancel();
        this.ff.cancel();
        
    }
});
var makeAccordion = new Class({
    initialize : function () {
        $$('.accordion').each(function(elt){
            elt.getElements('a.toggler').setStyle("cursor","pointer");
            new Accordion(elt, 'a.toggler', 'div.element',{alwaysHide: true, show:-1, opacity:false});
        }, this);
    }
});

window.addEvent("domready", function () {new scollMainContent(); new makeAccordion();});
var Diaporama = new Class({
    initialize: function (urlList, contid, slidenum) {
        if (urlList.length <= 1) return;
        //$(contid).setStyle("background-image","none");

        this.c = $chk($(contid).getElement("div.diap")) ?
             $(contid).getElement("div.diap") : new Element("div", { "class": "diap", "styles": { "cursor": "pointer", "width": "100%", "height": "100%"} }).inject($(contid));
             
        if (!$chk(slidenum)) slidenum = $random(1,urlList.length -1 );
        this.s = new Slideshow(this.c, urlList, { height: 450, width: 255, delay: 7000, controller: true, random: true });
        return;

    }
});
