/**/

var Site = {
    // clears and restores default value on searchform input field
    initFocus: function() {
        var iFocus = new inputFocus({
            form_id: 'searchform',
            setborder : false,
            txtcolor : '#3d3d3d',
            bgcolor : '#fefa8f',
            duration : 0
        });
    },
    // yellow background-color on all input fields
    initClear: function() {
        var iClear1 = new inputClear({  
            collection: $$('input[type=text], input[type=password]')  
        }); 
    },
    // generic button hover css effect
    initButtons: function() {
        var Button = new buttonHover({  
            collection: $$('button')  
        }); 
    },
    // prints the page
    initWindowPrint: function() {
        var print = new windowPrint({  
            collection: $$('a.print')  
        }); 
    },
        
    // opens popup windows in an unobstrusive way
    initPopUps: function() {
        var PopUp = new openPopUp({  
            collection: $$('a.popup')  
        }); 
    },
    
    // opens popup windows in an unobstrusive way
    initRemooz: function() {
        ReMooz.assign('#content .graphicbox a.enlarge', {
            'origin': 'img',
            'shadow': 'onOpen', // fx is faster because shadow appears after resize animation
            'resizeFactor': 0.9, // resize to maximum 80% of screen size
            'cutOut': false, // don't hide the original
            'opacityResize': 0.4, // opaque resize
            'dragging': false, // disable dragging
            'centered': true // resize to center of the screen, not relative to the source element
        });
    },
    
    //Scrolls the window to the top
    initScrollTop: function() {
        $(document.body).getElements('a[href$=top]').addEvents({
            'click': function(e){
                evt = new Event(e);
                var myFx = new Fx.Scroll(window, {
                    duration: 1000,
                    transition: Fx.Transitions.Sine.easeOut,
                    wait: false
                }).toTop()
                evt.stop();
                }
        });
    },
    
    // switches different style-sheets and sets a cookie
    initStyleSwitcher: function() {
        var StyleSwitch = new styleSwitcher({  
            collection: $$('#styleswitcher a'),
            stylepath: './common/css/',
            duration: ''
        }); 
    },
    // style-up form fields (renal pharma: radio-button login)
    initCFE: function() {
        var myCfe = new cfe.base(true); 
        // initialize cfe
        //myCfe.init({spacer: "/files/spacer.gif", toolTipsStyle: "normal"});
        myCfe.init({spacer: "/files/spacer.gif", toolTipsStyle: "normal"});
    },
    // form validation loginform
    initFormCheck: function() {
        var checklogin =  new FormCheck('loginform', {
            display : {
                showErrors : 0,    
                indicateErrors : 1,
                errorsLocation: 1,
                tipsPosition: 'left',
                tipsOffsetX: -30,
                addClassErrorToField: 'error',
                closeTipsButton : 1,
                flashTips : 1
            }            
        })
    },
    // search results selct onchange submit
    initSelectOnChange: function() {
        var selectChange = new selectOnChange ({  
            collection: $$('.select').getFirst('select')
        }); 
    },
            
    initSitemap: function() {
    
        $$('.sitemap .toggler').each(function(el) {  
            el.addEvent('click', function() { 
                var elnext = el.getNext();
                new Fx.Reveal(elnext, {duration: 500, mode: 'vertical',  onShow: function(){ el.removeClass('open'); }, onHide: function(){ el.addClass('open'); }  }).toggle();
            });  
            
        });  
                
        
        if ($('closeall') && $('showall')) {
            // set close all event
            $('closeall').addEvents({'click': function(){
                    $$('.stretcher').dissolve().getPrevious().addClass('open');
            }});
            // set show all event
            $('showall').addEvents({'click': function(){
                    $$('.stretcher').reveal().getPrevious().removeClass('open');
            }});
        }
    }
}

window.addEvent('domready', function(){ 
        Site.initStyleSwitcher();
        Site.initClear();
        Site.initFocus(); 
        Site.initButtons();
        Site.initScrollTop(); 
        Site.initPopUps();
        Site.initWindowPrint();
        Site.initRemooz();
        Site.initSitemap();
        Site.initCFE();
        /*Site.initFormCheck();*/
        Site.initSelectOnChange();
        urchinTracker();
    });

