function jumpToCategory(sel) {
	var value = sel.options[sel.selectedIndex].value;
	if (value && value != '') {
		document.location.href = '/categories/' + value + '.htm';
	}
}

function validateChangePassword(f) {
	var current = $('current_password').getValue();
	var newPass = $('new_password').getValue();
	var confirmPass = $('confirm_password').getValue();
	
	if (current == '' || newPass == '' || confirmPass == '') {
		alert("Please complete all three fields to continue.");
		return false;
	} else if (newPass != confirmPass) {
		alert("The values for your new password and the confirmation do not match. Please try again.");
		return false;
	}
	
	f.formAction.value = 'changePW';
	f.submit();
}

function addLoadEvent(func) {
    var oldOnLoad = window.onload;
    if (typeof window.onload != 'function') {
            window.onload = func;
    } else {
            window.onload = function() {
                    oldOnLoad();
                    func();
            }
    }
}

function checkMailingListStatus() {
	$('mailingListStatus').update('<img src="/script_images/ajax-loader-flat.gif" style="float: left;" /> &nbsp; &nbsp; Please wait... Checking to see whether you are on our mailing list...');
	new Ajax.Updater('mailingListStatus', '/ajaxRemote', {
		method: 'post',
		parameters: {
			action: 'isUserSubscribedToNewsletter'
		}
	});
	return false;
}

function addToMailingList() {
	$('mailingListStatus').update('<img src="/script_images/ajax-loader-flat.gif" style="float: left;" /> &nbsp; &nbsp; Please wait... Attempting to add your email address to our mailing list...');
	new Ajax.Updater('mailingListStatus', '/ajaxRemote', {
		method: 'post',
		parameters: {
			action: 'addToMailingList'
		}
	});	
	return false;
}

function removeFromMailingList() {
	$('mailingListStatus').update('<img src="/script_images/ajax-loader-flat.gif" style="float: left;" /> &nbsp; &nbsp; Please wait... Attempting to remove your email address from our mailing list...');
	new Ajax.Updater('mailingListStatus', '/ajaxRemote', {
		method: 'post',
		parameters: {
			action: 'removeFromMailingList'
		}
	});
	return false;
}
