// JavaScript Document  
$(document).ready(function(){	
$(".ui-widget-overlay").live('click', function(){
   $(".ui-dialog-titlebar-close").trigger('click');
});

		
	// Open Strict In New Window 	
$(function() {
	$('a[rel*=external]').click( function() {
		window.open(this.href);
		return false;
	});
});
	
		
// Form Validator With Ajax Submit	   
jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
    phone_number = phone_number.replace(/\s+/g, ""); 
	return this.optional(element) || phone_number.length > 9 &&
		phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
}, "Please specify a valid phone number");   				   
	$("#commentForm").validate({
							   rules: {
    field: {
      required: true, phoneUS: true
    }
 	},
	   submitHandler: function(form) {
		$(form).ajaxSubmit();
		$('#commentForm').hide('fast');
		$('#successmessage').delay(700).show('fast');
	   }
	})
	
	
	
	

	$('#header ul li:first-child').addClass('first');
	$('#header ul li:last-child').addClass('last');
	
});













// JavaScript Document
//Accordion & Modal Dialog User Created JS

$.fn.clearForm = function() {
  return this.each(function() {
 var type = this.type, tag = this.tagName.toLowerCase();
 if (tag == 'form')
   return $(':input',this).clearForm();
 if (type == 'text' || type == 'password' || tag == 'textarea')
   this.value = '';
 else if (type == 'checkbox' || type == 'radio')
   this.checked = false;
 else if (tag == 'select')
   this.selectedIndex = -1;
  });
};



$(function(){

				// Accordion
				$("#accordion").accordion({header: "h5", animated: 'Explode', fillSpace: true, collapsible: true, active: false
  });

	$('#dialog').dialog({
					autoOpen: false,
					width: 800, 
					modal: true,
					resizable: false,
					
					height: 400
					
				
				});
				
				
				
		$('#contactDialog').dialog({
					autoOpen: false,
					modal: true,
					resizable: false,
					width: 400,
					height: 470
					
				
				});
							
				$( "#contactDialog" ).dialog({
   close: function(event, ui) {
	     $('#successmessage').css({'display' : 'none'});
	 $('.cmxform').css({'display' : 'block'});
	   $('.cmxform').clearForm()
	   }
});
				

		
			
			$('#learnMoreBtn').click(function(){
					$('#dialog').dialog('open');
					$("#dialog").dialog( "option", "title", '<div class="cufonheading">When Should I Call An Ambulance?</div>' );
	

					
					Cufon.replace('.cufonheading'); 
					return false;
				});
			$('#contactBtn').click(function(){
					$('#contactDialog').dialog('open');
					$("#contactDialog").dialog( "option", "title", '<div class="cufonheading">Contact Us</div>' );
			Cufon.replace('.cufonheading'); 
					return false;
			});
	
	
	
	
			});

		
		

				  
$(document).ready(function(){	
						   
	jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
    phone_number = phone_number.replace(/\s+/g, ""); 
	return this.optional(element) || phone_number.length > 9 &&
		phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
}, "Please specify a valid phone number");
		   	   
	$("#commentForm").validate({
							   rules: {
    field: {
      required: true, phoneUS: true
    }
 	},
	   submitHandler: function(form) {
		$(form).ajaxSubmit();
		$('#commentForm').hide('fast');
		$('#successmessage').delay(700).show('fast');
		
	   }
	})






$("#commentForm #hiddenvalue").val("isNanNow")




});










  
