/*
 * Save User Event AJAX
 */

function saveUserEvent(eventName, eventValue, eventType) {
	//post if off via ajax
	var url     = "/explorers/api/saveuserevent.php";
	$.post(url, {'eventName': eventName,
				 'eventValue': eventValue	
				});
}

/*
 * Popup Window
 */
function popup(href) {
	window.open(href, '_blank', 'width=400,height=500,scrollbars=yes');
	return false;
}

function saveUserEvent(eventName, eventValue, eventType) {
	//post if off via ajax
	var url     = "/explorers/api/saveuserevent.php";
	$.post(url, {'eventName': eventName,
				 'eventValue': eventValue	
				});
}

/*
 * Onload
 */

$(document).ready(function() {

	// Login form JS
	$('#emailAddress').focus(function() {
		if($(this).val() == 'Email') {
			$(this).val('');
		}
	}).blur(function() {
		if($(this).val() == '') {
			$(this).val('Email');
		}
	});
	$('#password').focus(function() {
		if($(this).val() == '******') {
			$(this).val('');
		}
	}).blur(function() {
		if($(this).val() == '') {
			$(this).val('******');
		}
	});
	
	// hide comment box if comment is empty
	if ($('#attitudeReason').val() == '') {
		$('#attitudeReasonBox').addClass('displayNone');
	}
	
	// 'next' button JS
	$('#next').click(function(e) {
		var form = $('form.registerform');
		var errors = $('.activeError');
		if (errors.length) {
			//console.log(errors.eq(0).prev().attr('id'));
			errors.eq(0).prev().focus();
			if (e && e.preventDefault()) {
				e.preventDefault();
			}
			return false;
		}
		else {
			form.submit;
		}
	});
});