window.addEvent('domready', function() {
		
	//set up noobSlide
	var srgSlide = new noobSlide({
		box: $('pages'),
		items: $$('#pages div.page'),
		size: 818,
		handles: $$('#handles li a'),
		addButtons: {previous: $('prev'), next: $('next') },
		fxOptions: {duration: 1000, wait: false},
		onWalk: function(currentItem,currentHandle){
			this.handles.removeClass('active');
			currentHandle.addClass('active');
		}
	});
	
	//jumps to page if anchor included in URL
	var startPage = self.document.location.hash.substring(1);
	if (startPage.length > 0) {
		$(startPage).fireEvent('click');
	}
	
    SqueezeBox.initialize({
        size: {x: 800, y: 440}
    });
    SqueezeBox.assign($$('a[rel=boxed]'), {
		parse: 'rev'
	});
 
});

function updateCharCount(inp, target) {
	var maxLen = $(inp).maxLength;
	var txtLen = $(inp).value.length;
	$(target).innerHTML = maxLen - txtLen + " characters remaining";
}

function checkWich() {
	if ($('userwiches_types_id').options[$('userwiches_types_id').selectedIndex].value == "") {
		alert('Please choose your Wich.');
		return false;
	} else if (($('toppings').value == "") || ($('toppings').value == "Your Toppings")) {
		alert('Please describe your toppings.');
		return false;
	} else if (($('userwiches_name').value == "") || ($('userwiches_name').value == "Your Name")) {
		alert('Please enter your name.');
		return false;
	} else if (($('userwiches_email').value == "") || ($('userwiches_email').value == "Your Email")) {
		alert('Please enter your email address.');
		return false;
	} else {
		alert('Thank you! Your Wich will display once it has been approved.');
		$('wichform').submit();
	}
}