$(document).ready(function(){
	$(".scrollable").jCarouselLite({
		vertical: true,
		visible: 8,
		auto: 800,
		speed: 1000
	});

	$('.jumppage').hide();
	$('.jumppagenumber').bind('change', function(e) {
		window.location = window.location.pathname + '?page=' + $(this).val();
	});
	$('.rounder').corner('keep');
	$('.rwithout').corner();
	$('#holder').corner('bottom');
	$('.socialrotate').cycle({timeout: 5000});
	$('.rotate').cycle({timeout: 20000, random:  1});
	$('.tips').corner('bottom tr');
	$('.tips_display .current').corner('top');
	$('.calculator a').bind('mouseover',function(e) {
		$(this).css({'background-image':'url(images/buttons/img_arrow_rollover.gif)'});
	});
	$('.calculator a').bind('mouseout',function(e) {
		$(this).css({'background-image':'url(images/buttons/img_arrow_normal.gif)'});
	});
	$('#steptwo').hide();
	$('.enterandwin_alternate').hide();
	$('#enterandwin_next').show();
	$('#enterandwin_next').bind('click',function(e) {
		err=0;
		/*ability = $('input[name=ability]:checked').val();
		goal = $('input[name=goal]:checked').val();*/
		competition = $('#alternate').val();
		errmsg = 'Please answer the following:<br />';
		/*if (ability == undefined) {
			err++;
			errmsg += '- "Did you achieve your FebuSave goal?"<br />';
		}
		if (goal == undefined) {
			err++;
			errmsg += '- "How did you find your ability to reach your FebuSave goal?"<br />';
		}*/
		if (competition == '') {
			err++;
			errmsg += '- "What was your secret to achieving your FebuSave goal?"<br />';
		}
		if (err > 0) {
			$('#enterandwinerror').html(errmsg);
			$('#enterandwinerror').slideDown('slow');
			
		} else {
			$('#enterandwin_steptwo').slideDown('slow');
		}
	});
	$('#register_next').show();
	$('#register_next').bind('click', function(e) {
		$('#steptwo').fadeIn('slow');
	});
	
	if ($('#reg')) {
		$('#reg').validate({
			errorLabelContainer: "#errorBox",
			wrapper: "em",
			messages: {
				firstname: 'Please provide a first name',
				lastname: 'Please provide a last name',
				emailaddress: {
					required: 'Please provide an email address',
					email: 'Please provide a valid email address'
				},
				phone: 'Please provide a valid phone number (including area code)',
				postcode: 'Please provide a valid postcode',
				password: 'Please enter a password',
				dob: 'Please enter your birthday'
			}
		});
	}
	if ($('.acchde')) {
		if ($('.acchde:visible')) {
			$('.acchde').hide();
		}
	}
	if (window.location.hash != '') {
		$(window.location.hash).show();
	}
	if ($('#saving')) {
		if ($('#saving').val() == 'other') {
			other('.other', false);
		} 
		$('#saving').bind('click', function(e) {
			pl = this.value;
			if (pl == 'other') {
				other('.other', false);
			} else {
				other('.other', true);
			}
		});
	};
});
function imageswitch(pl, tothis) {
	$(pl).attr('src', tothis);
}
function other(pl, invis) {
	if ($(pl)) {
		if (invis == true) {
			$(pl).hide();
		} else {
			$(pl).show();
		}
	}
}
function acchde(pl) {
	$('.acchde:visible').slideUp();
	$(pl).slideDown('slow');
}
function tagthis(pl) {
	$('.rtas:visible').slideUp('slow', function(e) {
		$('.' + pl).slideDown('slow');
	});
	
}