if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
    location.href='http://inmunited.com/iphone';
  }
  
  function doMail(user,domain) {
  	locationstring = "mailto:" + user + "@" + domain;
  	window.location = locationstring;
  }

$(document).ready(function() {
	$('a[rel=external]').click(function(){
		window.open(this.href);
		return false;   
	});
	
	$('a.email').click(function() {
		doMail('info','inmunited.com');
	});
	$('a.more').click(function() {
		$(this).toggleClass("selected");
		$('div.info').slideToggle(200);
	}); 
	$('a.contact, a#close-form').each(function(index) {
		$(this).click(function() {
			$("a.contact").toggleClass("selected");
			$('div#contact-form').slideToggle(500);
		});
	});
	$('input.datepicker').datepicker({dateFormat: 'm/d/yy' });     

	var options = { 
		beforeSubmit:  showRequest,  // pre-submit callback 
		success:       showResponse  // post-submit callback 
	}; 

	$('#lead_form').ajaxForm(options); 
	




	function showRequest(formData, jqForm, options) { 
			var queryString = $.param(formData); 
			var contactEmail = $('input#contact_email').fieldValue(); 
		    if (!contactEmail[0]) { 
		        alert('Please enter an email address.'); 
		        return false; 
		    }
		return true; 
	} 

	function showResponse(responseText, statusText)  { 
		$("#lead_form .submit").hide();
		$("#lead_form div.last").append('<img src="/_assets/images/ajax-loader.gif" alt="Loading" id="loading" />');
		$("#hideme").slideUp("slow", function() {				   
			$("#hideme").after('<div id="thanks"><h2>Thank You</h2><p>After a sales representative receives and reviews your request, you will receive a call within 2 business days.</p></div>');	
			$("#thanks").fadeIn("slow");							
		});
	}
});