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

// Start Contact Form
$('myForm').addEvent('submit', function(e) {

	new Event(e).stop();
	var log = $('log_res').empty().addClass('ajax-loading');
	this.send({
		update: log,
		onComplete: function() {
		log.removeClass('ajax-loading');
	}
	});
	});		
// End Form -- Start Portfolio Display

	var moveAmount = 387, interval = 36, opened = 1;
 	var accs = $$("#acc .job_content");
 	var accFx = new Fx.Elements(accs, {wait: false, duration: 500, transition: Fx.Transitions.Expo.easeOut});
	var o = {};
	accs.each(function(acc, i) {
		//script to choose which div to be opened default
		if (i == (opened - 1)) { 
			acc.addClass('active'); //setting the class for 'active' div [active is a CSS classname]
		}
		if (i == opened) { 
			acc.setStyle("left", (i * interval) + moveAmount); //this is the default opened div
			$$('.active h2').setStyle('background-position', '0 0');
			$$('.active span').setStyle('visibility', 'visible');
		}
		else if (i < opened) {
			acc.setStyle("left", (i * interval)); //other divs which are left to opened
		}
		else if(i > opened) {
			acc.setStyle("left", (i * interval) + moveAmount); //other div s which are right to opened
		}
 
		acc.getElement('h2').addEvent("mousedown", function(event) {
		var my_slide = new Fx.Slide(acc.getElement(".slider")).hide();
			acc.addClass('active'); //setting the class for 'active' div
			var l = acc.getStyle("left").toInt()
			o[i] = {left: [l, i * interval]}
			
			$$('.active h2').setStyle('background-position', '0 0');
			$$('.active span').setStyle('display', '');
			new Fx.Style(acc.getElement("span"), 'opacity').start(0, 1);
			
			accs.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
					other.getElement('h2').setStyle('background-position', '');
					other.getElement('span').setStyle('display', 'none');
					my_slide.slideIn();
					
				}
				if(i < j) {
					o[j] = {left: [l2, (j * interval) + moveAmount]};
					other.removeClass('active'); // removing class from other divs
					other.getElement('h2').setStyle('background-position', '');
					my_slide.slideIn();
					other.getElement('span').setStyle('display', 'none');
				}
			});
			accFx.start(o);
			
		});
	});
	
 
});