
$(function() {
	$("#menu li").click(function(){
		window.location=$(this).find("a").attr("href"); 
		return false;
	});	

    $("#menu li").hover(
      function () {
        $(this).find('a').addClass('selected');
      }, 
      function () {
        $(this).find('a').removeClass('selected');
      }
    );
	
	$('#eway_form').validationEngine();

	$("span.hidden").hide();
	
	$(".showPayment").bind('click', function() {
		$(".hidden").hide().find('input').removeClass('validate[required]');
		div = '#'+$(this).attr('id')+'_form';
		$(div).show().find('input').addClass('validate[required]');
	});		
	

	var locationPath = filterPath(location.pathname);
	// Scroll to anchors
	$('a[href*=#]').each(function() {
		var thisPath = filterPath(this.pathname) || locationPath;
		if (locationPath == thisPath
		&& (location.hostname == this.hostname || !this.hostname)
		&& this.hash.replace(/#/,'') ) {
			var $target = $(this.hash), target = this.hash;
			if (target) {
				var targetOffset = $target.offset().top;
				$(this).click(function(event) {
					event.preventDefault();
					$('html').animate({scrollTop: targetOffset}, 400, function() {
					location.hash = target;
					});
				});
			}
		}
	});	

	
}); 

function filterPath(string) {
	return string.replace(/^\//,'')
	.replace(/(index|default).[a-zA-Z]{3,4}$/,'')
	.replace(/\/$/,'');
}	