jQuery(document).ready(function(){
								
	//function for contact form dropdown
	function contact() {
		
		if (jQuery("#contactForm").is(":hidden")){
			/*$("#contactForm").show();*/
			jQuery("#contactForm").slideDown("slow");
			jQuery("#backgroundPopup").css({"opacity": "0.7"});
			jQuery("#backgroundPopup").fadeIn("slow");
			jQuery(".close").slideDown("slow");
		}
		else{
			jQuery(".close").hide();
			jQuery("#contactForm").slideUp("slow");
			jQuery("#backgroundPopup").fadeOut("slow"); 
			jQuery('.event_date-missing').hide();
			jQuery('.mobile-missing').hide();
			jQuery('.email-missing').hide();
			jQuery('.name-missing').hide();
			jQuery('.event_loc-missing').hide(); 
			jQuery('.message-missing').hide(); 
		}
	}
	
	jQuery('#contactForm1 input[type="text"],#contactForm1 textarea').val("");
	 jQuery('#contactForm1 input[id=hh]').attr('checked', false);
	//run contact form when any contact link is clicked
	jQuery("#contact").click(function(){contact()});
	jQuery("#contactFooter1").click(function(){contact()});
	jQuery("#contactFooter2").click(function(){contact()});
	jQuery("#contactFooter3").click(function(){contact()});
	jQuery("#contactFooter4").click(function(){contact()});
	jQuery(".close").click(function(){contact()});
	
	//animation for same page links #
	jQuery('a[href*=#]').each(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname
		&& this.hash.replace(/#/,'') ) {
		  var $targetId = jQuery(this.hash), $targetAnchor = jQuery('[name=' + this.hash.slice(1) +']');
		  var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
			if (jQuery(this.hash).length) {
				jQuery(this).click(function(event) {
					var targetOffset = jQuery(this.hash).offset().top;
					var target = this.hash;
					event.preventDefault();			   
					jQuery('html, body').animate({scrollTop: targetOffset}, 500);
					return false;
				});
			}
		}
	});



   //submission scripts
  jQuery('.submit').live('click', function(){
										  jQuery('#contactForm').css({"height": "480px"});

		//statements to validate the form	
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var email = document.getElementById('e-mail');
		if (!filter.test(email.value)) {
			jQuery('.email-missing').show();
		} else {jQuery('.email-missing').hide();}
		if (document.cform.mobile.value == "") {
			jQuery('.mobile-missing').show();
		} else {jQuery('.mobile-missing').hide();}	
		if (document.cform.event_date.value == "") {
			jQuery('.event_date-missing').show();
		} else {jQuery('.event_date-missing').hide();}
		if (document.cform.event_loc.value == "") {
			jQuery('.event_loc-missing').show();
		} else {jQuery('.event_loc-missing').hide();}
		if (document.cform.name.value == "") {
			jQuery('.name-missing').show();
		} else {jQuery('.name-missing').hide();}	
		/*if (document.cform.message.value == "") {
			jQuery('.message-missing').show();
		} else {jQuery('.message-missing').hide();}	*/	
		if ((document.cform.name.value == "") || (!filter.test(email.value)) || (document.cform.mobile.value == "")){
			return false;
		} 
		
		if ((document.cform.name.value != "") && (filter.test(email.value)) &&  (document.cform.mobile.value != "")) {
	
	var form_data = jQuery("#contactForm1").serialize();
//alert(form_data);
jQuery.ajax({
    type: "post",
    url: "mail.php",
   data: form_data,
    success: function(msg){
	//alert(msg);
	//jQuery('.contactForm').hide();
		//show the loading bar
			//jQuery('.loader').append(jQuery('.bar'));
			//jQuery('.bar').css({display:'block'});
			//  jQuery('.bar').css({display:'none'});
			  jQuery('#contactForm').html(msg);
	jQuery("#contactFormContainer").show();
	jQuery("#contact","#contactFormContainer").show();
	//var prev_html=jQuery("#contactForm").html();
   // jQuery("#contactForm").html(msg);
	setTimeout('jQuery("#backgroundPopup").fadeOut("slow"); jQuery("#contactForm").slideUp("slow")', 2000);

	setTimeout('location.reload();', 4000);
	
	
//	jQuery("#contactForm").html(prev_html);
    }
  });
	
	/*		//hide the form
			jQuery('.contactForm').hide();
		
			//show the loading bar
			jQuery('.loader').append(jQuery('.bar'));
			jQuery('.bar').css({display:'block'});
		
			//send the ajax request
			jQuery.post('mail.php',{name:jQuery('#name').val(),
							  email:jQuery('#e-mail').val(),
							  message:jQuery('#message').val()},
		
			//return the data
			function(data){
			  //hide the graphic
			  jQuery('.bar').css({display:'none'});
			  jQuery('.loader').append(data);
			});
			
			//waits 2000, then closes the form and fades out
			setTimeout('jQuery("#backgroundPopup").fadeOut("slow"); jQuery("#contactForm").slideUp("slow")', 2000);
			
			//stay on the page
			return false;*/
			//document.cform.submit();
		} 
  });
	//only need force for IE6  
	jQuery("#backgroundPopup").css({  
		"height": document.documentElement.clientHeight 
	});  
});
