
// for IE
window.onload = function() {
$$('.slideWrapper').each(function(element, index) {
	var title = element.getElement('.title'); // using class getting the each element
	var info  = element.getElement('.mssg');
	var thisSlide = new Fx.Slide(info); // applying Slide
	thisSlide.hide(); // default hide the slide
}); // . slideWrapper
}


window.addEvent('domready',function() {
	// OnLoad assign the onclick function to all the Titles to toggle the Mssg element
	$$('.slideWrapper').each(function(element, index) {
		var title = element.getElement('.title'); // using class getting the each element
		var info  = element.getElement('.mssg');
		var thisSlide = new Fx.Slide(info); // applying Slide
		thisSlide.hide(); // default hide the slide
		title.addEvent('click',function(e){
			e.stop();
			thisSlide.toggle();
			title.toggleClass('inView');
		});
	}); // . slideWrapper
	
	// Expand all by setting all the Mssg element to slideIn
	$('expandAll').addEvent('click',function(e) {
		e.stop();
		$$('.slideWrapper').each(function(element, index) {
			var title = element.getElement('.title');
			var info  = element.getElement('.mssg');
			var thisSlide = new Fx.Slide(info);
			title.addClass('inView');
			thisSlide.slideIn();
		}); // . slideWrapper
		$(this).setStyle('display','none');
		$('collapseAll').setStyle('display','block');
	}); // expandAll
	
	// Collapse All by setting all the Mssg element to slideOut
	$('collapseAll').addEvent('click',function(e) {
		e.stop();
		$$('.slideWrapper').each(function(element, index) {
			var title = element.getElement('.title');
			var info  = element.getElement('.mssg');
			var thisSlide = new Fx.Slide(info);
			title.removeClass('inView');
			thisSlide.slideOut();
		}); // . slideWrapper
		$(this).setStyle('display','none');
		$('expandAll').setStyle('display','block');		
	}); // collapseAll
}); // dom

//this function loop class .slideWrapper, find the $src (as a number) and expand it.
var expandSct = function(sct) {
	if (sct !== '')
	{
		$$('.slideWrapper').each(function(element, index) {
			if (index == sct)
			{
				var title = element.getElement('.title');
				var info  = element.getElement('.mssg');
				var thisSlide = new Fx.Slide(info);
				title.addClass('inView');
				thisSlide.slideIn();
				scrollToTop(element);
			}
		});
	}
}

var myWidth = 0, myHeight = 0;
function alertSize() {
 // var myWidth = 0, myHeight = 0;
 if( typeof( window.innerWidth ) == 'number' ) {
 //Non-IE
 myWidth = window.innerWidth;
 myHeight = window.innerHeight;
 } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
 //IE 6+ in 'standards compliant mode'
    // this one works in all the browsers IE7, IE6, FF2, FF3, GoogleC, Safari

    // GIVES THE WHOLE VIEWABLE AREA OF THE BROWSER

 myWidth = document.documentElement.clientWidth;
 myHeight = document.documentElement.clientHeight;
 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
 //IE 4 compatible
 myWidth = document.body.clientWidth;
 myHeight = document.body.clientHeight;
 }
 // window.alert( 'Width = ' + myWidth );
 // window.alert( 'Height = ' + myHeight );
}

function scrollToTop(el) {
	// before it scrolls add some extra space in the bottom
	alertSize();
	extraSpace = myHeight+(myHeight*.20);
	extraSpace = extraSpace+'px';
	// alert (extraSpace);
	// comment below line to remove extra space at the bottom
	$('footer').setStyle('padding-bottom',extraSpace);
	// comment below line to remove scrolling
	var myFx = new Fx.Scroll(window);
	myFx.toElement(el);
} 