window.addEvent('load', function()
{

		 var carousel = new glow.widgets.Carousel("#carousel", {
				 id: "carousel-container",
		     loop: true
		 });	
		 	
			if ($('carousel-section'))
			{
		 var carouselSection = new glow.widgets.Carousel("#carousel-section", {
				 id: "carousel-section-container",
		     loop: true,
				 animDuration: 0.6
		 });
			}

	/*
	 * Home - Accordion
	 */
	 
	 if ($('accordion-home'))
	 {
		var accordionHome = new Fx.Accordion($$('#accordion-home .div-header'), $$('#accordion-home .div-content'),
		{
			show: 0,
			opacity: false,
			onActive: function(toggler, element)
			{
				toggler.getElement('a').addClass(toggler.getElement('a').get('class') + '-active');
			},
			onBackground: function(toggler, element)
			{
			    toggler.getElement('a').removeClass('branding-active').removeClass('web-development-active').removeClass('online-advertising-active').removeClass('web-video-active').removeClass('digital-signage-active');
			}	
		});
	 }
	     
     /*
      * Template - Callback
      */
      
     if ($('callback'))
     { 
         var callbackInfoSlide   = new Fx.Slide('callback-info').hide();
		     var callbackInfoOpacity = new Fx.Tween('callback-info', {property: 'opacity'});
         var callbackFormSlide   = new Fx.Slide('callback-content').hide();
		     var toggleButton        = glow.dom.get(".want-to-talk");
		 
			   $('callback-info').setStyle('display', 'block');
				 $('callback-content').setStyle('display', 'block');
		 
         var state = 'hidden';
         
         // Toggle Callback Form
         
         $('callback-toggler').addEvent('click', function(e)
         {
             e.stop();
             
             if (state == 'hidden')
             {
							   $('callback-info').getElement('img').setProperty('src', baseUrl + '/Themes/Kangaroo/Images/request-callback.gif');
							 
                 callbackInfoSlide.slideIn();
                 callbackFormSlide.slideIn();
                 toggleButton.css('background-position', '0 -40px');
								 
                 state = 'visible';
             }
             else
             {
                 callbackInfoSlide.slideOut();
                 callbackFormSlide.slideOut();
								 toggleButton.css('background-position', '0 0');
                 
                 state = 'hidden';
             }
         });
         
         // Submit Form
         
         $('callback-form').addEvent('submit', function(e)
         {
             e.stop();
			       state = 'hidden';
             callbackFormSlide.slideOut();
			 
             callbackInfoOpacity.start(1, 0).chain
						 (
						     function() { $('callback-info').getElement('img').setProperty('src', baseUrl + '/Themes/Kangaroo/Images/callback-requested.gif'); this.start(0, 1); },
				        (function() { callbackInfoSlide.slideOut(); }).delay(1300)
		         );
						 
						 this.send();
						 
         });
         
     }
		 
});

