$(document).ready(function(){
	//Examples of how to assign the ColorBox event to elements
	$("a[rel='slide']").colorbox({slideshow:true});
	
	//Example of preserving a JavaScript event for inline calls.
	$("#click").click(function(){ 
		$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
		return false;
	});

	$('#hearother').attr('disabled', 'true');
	$('#hearfrom').attr('onchange', 'SelectChange();');
	
});

function SelectChange() {	
	selec = document.getElementById("hearfrom").value;	

	if (selec=="Other") {
		$('#hearother').attr('disabled', false);	
		//document.getElementById('hearother').disabled = false;
		document.getElementById('hearother').focus();
	} else {
		document.getElementById('hearother').disabled = true;
	}
}
function formCheck(){
	var Error = "Please complete the following fields:\n\n";
	var IsError = false;
	
	if (document.getElementById("name").value == "") {
		Error += "- First Name must not be blank, please re-enter.\n";
		IsError = true;
	}		
	if (document.getElementById("lname").value == "") {
		Error += "- Last Name must not be blank, please re-enter.\n";
		IsError = true;
	}		
	if (document.getElementById("email").value == "") {
		Error += "- Email address must not be blank, please re-enter.\n";
		IsError = true;
	} else if (isEmail(document.getElementById("email").value) == false) {
		Error += "- Invalid Email address, please re-enter.\n";
		IsError = true;
	}
	if (document.getElementById("condition").value == "blank") {
		Error += "- Don't choose, please choose as 1st item.\n";
		IsError = true;
	}
	
	if (IsError == true) {
		alert(Error);
		return false;			
	} else {
		return true;
	}			
}	
	
function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
		return false;
}	

