

$(document).ready(function(){
						   
	//-------------------ENABLE ALT CONTACTS-------------					   
						   
	$('div#altContact').html('<a href="" class="mailTo"><img src="images/button_email.png" alt="email" /></a><a href="#" id="callLink"><img src="images/button_call.png" alt="call" /></a>');

	//-------------------ENABLE CONTACT NAV SCROLL-------
	if($('body').attr('id') == "home")
	{
		$("a#contactNav").click(function(){
			var offset = $('div#contact').offset().top;
			$('html,body').animate({
				scrollTop: offset}, 2000, 'easeInOutQuint');
			return false;
			});
	}
										
	//-------------------ENABLE MAILTO LINKS-------------
	ML="geomy@.inscd";
	MI=";197085;40;186:23";
	OT="";
	for(j=0;j<MI.length;j++){
	OT+=ML.charAt(MI.charCodeAt(j)-48);
	}
	$("a.mailTo").attr('href', 'mailto:' + OT);
	$("a.mailToFill").attr('href', 'mailto:' + OT).html(OT);


	//--------------------AJAX CODE---------------------
	$("form#submit").submit(function() 
        {

            var json = {
                "name": $("#FORM_name").attr("value"),
                "company": $("#FORM_company").attr("value"),
                "website": $("#FORM_website").attr("value"),
                "phone": $("#FORM_phone").attr("value"),
                "email": $("#FORM_email").attr("value"),
                "location": $("#FORM_location").attr("value"),
                "message": $("#FORM_message").attr("value")
            };

            if(validate(json.name, json.email))
            {
                 $.ajax({
                           type: "POST",
                           url: "submit.php",
                           data: json,
                           success: function(){
                                        $("#contact").hide();
                                        $("#contact").html('<div id="formSuccess"><h1>Thank you for your submission</h1><p>I will get back to you shortly</p></div>');
                                        $("#contact").show("fast");
                                        pageTracker._trackPageview("/contact/submit.html");
                           }
                 });
                 return false;
            }
            else
            {
                return false;
            }

	});

	//--------------------PHONE FIELD AUTO FORMAT----------------

	var phoneField = $("#FORM_phone");
	var backedUp = false;
	phoneField.keyup( function(e) {
		if(e.keyCode != '8' && !backedUp)
		{
			if(phoneField.val().length == '3')
			{
				phoneField.val("(" + phoneField.val() + ") ");
			}
			if(phoneField.val().length == '9')
			{
				phoneField.val(phoneField.val() + "-");
			}
		}
		else
		{
			backedUp = true;
		}
	});


    //--------------------GOOGLE VOICE APP---------------------

    $('div#voiceApp').prepend('<object id="voiceObject" type="application/x-shockwave-flash" data="https://clients4.google.com/voice/embed/webCallButton" width="230" height="85"><param name="movie" value="https://clients4.google.com/voice/embed/webCallButton" /><param name="wmode" value="transparent" /><param name="FlashVars" value="id=c393d83023ea186905d7a13170be3c43b9e79edb&style=0" /></object>');

    $("a#callLink").click(function(){
            $("div#altContact").hide();
            $("div#voiceApp").show();
            return false;
    });

     //--------------------ENABLE PORTFOLIO SLIDER--------------

    $('.anythingSlider').anythingSlider({
            easing: "easeInOutQuint",                // Anything other than "linear" or "swing" requires the easing plugin
            autoPlay: false,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not
            startStopped: false,            // If autoPlay is on, this can force it to start stopped
            delay: 3000,                    // How long between slide transitions in AutoPlay mode
            animationTime: 2200,             // How long the slide transition takes
            hashTags: true,                 // Should links change the hashtag in the URL?
            buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
            pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
            startText: "Start",             // Start text
            stopText: "Stop",               // Stop text
            navigationFormatter: null       // Details at the top of the file on this use (advanced use)
    });

    //--------------------ACTIVATE ROUNDED CORNERS--------------
    $('.roundedSmall').attr('style', '-moz-border-radius: 5px;-webkit-border-radius: 5px;');
    $('.roundedLarge').attr('style', '-moz-border-radius: 15px;-webkit-border-radius: 15px;');
    
});

//--------------------VALIDATE CONTACT FORM INPUT--------------
function validate(name, email)
{	
	var result = true;
	var NerrorContents = '<img src="images/error.png" alt="Error" /> Please enter your name';
	var EerrorContents = '<img src="images/error.png" alt="Error" /> Please enter your e-mail';

	if(name == "")
	{
		$("#reqName").addClass("error");
		$("#errNameContainer").html(NerrorContents).show("slow");
		$("input#FORM_name").css({ borderColor: "red"});
		result = false;
	}
	else
	{
		$("#errNameContainer").hide("slow");
		$("input#FORM_name").css({ borderColor: "#352421 #dc9488 #dc9488 #352421"});
	}
	if(email == "")
	{
		$("#reqEmail").addClass("error");
		$("#errEmailContainer").html(EerrorContents).show("slow");
		$("input#FORM_email").css({ borderColor: "red"});
		result = false;
	}
	else
	{
		$("#errEmailContainer").hide("slow");
		$("input#FORM_email").css({ borderColor: "#352421 #dc9488 #dc9488 #352421"});
	}
	return result;

}







