/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$(document).ready(function(){
	//Animates the #mainmenu text to red
	$("#mainmenu li a").mouseenter(function(){ $(this).animate({ "color": "#FFAC00" },"fast","linear")});
	$("#mainmenu li a").mouseout(function(){
										if($(this).hasClass("active"))
										{
											$(this).animate({"color":"#FFAC00"},"slow","linear");
										}
										else
										{
											$(this).animate({"color":"white"},"slow","linear");
										}
									});

	$("#contactForm").submit(function()
	{
		var pass = true;

		if( $("#name").val() == "")
		{
			$("#nameError").css("display","inline");
			pass = false;
		}
		else
		{
			$("#nameError").css("display","none");
		}
		if( $("#email").val() == "" && $("#phone").val() =="")
		{
			$("#emailError").css("display", 'inline');
			$("#phoneError").css("display",'inline');
			pass = false;
		}
		else
		{
			$("#emailError").css("display", 'none');
			$("#phoneError").css("display",'none');
		}
		if( $("#reason").val() == "Choose One")
		{
			$("#inquiryError").css("display","inline");
			pass = false;
		}
		else
		{
			$("#inquiryError").css("display","none");
		}
		if( $("#message").val() == "")
		{
			$("#message").css("background-color","#fbe3e4");
			pass = false;
		}
		else
		{
			$("#message").css("background-color","white")
		}
		return pass;
	});

	$('.email a').each(function()
	{
        var oldHref = $(this).attr('href');
        var newHref = rot13x(oldHref);
        var newLink = rot13x($(this).html());
        $(this).attr('href', "mailto:"+newHref);
        $(this).html(newLink);
	});	
});

function rot13x(s) {

    var rxi = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    var rxo = 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm5678901234';
    var map = [];
    var buf = '';

    for (z = 0; z < rxi.length; z++) {map[rxi.substr(z, 1)] = rxo.substr(z, 1);}

    for (z = 0; z < s.length; z++) {
        var c = s.charAt(z);
        buf  += (c in map ? map[c] : c);
    }

    return buf;
}






