$(document).ready(function(){
	//setup_form();
	$('ul.topnav li').hover(function(){
		$(this).css('backgroundColor', '#000');
		$(this).find('ul').stop(true, true).delay(50).slideDown(400);
	}, function(){ 
		$(this).css('backgroundColor', 'transparent');
		$(this).find('ul').stop(true, true).delay(50).slideUp(200);
	});
	if(INTPAGE == 'yes'){
		$("#bottomfeeder").load("galleries.php?type=kitchen", function(){
			Shadowbox.setup("kitchen", {
				gallery:  "kitchen",
				continuous:     false,
				counterType:    "default"
			});
		});
		$("#npcalc").click(function(){ showCalc(); });
		$("#kitchentour").click(function(){ showTour(); });
		$("#videolink").click(function(){ showVideo(); });
		$("#recipelink1").click(function(){ showRecipe1(); });
		$("#recipelink2").click(function(){ showRecipe2(); });
		$("#recipelink3").click(function(){ showRecipe3(); });
		$("#recipelink4").click(function(){ showRecipe4(); });
		$("#recipelink5").click(function(){ showRecipe5(); });
		$("#recipelink6").click(function(){ showRecipe6(); });
	}
	$(".courses").tooltip({effect: 'slide', position: 'center right' });
});

function showVideo(){
	Shadowbox.open({
	content:    '<iframe width="480" height="390" src="http://www.youtube.com/embed/nqreSeXeAc0?rel=0" frameborder="0" allowfullscreen></iframe>',
	player:     "html",
	title:      "Columbus Culinary: Program",
	height:     390,
	width:      480
	});
};



function showTour(){
	 
	
		var img1 = { 
          player: 'img', 
          content: 'http://www.bradfordschools.com/media/images/culinarytour/t1.jpg', 
          gallery: 'kitchen' 
        }; 
        var img2 = { 
          player: 'img', 
          content: 'http://www.bradfordschools.com/media/images/culinarytour/t10.jpg', 
          gallery: 'kitchen' 
        }; 
		var img3 = { 
          player: 'img', 
          content: 'http://www.bradfordschools.com/media/images/culinarytour/t3.jpg', 
          gallery: 'kitchen' 
        }; 
        var img4 = { 
          player: 'img', 
          content: 'http://www.bradfordschools.com/media/images/culinarytour/t11.jpg', 
          gallery: 'kitchen' 
        }; 
		var img5 = { 
          player: 'img', 
          content: 'http://www.bradfordschools.com/media/images/culinarytour/t4.jpg', 
          gallery: 'kitchen' 
        }; 
        var img6 = { 
          player: 'img', 
          content: 'http://www.bradfordschools.com/media/images/culinarytour/t5.jpg', 
          gallery: 'kitchen' 
        }; 
		var img7 = { 
          player: 'img', 
          content: 'http://www.bradfordschools.com/media/images/culinarytour/t12.jpg', 
          gallery: 'kitchen' 
        }; 
        var img8 = { 
          player: 'img', 
          content: 'http://www.bradfordschools.com/media/images/culinarytour/t6.jpg', 
          gallery: 'kitchen' 
        }; 
		var img9 = { 
          player: 'img', 
          content: 'http://www.bradfordschools.com/media/images/culinarytour/t8.jpg', 
          gallery: 'kitchen' 
        }; 
		var img10 = { 
          player: 'img', 
          content: 'http://www.bradfordschools.com/media/images/culinarytour/t13.jpg', 
          gallery: 'kitchen' 
        }; 
        var img11 = { 
          player: 'img', 
          content: 'http://www.bradfordschools.com/media/images/culinarytour/t14.jpg', 
          gallery: 'kitchen' 
        };
		
		Shadowbox.open([img1, img2, img3, img4, img5, img6, img7, img8, img9, img10, img11], { 
         continuous: true, 
         autoplay: true 
        });
} 




function showCalc(){
	Shadowbox.open({
	content:    '<iframe width="800" height="510" src="npcalc.html" frameborder="0" allowfullscreen></iframe>',
	player:     "html",
	height:     510,
	width:      800
	});
};


function showRecipe1(){
	Shadowbox.open({
	content:    '<iframe width="563" height="420" src="ajax_recipe1.php" frameborder="0" allowfullscreen></iframe>',
	player:     "html",
	title:      "Columbus Culinary: Recipe",
	height:     420,
	width:      563
	});
};

