/* SCRIPT DIRECTORY
What you can find in this file [listed in order they appear]

       1.) Crossbrowser Placeholder Tag fix

*/


/**
* 1.) Crossbrowser Placeholder Tag fix
*/

$(document).ready(function(){
	if(!Modernizr.input.placeholder){	
		$('[placeholder]').focus(function() {
			var input = $(this);
			if (input.val() == input.attr('placeholder')) {
			input.val('');
			input.removeClass('placeholder');
			}
		}).blur(function() {
			var input = $(this);
			if (input.val() == '' || input.val() == input.attr('placeholder')) {
			input.addClass('placeholder');
			input.val(input.attr('placeholder'));
			}
		}).blur();
		$('[placeholder]').parents('form').submit(function() {
			$(this).find('[placeholder]').each(function() {
			var input = $(this);
			if (input.val() == input.attr('placeholder')) {
				input.val('');
			}
			})
		});	
	}
});

$(document).ready(function() {
	// validate contactus form on keyup and submit
	jQuery.validator.messages.required = "";
	jQuery.validator.messages.email = "";
	var validator = $("#form_newsletter_subscribe").validate({
		rules: {
			email: {
				required: true,
				email: true
			}
		}
	});

});


$(document).ready(function() {

  $('#_HOLD_submit_subscribe').click(function() {
		
		// get the value from the username field                              
    var email = $('#email').val();
		
		if (!email || email == 'email') {
			alert('Please enter an email address');
			return false;
		}
						
		var form_data = {
			email: $('#email').val()
		};		
				
		$.ajax({
			url: "<?php echo site_url('ajax/email_signup'); ?>?alt=json-in-script",
			//url: 'http://localhost/calvary/index.php/ajax/email_signup',
			cache: false,
			dataType: 'jsonp',
			type: 'POST',
			data: form_data,
			success: function(msg) {
				
				alert(msg);
								
				//$('#main_content').html(msg);
			},
			error: function (xhr, ajaxOptions, thrownError) {
				
				alert(xhr.status);
        alert(thrownError);

								
			},
		});
	
		
		

	
		return false;
		
  });  

});



