

/* ======================================= */
/*      jquery scripts          		   */
/* ======================================= */

/* ONLY LOADS ON FRONT PAGE */
function crossFade () {

	$(document).ready(function(){


		/* FRONT PAGE IMAGE TRANSITION */

		$('#main-img').crossSlide({
		  sleep: 2.8,
		  fade: 2.8
		}, [
		  { src: 'resources/images/home/home_photo_1.jpg' },
		  { src: 'resources/images/home/home_photo_2.jpg' },
		  { src: 'resources/images/home/home_photo_3.jpg' }
		]);

		});


}


/* FRONT PAGE FIX FOR IE6 */

function cameraIcon() {
	$(document).ready(function(){

		alert ("upgrade your browser!");

		$("img.buttonpng").attr({
			src: "resources/images/home/camera.gif"
			});


		});


	}






/* SITE WIDE JQUERY SCRIPTS */

$(document).ready(function(){

	/* TOGGLE MENUS ON/OFF */

	// Grants Menu
	$("#grants").hover(function() {
		$("#grant-sub").show();
		},
		function() {
			$("#grant-sub").hide("slow");
			});


/*	NOT CURRENTLY USED
	// GRANT YEARS
	$("#granteecont").click(function(){
		$("#grantyears").fadeIn("fast");
		})

*/


	/* VIEW LARGE PHOTO */

	$(".thumb img, .thumbLeft img").click(function(){

		//convert the thumbnail to large photo src
		var theImg = $(this).attr("src");
		var theExt = ".jpg"
		var theBig = theImg.replace(theExt, "_lg.jpg");
		$("#bigimg").attr("src", theBig);

		// set the caption
		var theCaption = "";
		theCaption = $(this).attr("alt");
		$("#caption").text("");
		$("#caption").append(theCaption);

		// turn div on
		$("#bigpic").fadeIn("slow");
		$("#imgcont").fadeIn("slow");

	    });



	/* CLOSE PHOTO OVERLAY */
	$("#close").click (function(){
		$("#bigpic").fadeOut("slow");
		$("#imgcont").fadeOut("slow");

		// zero out the old info so it's blan for next time
		$("#caption").text("");
		$("#bigimg").attr("src", "#");

		});


	/* IMG ROLLOVER FOR BUTTONS */
	$(".button").hover(function(){

		//convert the thumbnail to large photo src
		var theImg = $(this).attr("src");
		var theExt = ".gif"
		var theBig = theImg.replace(theExt, "_over.gif");
		$(this).attr("src", theBig);
		},
		function(){
				var theRoll = $(this).attr("src");
				var theExt = "_over";
				var theImg = theRoll.replace(theExt, "");
				$(this).attr("src", theImg);
				});

	/* IMG ROLLOVER FOR PNG BUTTONS */
	$(".buttonpng").hover(function(){

		//convert the thumbnail to large photo src
		var theImg = $(this).attr("src");
		var theExt = ".png"
		var theBig = theImg.replace(theExt, "_over.png");
		$(this).attr("src", theBig);
		},
		function(){
				var theRoll = $(this).attr("src");
				var theExt = "_over";
				var theImg = theRoll.replace(theExt, "");
				$(this).attr("src", theImg);
				});




	});

/* ======================================= */






/* CHECK THE FORM FOR REQUIRED FIELDS */

function checkFields () {
	var organization = document.getElementById('organization').value;
	var first = document.getElementById('first').value;
	var last = document.getElementById('last').value;
	var phone = document.getElementById('telephone').value;
	var email = document.getElementById('email').value;

	var flag = true;
	var i = 0;
	var j = 0;
	var theFields = new Array();


	if (organization == "" || organization == "This is a required feild.") {
		var flag = false;
		theFields[i] = "organization";
		i++;
		}


	if (first == "") {
		var flag = false;
		theFields[i] = "first";
		i++;
		}

	if (last == "") {
		var flag = false;
		theFields[i] = "last";
		i++;
		}

	if (phone == "") {
		var flag = false;
		theFields[i] = "telephone";
		i++;
		}

	if (email == "") {
		var flag = false;
		theFields[i] = "email";
		}

	if (flag == false) {
		for (j in theFields) {
			document.getElementById(theFields[j]).className = "required";
			}
		return;
		}

	if (flag == true) {
		var send = document.getElementById('submitform');
		send.style.display = "inline";
		send.disabled = false;
		}


	}


/* OPEN EXTERNAL LINKS IN A NEW WINDOW */

function outlink(theURL) {
	var theURL = theURL;
	window.open(theURL);
	return false;
	}

