var errors = 0;

function makecookie(prov) {
	$.cookie('lda', 'set');
	$.cookie('cruise_province', prov);
}

function checkcookie() {
	if($.cookie('lda') == 'set') {
		return true;
	} else {
		return false;
	}
}

function openPopup(path) {
	window.open(path,'Budcamp','menubar=no,scrollbars=yes,resizable=no,width=645,height=500');
}

function ajaxLoad(page, elm) {
	$.ajax({
	  url: 'includes/'+page+'.php',
	  success: function(data) {
	    $('#'+elm).fadeOut('slow', function() {
			$('#'+elm).html(data);
		});
		$('#'+elm).fadeIn('slow', function() {});
	  }
	});
}

$(document).ready(function () {	
	Cufon.replace('.form_text_switch', {
		fontFamily: 'futuraB',
		textShadow: '3px 5px rgba(0, 0, 0, 0.2)'
	});	
	Cufon.replace('#pinForm .col label', {
		fontFamily: 'futuraB'
	});
	Cufon.replace('#ldaForm label.gen', {
		fontFamily: 'futuraB'
	});
	Cufon.replace('#navItems a.item', {
		fontFamily: 'futuraB',
		hover: {
			color: '#e2141a'
		}
	});
	Cufon.now();
	
	$('.button').hover(
		function() {
			this.src = this.src.replace("_off","_on");
		},
		function() {
			this.src = this.src.replace("_on","_off");
		}
	);
	
	$('#needPin').click(function() {
		$('html, body').animate({scrollTop:0}, 'fast', function() {
			$('#needPinPage').css('height', $(document).height());
			$('#needPinPage').fadeIn(500);
		});
	})
	
	$('#pinClose').click(function() {
		//$('html, body').css('overflow', 'scroll');
		$('#needPinPage').fadeOut(500);
	})
	
	if($('#ldaForm')[0] != undefined) {
		
		$('input.lda').focus(function() {
			$(this).val('');	
		});
		$('#date').autotab({ target: 'month', format: 'numeric', maxlength: 2 });
		$('#month').autotab({ target: 'year', previous: 'date', format: 'numeric', maxlength: 2 });
		$('#year').autotab({ target: 'province', previous: 'month', format: 'numeric', maxlength: 2 });
		
		$('#ldaForm label.noGen').mouseup(function() {
			//console.log(this);
			$('#ldaForm label').removeClass('active');
			$(this).addClass('active');
		});
	}
	
});
