
var toggle = 0;

// Event Assignment 

window.addEvent('domready', function() 
{	
	initEffects();
	//initButton();	
});

function initEffects()
{
	if(!(BrowserDetect.browser == 'Explorer' && BrowserDetect.version < 6))
	{
		setEffect.delay(8000);
	}
	
	var el = $('text-bck-div');
	var myFx = new Fx.Morph(el);
	myFx.set({'opacity': 0.85});
}
var setEffect = function()
{
	var morphElement = $('back-wrapper');
	setSlideShow(morphElement);
	setSlideShow.periodical(60000, this, [morphElement]);
}

function setSlideShow(morphElement)
{
    var myFx = new Fx.Morph(morphElement, { duration: 2500, transition: Fx.Transitions.Sine.easeOut}); 
    myFx.start({'opacity': 0}).chain( 
        function(){ this.start({'opacity': 1});$('back-wrapper').addClass('img2').removeClass('img1'); }, 
        function(){ this.start.delay(8000, this, {'opacity': 0}); }, 
        function(){ this.start({'opacity': 1});$('back-wrapper').addClass('img3').removeClass('img2'); },
	    function(){ this.start.delay(8000, this, {'opacity': 0}); }, 
        function(){ this.start({'opacity': 1});$('back-wrapper').addClass('img4').removeClass('img3'); },	
	    function(){ this.start.delay(8000, this, {'opacity': 0}); }, 
        function(){ this.start({'opacity': 1});$('back-wrapper').addClass('img1').removeClass('img4'); }

    ); 
}
function initButton()
{
    var el = $('btn');
    var txtbx = $('text-div');
    
    var exTxt = $('extra-text');

	var myFx = new Fx.Morph(exTxt);
	myFx.set({'opacity': 0});
	
	el.addClass('up');
	el.setAttribute('title', 'More');
    
	el.addEvents({
	    click: function ()
	        {
	            if(toggle == 0){
	                txtbx.morph({'height' : 730 });
	                delayedFadeIn.delay(800);
	                toggle = 1;
	                el.addClass('down');
	                el.removeClass('up');
	                el.setAttribute('title', 'Return');
	            }
	            else
	            {
	                txtbx.morph({'height' : 365 });
                	myFx.set({'opacity': 0});
	                toggle = 0;
	                el.addClass('up');
	                el.removeClass('down');
                	el.setAttribute('title', 'More');
	            }
            }
   	});  
}

function delayedFadeIn()
{
    var exTxt = $('extra-text');
    exTxt.morph({'opacity' : 1 });
}


