Cufon.replace("h2", { fontFamily: "Interstate Mono", hover: true});
Cufon.replace("h3", { fontFamily: "Interstate Mono"});
Cufon.replace("h4", { fontFamily: "Interstate Mono", hover: true});

$(document).ready(function() {
	var minHeight = $("#sidebar").height();
	$("#primary").css("min-height", minHeight);

	// initialize lightbox
	if ($("a[rel^='prettyPhoto']").length) {
		$("a[rel^='prettyPhoto']").prettyPhoto({
			animationSpeed: 500,
			padding: 0,
			opacity: 0.7,
			showTitle: false,
			allowresize: true,
			counter_separator_label: "/"
		});
	}

	// drop down navigation for gallery
	var navTimer = null;

	$("li.headlink", "#cssdropdown").hover(function() {
		if (navTimer) {
			clearTimeout(navTimer);
			navTimer = null;
		}
		else {
			$("li.headlink a", "#cssdropdown").css("background-position", "0 bottom");
			$("li.headlink ul", "#cssdropdown").slideToggle(300);
		}
	}, function() {
		navTimer = setTimeout(function() {
			$("li.headlink ul", "#cssdropdown").slideToggle(300);
			$("li.headlink a", "#cssdropdown").css("background-position", "0 top");
			navTimer = null;
		}, 1000);
	});

	$("button, a.button").hover(function() {
		if (!$(this).is("disabled")) $(this).css("background-position", "0 bottom");
	}, function() {
		if (!$(this).is("disabled")) $(this).css("background-position", "0 top");
	});

	$("a.disabled").click(function() {
		return false;
	});

	$("button#logoutBtn").click(function() {
		agree = confirm("Are you sure you want to logout?");

		if (agree) return true;
		else return false;
	});
});


// Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-5412040-1']);
_gaq.push(['_trackPageview']);

(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


// copyright 1999 Idocs, Inc. http://www.idocs.com
// Distribute this script freely but keep this notice in place
function numbersonly(myfield, e, dec) {
	var key;
	var keychar;
	
	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	
	keychar = String.fromCharCode(key);
	
	// control keys and punctuation
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) || (key==45) || (key==46) || (key==120) || (key==45) || (key==40) || (key==41) || (key==32) || (key==43))
	   return true;
	
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
	   return true;
	
	// decimal point jump
	else if (dec && (keychar == ".")) {
	   myfield.form.elements[dec].focus();
	   return false;
	}
	else return false;
}

function validEmail(email) {
	invalidChars = " /:,;";
	if (email == "") {
		return false;
	}
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i);
		if (email.indexOf(badChar,0) != -1) {
			return false;
		}
	}
	atPos = email.indexOf("@",1);
	if (atPos == -1) {
		return false;
	}
	if (email.indexOf("@",atPos+1) != -1) {
		return false;
	}
	periodPos = email.indexOf(".",atPos);
	if (periodPos == -1) {
		return false;
	}
	if (periodPos+3 > email.length)	{
		return false;
	}
	return true;
}