function validateCatalog() {
	var catalogFName = document.getElementById('catalogFName');
	var catalogLName = document.getElementById('catalogLName');
	var catalogAddress = document.getElementById('catalogAddress');
	var catalogCity = document.getElementById('catalogCity');
	var catalogState = document.getElementById('catalogState');
	var catalogZip = document.getElementById('catalogZip');
	var catalogHomePhone = document.getElementById('catalogHomePhone');
	var catalogWorkPhone = document.getElementById('catalogWorkPhone');
	var catalogEmail = document.getElementById('catalogEmail');
	var catalogConfirmEmail = document.getElementById('catalogConfirmEmail');
	var catalogTimeStamp = document.getElementById('catalogTimeStamp');
	
	for (i=1;i<=9;i++) {
		document.getElementById("catalogLabel" + i).className = "";
	}
	
	var numericExpression = /^[0-9]+$/;
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	
	var errors = "";
	var theError = "";
	
	var errorsBox = document.getElementById('errors');
	
	if(catalogFName.value.length == 0){
		errors++;
		document.getElementById("catalogLabel1").className = "labelError";
	}

	if(catalogLName.value.length == 0){
		errors++;
		document.getElementById("catalogLabel2").className = "labelError";
	}

	if(catalogAddress.value.length == 0){
		errors++;
		document.getElementById("catalogLabel3").className = "labelError";
	}

	if(catalogCity.value.length == 0){
		errors++;
		document.getElementById("catalogLabel4").className = "labelError";
	}

	if(catalogState.value.length == 0){
		errors++;
		document.getElementById("catalogLabel5").className = "labelError";
	}

	if(catalogZip.value.length == 0){
		errors++;
		document.getElementById("catalogLabel6").className = "labelError";
	}

	if(catalogHomePhone.value.length == 0){
		errors++;
		document.getElementById("catalogLabel7").className = "labelError";
	}


	
	if(!catalogEmail.value.match(emailExp)){
		errors++;
		theError += "<br />Please enter a valid email address.";
		document.getElementById("catalogLabel8").className = "labelError";
	}
	
	if(!catalogConfirmEmail.value.match(emailExp)){
		errors++;
		//theError += "<br />Please enter a valid email address.";
		document.getElementById("catalogLabel9").className = "labelError";
	}
	
	if(catalogEmail.value != catalogConfirmEmail.value) {
		errors++;
		theError += "<br />Please make sure the email addresses match.";
		document.getElementById("catalogLabel8").className = "labelError";
		document.getElementById("catalogLabel9").className = "labelError";
	}
	
	if (errors == "") {
		errorsBox.style.display = "none";
		return true;
	} else {
		errorsBox.style.display = "block";
		errorsBox.innerHTML = "There were some errors.<br />";
		errorsBox.innerHTML += theError;
		return false;
	}
	
}
function validateTour() {
	var tourFName = document.getElementById('tourFName');
	var tourLName = document.getElementById('tourLName');
	var tourAddress = document.getElementById('tourAddress');
	var tourCity = document.getElementById('tourCity');
	var tourState = document.getElementById('tourState');
	var tourZip = document.getElementById('tourZip');
	var tourHomePhone = document.getElementById('tourHomePhone');
	var tourWorkPhone = document.getElementById('tourWorkPhone');
	var tourEmail = document.getElementById('tourEmail');
	var tourConfirmEmail = document.getElementById('tourConfirmEmail');
	var tourTimeStamp = document.getElementById('tourTimeStamp');
	
	for (i=1;i<=9;i++) {
		document.getElementById("tourLabel" + i).className = "";
	}

	var numericExpression = /^[0-9]+$/;
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	
	var errors = "";
	var theError = "";
	
	var errorsBox = document.getElementById('errors');
	
	if(tourFName.value.length == 0){
		errors++;
		document.getElementById("tourLabel1").className = "labelError";
	}

	if(tourLName.value.length == 0){
		errors++;
		document.getElementById("tourLabel2").className = "labelError";
	}

	if(tourAddress.value.length == 0){
		errors++;
		document.getElementById("tourLabel3").className = "labelError";
	}

	if(tourCity.value.length == 0){
		errors++;
		document.getElementById("tourLabel4").className = "labelError";
	}

	if(tourState.value.length == 0){
		errors++;
		document.getElementById("tourLabel5").className = "labelError";
	}

	if(tourZip.value.length == 0){
		errors++;
		document.getElementById("tourLabel6").className = "labelError";
	}

	if(tourHomePhone.value.length == 0){
		errors++;
		document.getElementById("tourLabel7").className = "labelError";
	}

	
	if(!tourEmail.value.match(emailExp)){
		errors++;
		theError += "<br />Please enter a valid email address.";
		document.getElementById("tourLabel8").className = "labelError";
	}
	
	if(!tourConfirmEmail.value.match(emailExp)){
		errors++;
		//theError += "<br />Please enter a valid email address.";
		document.getElementById("tourLabel9").className = "labelError";
	}
	
	if(tourEmail.value != tourConfirmEmail.value) {
		errors++;
		theError += "<br />Please make sure the email addresses match.";
		document.getElementById("tourLabel8").className = "labelError";
		document.getElementById("tourLabel9").className = "labelError";
	}


	if (errors == "") {
		errorsBox.style.display = "none";
		return true;
	} else {
		errorsBox.style.display = "block";
		errorsBox.innerHTML = "There were some errors.<br />";
		errorsBox.innerHTML += theError;
		return false;
	}
	
}

