function init()
{
	$("#faqs a[href$=.mp3]").click(function() {
		$('#niftyplayer').animate({bottom:'0'}, 500);
		niftyplayer('niftyPlayer1').loadAndPlay($(this).attr('href'));
		return false;
	});
	
	$("a[href^='http']").not("a[href*='"+document.domain+"']").click(function(){
		_gaq.push(['_trackEvent', 'External Link', this.href, location.href]);
	});

	$("form input[type=text], form textarea").focus(function(event){
		if($(this).attr("defaultValue")==$(this).attr("value"))
		{
			$(this).attr("value","")
		}
	});
	$("form input[type=text], form textarea").blur(function(event){
		if($(this).attr("value")=="")
		{
			$(this).attr("value",$(this).attr("defaultValue"))
		}
	});
	$("form #captcha").click(function() {
		var src = $(this).attr("src");
		src += "?refresh="+new Date().getTime();
		$(this).removeAttr("src").attr("src", src);
	});
	$("form").submit(function() {
		var error = false;
		
		$(this).find("input[name=_email]").each(function() {
			if(!isValidEmail($(this).attr("value")))
			{
				error = "Please enter a valid email address.";
				$(this).parent().css({"border-color" : "#990033"});
			}
			else
			{
				$(this).parent().css({"border-color" : "#C8C8C8"});
			}
		});
		
		$(this).find("input, select, textarea").each(function() {
			if($(this).attr("name").charAt(0)=="_")
			{
				if($(this).attr("value")==$(this).attr("defaultValue"))
				{
					error = "Please complete all required fields.";
					$(this).parent().css({"border-color" : "#990033"});
				}
				else
				{
					$(this).parent().css({"border-color" : "#C8C8C8"});
				}
			}
		});
		
		if(error)
		{
			$(this).find("p.error").animate({opacity: 0.0}, 1);
			$(this).find("p.error").html(error);
			$(this).find("p.error").animate({opacity: 0.0}, 100 ).animate({opacity: 1}, 900 );
			return false;
		}
		else
		{
			$("form input[type=text], form textarea").each(function() {
				if($(this).attr("value")==$(this).attr("defaultValue"))
				{
					$(this).attr("value","");
				}
			});
		}
		return true;
	});
}

function isValidEmail(str)
{ 
	var email_pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
	return email_pattern.test(str);  
}