function showRecipe2(){
	Shadowbox.open({
	content:    '<iframe width="563" height="420" src="ajax_recipe2.php" frameborder="0" allowfullscreen></iframe>',
	player:     "html",
	title:      "Columbus Culinary: Recipe",
	height:     420,
	width:      563
	});
};

function showRecipe3(){
	Shadowbox.open({
	content:    '<iframe width="563" height="420" src="ajax_recipe3.php" frameborder="0" allowfullscreen></iframe>',
	player:     "html",
	title:      "Columbus Culinary: Recipe",
	height:     420,
	width:      563
	});
};

function showRecipe4(){
	Shadowbox.open({
	content:    '<iframe width="563" height="420" src="ajax_recipe4.php" frameborder="0" allowfullscreen></iframe>',
	player:     "html",
	title:      "Columbus Culinary: Recipe",
	height:     420,
	width:      563
	});
};

function showRecipe5(){
	Shadowbox.open({
	content:    '<iframe width="563" height="420" src="ajax_recipe5.php" frameborder="0" allowfullscreen></iframe>',
	player:     "html",
	title:      "Columbus Culinary: Recipe",
	height:     420,
	width:      563
	});
};

function showRecipe6(){
	Shadowbox.open({
	content:    '<iframe width="563" height="420" src="ajax_recipe6.php" frameborder="0" allowfullscreen></iframe>',
	player:     "html",
	title:      "Columbus Culinary: Recipe",
	height:     420,
	width:      563
	});
};

function showPopup1(){
	Shadowbox.open({
	content:    '<iframe width="703" height="420" src="popup1.php" frameborder="0" allowfullscreen></iframe>',
	player:     "html",
	height:     420,
	width:      703
	});
};

function showPopup2(){
	Shadowbox.open({
	content:    '<iframe width="703" height="420" src="popup2.php" frameborder="0" allowfullscreen></iframe>',
	player:     "html",
	height:     420,
	width:      703
	});
};

function showPopup3(){
	Shadowbox.open({
	content:    '<iframe width="703" height="420" src="popup3.php" frameborder="0" allowfullscreen></iframe>',
	player:     "html",
	height:     420,
	width:      703
	});
};

function showPopup4(){
	Shadowbox.open({
	content:    '<iframe width="703" height="420" src="popup4.php" frameborder="0" allowfullscreen></iframe>',
	player:     "html",
	height:     420,
	width:      703
	});
};


function form_switchfields(ID, VALUE){
	$("#"+ID).focus(function(){  if($(this).val() == VALUE){ $(this).attr('value', ''); }  }).blur(function(){ if($(this).val() == ''){ $(this).attr('value', VALUE); } });
}