function loadVideo(which) {
    $('#player').attr("src", $('#imgbox'+which+' a.btn').attr('href'));
    $('.vidDeets.current').removeClass('current');
    $('#vidDeets'+which).addClass("current");
}
// function centerHover(what,where){
// 	$(what).position({
// 		my: "center",
// 		at: "center",
// 		of: where,
// 		collison: "fit fit"
// 	});
// 	
// 	$(where).mousemove(function(e){
// 
// 		var x = e.pageX - this.offsetLeft;
// 		var y = e.pageY - this.offsetTop;
// 
// 		var newx = (x) * .02;// / 50;
// 		var newy = (y) * .02;// / 50;
// 		//var newx = newx/15;
// 		//var newy = newy/15;
// 		$(what).position({
// 			my: "center",
// 			at: "center",
// 			of: where,
// 			collison: "fit fit",
// 			offset: newx + " " + newy
// 		});
// 	});
// 	
// }

$(document).ready(function(){

	$("#topNavDrop").menuHover("topNavDrop");
	$("#aciCarousel").scrollable();
	$("a[rel='thumbs']").colorbox();
	$("a[rel='video']").colorbox({iframe:true, innerWidth:640, innerHeight:350, current:""});
	$("a[rel='videoIcon']").colorbox({iframe:true, innerWidth:640, innerHeight:350, current:""});
	$("a[rel='info']").colorbox({iframe:true, innerWidth:400, innerHeight:500, current:""});

	$('span.head').click(function(){
	   $("#vidCatList").slideDown('slow');
	   $("#vidCatList").mouseleave(function(){
           $("#vidCatList").slideUp("slow"); 
       });
	});
	$(".tooltips").click(
		function() {
			$(this).contents("span.tooltip").css({ display: "block" });
		}
	);
	
	$(".requestCatalog").click(function() {
		$(".scheduleTour").css("opacity","0.5");
		$(".requestCatalog").css("opacity","1");
		$("#aciFooter").css("padding-bottom","15px");
		$("#aciFooter").css("margin-bottom","10px");
		$("#aciFooter img.cta").css("clip","rect(0px, 181px, 225px, 0px)");
		$("#aciFooter img.cta").css("top","10px");
		$("#footerForm").css("display","block");
		$("#catalogForm").css("display","block");
		$("#errors").css("display","none");
		$("#tourForm").css("display","none");
		$("#footerForm h6").html("Request a Catalog");
		$("p.formDescriptor").html("To find out more about the Arizona Culinary Institute, fill out the following form to receive an ACI brochure. The brochure will immediately be sent to you via email along with tuition and financial aid information.");
	});
	$(".scheduleTour").click(function() {
		$(".requestCatalog").css("opacity","0.5");
		$(".scheduleTour").css("opacity","1");
		$("#aciFooter").css("padding-bottom","15px");
		$("#aciFooter").css("margin-bottom","10px");
		$("#aciFooter img.cta").css("clip","rect(0px, 181px, 225px, 0px)");
		$("#aciFooter img.cta").css("top","10px");
		$("#footerForm").css("display","block");
		$("#catalogForm").css("display","none");
		$("#errors").css("display","none");
		$("#tourForm").css("display","block");
		$("#footerForm h6").html("Schedule a Tour");
		$("p.formDescriptor").html("Want to get a closer look at ACI? We're more than happy to give you a personal tour. Once you see our facilities, we think you will agree it's the right place for you.");
	});

	$(".requestCatalog").css("opacity","0.5");
	$(".scheduleTour").css("opacity","0.5");
	
	/* if ( $.browser.msie ) {
		$("#aciStoryMain").css("background-color","#ffffff");
		$("#aciStoryMain").css("background-image","none");
		$("#aciStoryMain").css("opacity","0.85");
		$("#aciCarouselWrap").css("background-color","#ffffff");
		$("#aciCarouselWrap").css("background-image","none");
		$("#aciCarouselWrap").css("opacity","0.85");
	} */

	var timeStamp = new Date().getTime();
	$('<input type="hidden" name="catalogTimeStamp" value="'+ timeStamp +'" />').appendTo('form#catalogForm');
	$('<input type="hidden" name="tourTimeStamp" value="'+ timeStamp +'" />').appendTo('form#tourForm');
	$('<input type="hidden" name="catalogTimeStamp" value="'+ timeStamp +'" />').appendTo('form#aciNewForm.catalogForm');
	$('<input type="hidden" name="tourTimeStamp" value="'+ timeStamp +'" />').appendTo('form#aciNewForm.tourForm');
	
	window.onunload = function(){
		hideMenu();
	};
	
	var currentBox;
	$("[rel='pop']").click(function (e){
		if(currentBox){
			currentBox.hide("medium");
			currentBox = null;
		} 
		var caller = e.target;
		currentBox = $("div."+caller.id);
	  	currentBox.show("medium");
	});
	$(".close").click(function () {
		currentBox.hide("medium");
		currentBox = null;
	});
	
	$(function() {
		var zIndexNumber = 1000;
		var ie = ($.browser.msie && parseInt($.browser.version, 10) <= 7);
		if(ie){
			$('#curriculum div.imgwrap').each(function() {
				$(this).css('zIndex', zIndexNumber);
				zIndexNumber -= 10;
			});
		}
	});

/*	centerHover("#img1","#imgbox1");
	centerHover("#img2","#imgbox2");
	centerHover("#img3","#imgbox3");
	centerHover("#img4","#imgbox4");
	centerHover("#img5","#imgbox5");
	centerHover("#img6","#imgbox6");
	centerHover("#img7","#imgbox7");
	centerHover("#img8","#imgbox8");
	centerHover("#img9","#imgbox9");
	centerHover("#img10","#imgbox10");
	centerHover("#img11","#imgbox11");
	centerHover("#img12","#imgbox12");
	centerHover("#img13","#imgbox13");
	centerHover("#img14","#imgbox14");
	centerHover("#img15","#imgbox15");
	centerHover("#img16","#imgbox16");
	*/
});
