$(document).ready(function(){
	
$('#largePromo').cycle({
	timeout:10000,
	speed:100,
	sync:0,
	cleartype:true, 
	cleartypeNoBg:false
});

$('.historyLink').click(function (e) {
		$('#historyPopup').modal();
		  return false;
	});
	
$("#mailFrm").submit(function() {
	dataString = $("#mailFrm").serialize(); 
	$.ajax({
		type: "POST", 
		url: "forms_cb.php",
		data: dataString,
		dataType: "json",
		success: function(data) {
    	 if (data.success == 'FAIL')
				{
					$("#statusbox").html('<ul></ul>');
					$("#statusbox" + ' ul').empty().addClass('mailErrors');
					$.each(data.errors, function(index, value) {
					$("#statusbox" + ' ul').append("<li>" + value.replace('_', ' ') + "</li>");
					});
				} 
				else  if (data.success == 'PASS') 
				{
					$("#statusbox").html('<ul></ul>');
					$("#statusbox" + ' ul').empty().addClass('mailSuccess');
					$.each(data.pass, function(index, value) {
					$("#statusbox" + ' ul').append("<li>" + value.replace('_', ' ') + "</li>");
					});
					resetForm('mailFrm');
				}								
			}
	});
	return false; 
	});	

$("#nlSignupFrm").submit(function() {
	dataString = $("#nlSignupFrm").serialize(); 
	$.ajax({
		type: "POST", 
		url: "forms_cb.php",
		data: dataString,
		dataType: "json",
		success: function(data) {
    	 if (data.success == 'FAIL')
				{
					$("#statusbox").html('<ul></ul>');
					$("#statusbox" + ' ul').empty().addClass('mailErrors');
					$.each(data.errors, function(index, value) {
					$("#statusbox" + ' ul').append("<li>" + value.replace('_', ' ') + "</li>");
					});
				} 
				else  if (data.success == 'PASS') 
				{
					$("#statusbox").html('<ul></ul>');
					$("#statusbox" + ' ul').empty().addClass('mailSuccess');
					$.each(data.pass, function(index, value) {
					$("#statusbox" + ' ul').append("<li>" + value.replace('_', ' ') + "</li>");
					});
					resetForm('nlSignupFrm');
				}								
			}
	});
	return false; 
	});
	
$("#nlUnsubscribeFrm").submit(function() {
	dataString = $("#nlUnsubscribeFrm").serialize(); 
	$.ajax({
		type: "POST", 
		url: "forms_cb.php",
		data: dataString,
		dataType: "json",
		success: function(data) {
    	 if (data.success == 'FAIL')
				{
					$("#statusbox").html('<ul></ul>');
					$("#statusbox" + ' ul').empty().addClass('mailErrors');
					$.each(data.errors, function(index, value) {
					$("#statusbox" + ' ul').append("<li>" + value.replace('_', ' ') + "</li>");
					});
				} 
				else  if (data.success == 'PASS') 
				{
					$("#statusbox").html('<ul></ul>');
					$("#statusbox" + ' ul').empty().addClass('mailSuccess');
					$.each(data.pass, function(index, value) {
					$("#statusbox" + ' ul').append("<li>" + value.replace('_', ' ') + "</li>");
					});
					resetForm('nlUnsubscribeFrm');
				}								
			}
	});
	return false; 
	});		
	
$("#nav-one li").hover(
		function(){ $("ul", this).fadeIn("fast"); }, 
		function() { } 
	);
	if (document.all) {
		$("#nav-one li").hoverClass ("sfHover");
	}
});

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});

	
};

// FORM RESET - CLEARS FORM OF PREVIOUSLY ENTERED DATA
function resetForm(id) {
	$('#'+id).each(function(){
	        this.reset();
	});
}

function getHistory(id) {
	dataString = "year=" + id; 
	$.ajax({
		type: "POST", 
		url: "about-us_cb.php",
		data: dataString,
		dataType: "string",
		success: function(data) {
    	 	$("#history").html(data);						
		}
	});
	return false; 
}
