/* Homepage Effects


*/
window.addEvent('domready', function(){
									 
	/**
	HAccordion
	**/
	
	var moveAmount, interval, opened = 1; 
	
	interval = $E('h6', 'pleah').getStyle('width').toInt();
	moveAmount = $('pleah').getStyle('width').toInt() - interval * $$('#pleah .acContent h6').length; 
	
	var pleahs = $$("#pleah .acContent");
	
	var pleahFx = new Fx.Elements(pleahs, {wait: true, duration: 600});
	var o = {};
	pleahs.each(function(pleah, i) {
		//script to choose which div to be opened default
		if (i == (opened - 1)) { 
			pleah.addClass('active'); //setting the class for 'active' div [active is a CSS classname]
		}
		if (i == opened) { 
			pleah.setStyle("left", (i * interval) + moveAmount); //this is the default opened div
		}
		else if (i < opened) {
			pleah.setStyle("left", (i * interval)); //other div s which are left to opened
		}
		else if(i > opened) {
			pleah.setStyle("left", (i * interval) + moveAmount); //other div s which are right to opened
		}
		
		pleah.addEvent("mousedown", function(event) {
			pleah.addClass('active'); //setting the class for 'active' div
			var l = pleah.getStyle("left").toInt()
			o[i] = {left: [l, i * interval]}
			pleahs.each(function(other, j) {
				var l2 = other.getStyle("left").toInt();
				if(i > j) {
					o[j] = {left: [l2, j * interval]};
					other.removeClass('active'); // removing class from other divs
				}
				if(i < j) {
					o[j] = {left: [l2, (j * interval) + moveAmount]};
					other.removeClass('active'); // removing class from other divs
				}
			});
			pleahFx.start(o);
		});
	});
	
});