function validate_ri(){
	var starter = document.ri;
	if (starter.name.value == 'FULL NAME'){
		alert("Please enter your full name.");
		starter.name.focus();
		return 0;
	}
	if (starter.email.value == 'EMAIL'){
		alert("Please enter your email address....");
		starter.email.focus();
		return 0;
	} else {
		var str = starter.email.value;
	    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	    if (!str.match(re)) {
	        alert("Your email address is invalid. Please verify that you have entered it correctly.");
			starter.email.focus();
			return 0;
	    }
	}
	if (starter.address.value == 'STREET'){
		alert("Please enter your street name.");
		starter.address.focus();
		return 0;
	}
	if (starter.city.value == 'CITY'){
		alert("Please enter your city name.");
		starter.city.focus();
		return 0;
	}
	if (starter.zip.value == 'ZIP'){
		alert("Please enter your zip code.");
		starter.zip.focus();
		return 0;
	}
	if (starter.phone.value == 'PHONE'){
		alert("Please enter your phone number.");
		starter.phone.focus();
		return 0;
	}
	if (starter.highshool.value == 'HIGH SCHOOL'){
		alert("Please enter your high school name.");
		starter.highshool.focus();
		return 0;
	}
	if (starter.hsgrad.selectedIndex == 0){
		alert("Please select your graduation year.");
		starter.hsgrad.focus();
		return 0;
	}
	if (starter.time.selectedIndex == 0){
		alert("Please select a best time to call.");
		starter.time.focus();
		return 0;
	}
	if (starter.ref.selectedIndex == 0){
		alert("Please tell us about how you heard about us.");
		starter.ref.focus();
		return 0;
	}
	starter.submit();
}
/*
function validate_apply(){
	var starter = document.ri;
	if (starter.name.value == 'FULL NAME'){
		alert("Please enter your full name.");
		starter.name.focus();
		return 0;
	}
	if (starter.email.value == 'EMAIL'){
		alert("Please enter your email address....");
		starter.email.focus();
		return 0;
	} else {
		var str = starter.email.value;
	    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	    if (!str.match(re)) {
	        alert("Your email address is invalid. Please verify that you have entered it correctly.");
			starter.email.focus();
			return 0;
	    }
	}
	if (starter.address.value == 'STREET'){
		alert("Please enter your street name.");
		starter.address.focus();
		return 0;
	}
	if (starter.city.value == 'CITY'){
		alert("Please enter your city name.");
		starter.city.focus();
		return 0;
	}
	if (starter.zip.value == 'ZIP'){
		alert("Please enter your zip code.");
		starter.zip.focus();
		return 0;
	}
	if (starter.phone.value == 'PHONE'){
		alert("Please enter your phone number.");
		starter.phone.focus();
		return 0;
	}
	if (starter.highshool.value == 'HIGH SCHOOL'){
		alert("Please enter your high school name.");
		starter.highshool.focus();
		return 0;
	}
	if (starter.hsgrad.selectedIndex == 0){
		alert("Please select your graduation year.");
		starter.hsgrad.focus();
		return 0;
	}
	if (starter.time.selectedIndex == 0){
		alert("Please select a best time to call.");
		starter.time.focus();
		return 0;
	}
	if (starter.ref.selectedIndex == 0){
		alert("Please tell us about how you heard about us.");
		starter.ref.focus();
		return 0;
	}
	starter.submit();
}
*/
function validate_apply(){
	if(val_error('name1', 'FIRST NAME', 'Please enter your first name.') == 0){ return 0; }
	if(val_error('name2', 'LAST NAME', 'Please enter your last name.') == 0){ return 0; }
	if(val_error('email', 'EMAIL', 'Please enter your email address.') == 0){ return 0; }
	if(val_error3('email', 'EMAIL') == 0){ return 0; }
	if(val_error('address', 'STREET', 'Please enter your street address.') == 0){ return 0; }
	if(val_error('city', 'CITY', 'Please enter your city.') == 0){ return 0; }
	if(val_error('zip', 'ZIP', 'Please enter your zip code.') == 0){ return 0; }
	if(val_error('phone1', 'DAYTIME PHONE', 'Please enter your daytime phone number.') == 0){ return 0; }
	if(val_error('phone2', 'EVENING PHONE', 'Please enter your evening phone number.') == 0){ return 0; }
	if(val_error('phone3', 'CELL PHONE', 'Please enter your cell phone number.') == 0){ return 0; }
	if(val_error('dob', 'DATE OF BIRTH', 'Please enter your date of birth.') == 0){ return 0; }
	if(val_error('ssn', 'SOCIAL SECURITY NUMBER', 'Please enter your social security number.') == 0){ return 0; }
	if(val_error2('hsgrad', 'Please enter your High School Graduation Year.') == 0){ return 0; }
	if(val_error('high', 'HIGH SCHOOL ATTENDED', 'Please enter your high school attended.') == 0){ return 0; }
	//if(val_error('college', 'PREVIOUS COLLEGES ATTENDED', 'Please enter your first name') == 0){ return 0; }
	if(val_error2('apt', 'Please enter your housing needs.') == 0){ return 0; }
	if(val_error2('start', 'Please indicate when you would like to begin.') == 0){ return 0; }
	//alert('about to apply');
	$("#apply").submit();
}
function val_error(field, value, alerttext){
	if ($("#"+field).val() == value){
		alert(alerttext);
		$("#"+field).focus();
		return 0;
	} else {
		return 1;	
	}
}
function val_error2(field, alerttext){
	if ($("#"+field).attr("selectedIndex") == 0){
		alert(alerttext);
		$("#"+field).focus();
		return 0;
	} else {
		return 1;	
	}
}
function val_error3(field){
	var str = $("#"+field).val();
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (!str.match(re)) {
		alert("Your email address is invalid. Please verify that you have entered it correctly.");
		$("#"+field).focus();
		return 0;
	}	
}
