//functions for making the countdown timer
function countdown_init(){
	if(si){ clearInterval(si); }	
	var si = setInterval("decrement()",60000);
}

function decrement(){
	var d = $("#days").text();
	var h = $("#hrs").text();
	var m = $("#mins").text();

	if(m > 0){ m--;}
	else{
			m = 59;
			if(h > 0){ h--;}else{h = 23;d--;}
			}
	
			$("#days").text(d);
			$("#hrs").text(h);
			$("#mins").text(m);
}

//function to add users to teh CM lists via ajax
function addSignupToCM(){
	var em = $("#email_addr").val();
	
	var pars = 'email_addr='+em;
		
		$.ajax({
		   type: "POST",
		   url: "ajax.signup.php",
		   data: pars,
			success: function(msg){
				if(msg == 'pass'){
					//clear out the fields
					$("#email_addr").val('');

					$("#email_addr").removeClass('pass');
					$("#email_addr").removeClass('errors');
	
					$("#form_feedback").html('Thank you for signing up.');
					$("#form_feedback").show();
				}else{
					$("#email_addr").addClass('errors');
					$("#form_feedback").html('Sorry, there was an error signing you up.');
					$("#form_feedback").show();
				}
			}
		 });
}

//function to rotate between 2 headers
function headerRotate(){
	$("#content_header_2").fadeOut(1500,function(){
		setTimeout("fadeBackIn()",6000);
	});
}

function fadeBackIn(){
	$("#content_header_2").fadeIn(1500,function(){
		setTimeout("headerRotate()",6000);
	});
}

window.onload = function(){
	formEvents();
}