var currPart = 2;
$(document).ready(function() {
	if($(".storyItem")) {
		var myNum = Math.ceil(Math.random()*12);
		$("#story"+myNum).css("display","block");
	}
	if($("#photosPage")) {
		$(".thumbnail").click(function() {
			var thumbSRC = $(this).attr("src")
			var thumbSplit = thumbSRC.indexOf("thumbs/")+7;
			var imgName = thumbSRC.substring(thumbSplit);
			showImage(imgName,$(this).attr("alt"));
		});
	}
});
function showVideo() {
	$("#awanaVideo").css("display","block");
}
function hideVideo() {
	$("#awanaVideo").css("display","none");
}
function getFlashMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}
function formSend(movie,text) {
	getFlashMovie(movie).sendTextToFlash(text);
}
function showImage(srcIMG,alt) {
	var newIMG = "/images/photos/lowres/"+srcIMG;
	var highIMG = "/images/photos/highres/"+srcIMG;
	$("#awanaImage").css("display","block");
	$("#lightboxIMG").attr("src",newIMG);
	$("#lowresLINK").attr("href",newIMG);
	$("#highresLINK").attr("href",highIMG);
	$("p.imgDesc").text(alt);
	$(".lightBox").css("position","fixed");
	$(".lightBox").css("left",($("body").innerWidth()/2)-200+"px");
}
function hideImage() {
	$("#awanaImage").css("display","none");
	$("#lightboxIMG").attr("src","/images/photos/loading.gif");
}
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
function showYT(url) {
	$("#awanaVideo").css("display","block");
	$("#ytPlayer").attr("data",url);
	$("#paramMovie").attr("value",url);
}
function vote(ytID,clientID) {
	var cookieFound = false;
	var currPage = window.location.href.indexOf(".aspx")
	var cookieJar = document.cookie;
	var cookieArr = cookieJar.split(";");
	for(i=0;i<cookieArr.length;i++) {
		if(cookieArr[i].indexOf("pageVoted") >= 0) {
			var divider = cookieArr[i].indexOf("=")+1;
			var cookieValue = cookieArr[i].substring(divider,cookieArr[i].length);
			if(cookieValue.indexOf(window.location.href.charAt(currPage-1)) >= 0) {
				alert("You are only allowed to vote once per day.");
				cookieFound = true;
				break;
			} else {
				$("#tfa_3328747454258").attr("value",ytID);
				$("#tfa_IPAddress").attr("value",clientID);
				$("#tfa_Page").attr("value",window.location.href.charAt(currPage-1));
				$("#id2520488").submit();
				bakeCookie(currPage,cookieValue);
				cookieFound = true;
				break;
			}
		}
	}
	if(cookieFound == false) {
		$("#tfa_3328747454258").attr("value",ytID);
		$("#tfa_IPAddress").attr("value",clientID);
		$("#tfa_Page").attr("value",window.location.href.charAt(currPage-1));
		$("#id2520488").submit();
		bakeCookie(currPage,'');
	}
}
function bakeCookie(currPage,currValue) {
	var theDate = new Date();
	var expireDate = new Date;
	expireDate.setHours(23);
	expireDate.setMinutes(59);
	expireDate.setSeconds(59);
	expireDate.setMilliseconds(999);
	document.cookie = "pageVoted="+window.location.href.charAt(currPage-1).toString()+currValue.toString()+";expires="+expireDate.toUTCString()+";path=/";
}
function addParicipant(div) {
	$(div).html($(div).html()+"<div class=\"oneField release\"><label for=\"tfa_Name"+currPart+"\"><strong>Name</strong></label><br /><input type=\"text\" id=\"tfa_Name"+currPart+"\" name=\"tfa_Name"+currPart+"\" size=\"40\"><br /></div><div class=\"oneField release\"><label for=\"tfa_Date"+currPart+"\"><strong>Date</strong></label><br /><input type=\"text\" id=\"tfa_Date"+currPart+"\" name=\"tfa_Date"+currPart+"\" size=\"20\"></div><br class=\"last\" />");
	currPart++
}
function checkAge(age) {
	var birthYear = age.substr(4,4)
	if(Number(birthYear) > 1992) {
		alert("You are too young to enter this contest.")
		$("#tfa_BirthYear").val("");
	}
}






















