/* it's soapdesigned.com */
$(document).ready(function() {
	$('a.j_expand, a.j_close').live('click', function() {
		var	target = $('#'+$(this).data('target')),
			h1 = $('h1.comingsoon')
		
		if(target.hasClass('active') || $(this).is('a.j_close')) {
			h1.animate({top:0,left:0},150);
			target.hide(150).removeClass('active');
		} else {
			h1.animate({top:-145,left:-430},150);
			target.show(150).addClass('active');	
		}
		return false;
	});
	$('form').submit(function() {
		var 	error = false,
			errfields = [];		
		$('.required', $(this)).each(function() {
			val = $.trim($(this).val());
			if(val == '') {
				error = true;
				errfields.push($(this));
			} else if($(this).hasClass('email') && !val.match(/^[_A-z0-9-]+((\.|\+)[_A-z0-9-]+)*@[A-z0-9-]+(\.[A-z0-9-]+)*(\.[A-z]{2,4})$/)) {
				error = true;
				errfields.push($(this));
			} else if($(this).hasClass('phone')) {
				ph = val.replace(/[^0-9]/g,'');
				if(ph.length < 10) {
					error = true;
					errfields.push($(this));
				} else	$(this).removeAttr('style');				
			} else	$(this).removeAttr('style');
		});		
		if(error) {
			$('.errmessage').slideDown(200, function() {
				if(errfields.length >= 1)
					var t = 1;
					for(i=0; i <= errfields.length; i++) {
						$(errfields[i]).delay(t).animate({borderWidth:5},100);
						t = t+100;
					}
			});
			
		} else	return true;		
		return false;
	});
});

