// JavaScript Document

// adds the default Scroll functionality as overlay on the container
/* $Id: init-scrollers.js 242 2009-12-22 14:31:24Z pn $ */

window.addEvent('load', function() {
         // create scroller with settings
	if ($('imagebox')) {
		 $('imagebox').setStyle('overflow-x', 'hidden');
         
		 var scroll2 = new Scroller('imagebox', {area: 150, velocity: 0.3});
	         scroll2.start();
        	 $('imagebox').addEvent('mouseover', scroll2.start.bind(scroll2));
         	 $('imagebox').addEvent('mouseout', scroll2.stop.bind(scroll2));
		 
	}

	if (($('template1') || $('template2') || $('template3')) && $('content-main')) {
		 $('content-main').setStyle('overflow-x', 'hidden');
		
		 var scrollContent = new Scroller('content-main', {area: 150, velocity: 0.3});
	         scrollContent.start();
        	 $('content-main').addEvent('mouseover', scrollContent.start.bind(scrollContent));
         	 $('content-main').addEvent('mouseout', scrollContent.stop.bind(scrollContent));
	}

});

// adds the scrolling functionality to the two images (RemoteScroller)
window.addEvent('load', function() {        // should NOT be 'domready', coz rendering is not ready then (unable to fetch dimensions)
	var scrollSettingsImg = {
		container:$('imagebox'),    // Reference to container to scroll (mandatory)
		startEvent:'mouseover',             // Trigger scrollstart whithin this event (mandatory)
		stopEvent:'mouseout',                // Trigger scrollstop whithin this event (mandatory)
		buttons:{
			left:$('img-scroll-right'),           // References to the elements to be used as buttons (minimum 1 is obviously mandatory)
			right:$('img-scroll-left')         // does not trigger an error when empty
			// up:$('scrollUp'),
			// down:$('scrollDown')
		}/*,
                                hideScrollBars:true,                            // Hide scrollbars (optional)
                                onscrollstart:console.log,                      // Reference to function to be triggered on start of scrolling (optional)
                                onscrollstop:console.log,                       // Reference to function to be triggered on stop of scrolling (optional)
                                fps:25,                                         // Frames per second (optional, defaults to 25)
                                step:20                                         // Pixels to be scrolled by 1 frame (optional, defaults to 20)
		*/
	}
	if ($('imagebox')) {
		window.rcImg = new RemoteScroller(scrollSettingsImg);
	}
});

window.addEvent('load', function() {        // should NOT be 'domready', coz rendering is not ready then (unable to fetch dimensions)
	var scrollSettingsContent = {
		container:$('content-main'),    // Reference to container to scroll (mandatory)
		startEvent:'mouseover',             // Trigger scrollstart whithin this event (mandatory)
		stopEvent:'mouseout',                // Trigger scrollstop whithin this event (mandatory)
		buttons:{
			left:$('content-scroll-right'),           // References to the elements to be used as buttons (minimum 1 is obviously mandatory)
			right:$('content-scroll-left')         // does not trigger an error when empty
			// up:$('scrollUp'),
			// down:$('scrollDown')
		}/*,
                                hideScrollBars:true,                            // Hide scrollbars (optional)
                                onscrollstart:console.log,                      // Reference to function to be triggered on start of scrolling (optional)
                                onscrollstop:console.log,                       // Reference to function to be triggered on stop of scrolling (optional)
                                fps:25,                                         // Frames per second (optional, defaults to 25)
                                step:20                                         // Pixels to be scrolled by 1 frame (optional, defaults to 20)
		*/
	}
	if ($('content-main')) {
		window.rcContent = new RemoteScroller(scrollSettingsContent);
	}
});

// --------------------------------------------------------------------------------------- 
// --------------------------------------------------------------------------------------- 
// --------------------------------------------------------------------------------------- 
/**
 * for ie only, debugging/logging only
 */
if (typeof console == 'undefined') {
	var console = {
		log:function(thing) {
			if (typeof thing.id != 'undefined')
				document.body.appendChild(document.createTextNode(this.id))
			else
				document.body.appendChild(document.createTextNode(thing));
		}
	}
}

