//Stop CSS Background Flickering in Internet Explorer 6
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(e) {}

//function to get random number from 1 to n (maxVal)
function randomToN(maxVal,floatVal) {
   var randVal = Math.random()*maxVal;
   return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}

function removeRegForm() {
	$('#regFormZone').fadeOut(300);
}

function afterForm () {
	$('#regFormArea').addClass('thanks');
	var fadeIt = setTimeout(removeRegForm, 4000);
	return false;
}

function initForm() {
	var options = { target: '#regFormArea', type: 'post', success: afterForm };
	var v = $('#registration').validate({
		rules: {
			firstname: {
				required: true
			},
			lastname: {
				required: true,
				minlength: 2
			},
			email: {
				required: true,
				email: true
			},
			phone: {
				required: true,
				minlength: 10
			}
		},
		messages: {
			firstname: {
				required: 'Required'
			},
			lastname: {
				required: 'Required',
				minlength: 'Too short'
			},
			email: {
				required: 'Required'
			},
			phone: {
				required: 'Required',
				minlength: '123-456-7890'
			}
		},
	    submitHandler: function(form) {
			$('#registration').ajaxSubmit(options);
		   	return false;
 		}
	});
}

// JQUERY READY
$(function() {

$('a.external').attr("target","_blank");
initForm();

}); // JQUERY END
