var fields = ["name", "email", "specifics"];
//var defaults = ["Name...", "Company/Organization...", "Telephone...", "E-mail...", "Your Message..."];
var v1, v2, t;


var fx = {
	'notification': new Fx.Style( 'notification', 'opacity',{ duration: 200 } ),
	'note0': new Fx.Style( 'note0', 'opacity',{ duration: 200 } ),
	'note1': new Fx.Style( 'note1', 'opacity',{ duration: 200 } ),
	'note2': new Fx.Style( 'note2', 'opacity',{ duration: 200 } ),
	'note3': new Fx.Style( 'note3', 'opacity',{ duration: 200 } )
};

// Hides the loading div, and shows the el div for
// a period of four seconds.
var showHide = function( el ){
	(fx[ el ]).start(0,1);
	(function(){ (fx[ el ]).start(1,0); }).delay( 2000 );
}
var show = function( el ){
	(fx[ el ]).start(0,1);
}
var hide = function( el ){
	(function(){ (fx[ el ]).start(1,0); }).delay( 500 );
}

function evblank(ar,br) {
	var err1 = 0;
	ar.each(function(item, index){
		if($(item).getProperty('value') == '' || $(item).getProperty('value') == br[index]) {
			err1++;
		}
	});
	if(err1 !=0) {
		return err1;
	}
}

show('note0');
showHide('note1');
showHide('note2');
showHide('note3');
var rfields = ["name", "email", "specifics"];
//var rdefaults = ["Name...", "E-mail...", "Your Message..."];

function note(v) {
	var note0 = $('note0');
	var note1 = $('note1');
	var note2 = $('note2');
	var note3 = $('note3');
	
	switch(parseInt(v)){
		case 0:
			note0.addClass('success');
			show('note0');
			
			$("close").addEvent('click', function(){
				hide('note0');
				//note0.removeClass('success');
			});
			break;
		case 1:
			note1.addClass('notify');
			showHide('note1');
			
			rfields.each(function(item, index){
				if($(item).getProperty('value') == '') {
					$(item).addClass('ferror');
				} else {
					$(item).removeClass('ferror');
				}
			});		
			break;
		case 2:
			note2.addClass('notify');
			showHide('note2');
			
			$('email').addClass('ferror');

			break;
		case 3:
			note3.addClass('notify');
			showHide('note3');
			break;
		default:
			note3.addClass('notify');
			showHide('note3');
			break;
	}
}
$('submit').addEvent('click', function(evt){
	new Event(evt).stop();

	var submit = $('submit');
	var notify = $('notification');

	submit.setProperty('value', '');
	submit.addClass('loading');
	$('conform').send({
		update: notify,
		onComplete: function() {
			submit.setProperty('value', 'Submit');
			submit.removeClass('loading');

			note(notify.getElement('input').value);
		}
	});
});

