// JavaScript Document
function submitForm()   {
    var testAddress1 = document.getElementById("emailAddress").value;

    if(testAddress1 != null )   {
        if(checkValidation(testAddress1) == true) {
            emailContact();
            document.getElementById("textContact").style.display = 'none';
            document.getElementById("problemAlert2").style.display = 'none';
            document.getElementById("submittedAlert").style.display = 'block';
            setTimeout("waitThenReset()",1500);
        }else{
            $("#problemAlert2").text("Please enter a valid email address.");
            document.getElementById("problemAlert2").style.display = 'block';
        }
    }else{
    $("#problemAlert2").text("Please enter a valid email address.");
    document.getElementById("problemAlert2").style.display = 'block';
    }
    
    return (false);


}

function emailContact()		{
	$.post("mailer.asp", {need: $('#changeNeed').val(), start: $('#contactStartPicker').val(), end: $('#contactEndPicker').val(), 
							problem: $('#selectProblem').val(), email: $('#emailAddress').val(), text: $('#txtAreaMain').val()});
	
	return (false);
	//alert('test');
}

function waitThenReset()    {
    document.getElementById("EmailForm").reset();
    document.getElementById("contactTechnical").style.display = 'none';
    document.getElementById("contactReserve").style.display = 'none';
    document.getElementById("contactAddress").style.display = 'none';
    document.getElementById("contactEmailBody").style.display = 'none';
    document.getElementById("submittedAlert").style.display = 'none';
    document.getElementById("textContact").style.display = 'block';
}


function submitNewsletterForm()	{
    var testAddress1 = document.getElementById("emailOne").value;
    var testAddress2 = document.getElementById("emailTwo").value;
    
    if(checkValidation(testAddress1) == true && checkValidation(testAddress2) == true)   {
        if(testAddress1 == testAddress2) {
            emailContact2();
			document.getElementById("containmentDiv").style.display = 'none';
            document.getElementById("submittedAlert2").style.display = 'block';
            
            setTimeout("waitThenClose()",1500);
            
        }else{
            $("#problemAlert").text("The email addresses do not match.");
            document.getElementById("problemAlert").style.display = 'block';
        }
    }else{
    $("#problemAlert").text("Please enter a valid email address.");
    document.getElementById("problemAlert").style.display = 'block';
    }
    
    return (false);
    
}

function emailContact2()		{
	$.post("newsletterMailer.asp", {email: $('#emailOne').val()});
	
	return (false);
	//alert('test');
}

function checkValidation(testAddress) {

    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    
    if(!filter.test(testAddress))    {
        return(false);
    }else{
        return(true);
    }

    return (false);
}



function waitThenClose()    {
    $("#web2NewsletterSignup").hide("puff", {}, 500);
    document.getElementById("EmailForm1").reset();
    document.getElementById("containmentDiv").style.display = 'block';
    document.getElementById("problemAlert").style.display = 'none';
    document.getElementById("submittedAlert2").style.display = 'none';
}




function WhichDivVis(SelectedVal)   {
        
        
        switch(SelectedVal) {
            case "hi":
                document.getElementById('contactAddress').style.display = 'block';
                document.getElementById('contactReserve').style.display = 'none';
                document.getElementById('contactTechnical').style.display = 'none';
                break;
                
            case "reserve":
                document.getElementById('contactReserve').style.display = 'block';
                document.getElementById('contactAddress').style.display = 'block';
                document.getElementById('contactTechnical').style.display = 'none';
                break;
           
            case "getEmailBody":
                document.getElementById('contactEmailBody').style.display = 'block';
                break;
                
            case "support":
                document.getElementById('contactTechnical').style.display = 'block';
                document.getElementById('contactAddress').style.display = 'block';
                document.getElementById('contactReserve').style.display = 'none';
                break;
                
            default:
                document.getElementById('contactTechnical').style.display = 'none';
                document.getElementById('contactAddress').style.display = 'none';
                document.getElementById('contactReserve').style.display = 'none';
                document.getElementById('contactEmailBody').style.display = 'none';
                break;
        }
        
}

$(function() {
		$("#contactStartPicker").datepicker({
			numberOfMonths: 1
		});
});

$(function() {
		$("#contactEndPicker").datepicker({
			numberOfMonths: 1
		});
});



 $(document).ready(function(){
							
 
    $("#showHidden").click(function () {
      $("#hiddenJim").slideToggle("slow");
    });
	
	$("#closeHidden").click(function () {
      $("#hiddenJim").slideToggle("slow");
    });
	
	$("#navInner2").hover(
		function(){ $(".classNavToggle").fadeIn("fast"); }, 
		function(){ $(".classNavToggle").fadeOut("fast"); }
	);
	
	$("#web2Icon4").click(function () { 
		$("#web2NewsletterSignup").show("puff", {}, 500);
	})
	
	
	$("#web2Icon1").hover(
		function(){ $("#web2Icon1Explanation").fadeIn("fast"); }, 
		function(){ $("#web2Icon1Explanation").fadeOut("fast"); }
	);
	
	$("#web2Icon2").hover(
		function(){ $("#web2Icon2Explanation").fadeIn("fast"); }, 
		function(){ $("#web2Icon2Explanation").fadeOut("fast"); }
	);
	
	$("#web2Icon3").hover(
		function(){ $("#web2Icon3Explanation").fadeIn("fast"); }, 
		function(){ $("#web2Icon3Explanation").fadeOut("fast"); }
	);
	
	$("#web2Icon4").hover(
		function(){ $("#web2Icon4Explanation").fadeIn("fast"); }, 
		function(){ $("#web2Icon4Explanation").fadeOut("fast"); }
	);
	
	$("#web2Icon5").hover(
		function(){ $("#web2Icon5Explanation").fadeIn("fast"); }, 
		function(){ $("#web2Icon5Explanation").fadeOut("fast"); }
	);
    
});