
/*
Powerful Errors Template - Javascript file
Requires: jQuery 1.3+
          jQuery UI Core 
		  jQuery UI Effects Core
*/

/*** OPTIONS ***/
var email_message = 'Enter your email address...'; // the default text in the search box, you will also need to change this on the form itself for
												   // non-javascript browsers
												   
var date = {
	'year':		'2010',    // year
	'month':	'8',	   // month - use 1 to 12
	'date':		'24',      // date 1 to 31
	'hour':		'23',	   // hour - 0 to 23
	'minute':	'59',	   // minute - 0 to 59
	'second':	'59'	   // second - 0 to 59
}

var date_format = 'owDHMS';		// 'O' for months, 'W' for weeks, 'D' for days, 'H' for hours, 'M' for minutes, 'S' for seconds.
 								//  use lower case versions for "Optional" - i.e. the count will only show if it's greater than 0

/*** END OPTIONS ***/


// start jQuery
$(document).ready(function(){

	// this handles the search box message when it's focused and unfocused (on blur)
	$('#emailaddress').focus(function() {
		if($(this).attr("value") == email_message) {
			$(this).attr("value", '');
		}
	});
	
	$('#emailaddress').blur(function() {
		if($(this).attr("value") == '') {
			$(this).attr("value", email_message);
		}
	});
	
	$('#emailsubscribe').submit(function(){
		
		$('#loadingimg').show();												// show loading image
		var datastream = $("#emailsubscribe").serialize() + '&ajax=true';		// convert form data and add ajax boolean. This doesn't do anything
																				// by default but it's there for you to utilise
		jQuery.ajax({
			data: datastream,		
			url: this.action,	 // the ajax request will be sent to the ACTION value of the form
			timeout: 2000,
			error: function() {},
			success: function(r) { 
			  $('.ajaxresult').html(r); 	// put the result in the ajaxresult div
			  $('#loadingimg').hide();		// hide the image again
			}
	  	});
		
	  	return false;
	});


});
function close_response()
{
	$('.ajaxresult').html("");
}

$(function () {
	var austDay = new Date();
	austDay = new Date(date.year, date.month-1, date.date, date.hour, date.minute, date.second);
	$('#countdown').countdown({until: austDay, format: date_format});
});
