function reg(next) {

	// Validate input first
	if(validate_reg()) {

		var url = window.location.protocol + '//' + window.location.host + '/video/register.php?r=' + Math.floor(Math.random()*1001);
		var pars = 'next=' + next + '&name=' + $('rname').value + '&email=' + $('remail').value + '&company=' + $('rcompany').value + '&password=' + $('rpassword').value;
		
		var myAjax = new Ajax.Updater(
			'video', 
			url, 
			{
				method: 'get', 
				parameters: pars, 
				evalScripts: true
			});
	
	} else {
	
		window.alert('You must complete all 4 fields to register and use a valid email address.');
	
	}

} // reg()


function validate_reg() {

	// set defaults
	var emailtest = false;
	var nametest = false;
	var comptest = false;
	var pwtest = false;

	//check for valid email
	var emailRegExp  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
	emailtest = emailRegExp.test($('remail').value);
	
	if($('rname').value)
		nametest = true;

	if($('rcompany').value)
		comptest = true;

	if($('rpassword').value)
		pwtest = true;
		
	if(emailtest && nametest && comptest && pwtest)
		return true;
	else
		return false;

} // validate_reg()


function login() {

	// Validate input first
	if(validate_login()) {

		var url = window.location.protocol + '//' + window.location.host + '/video/login.php?r=' + Math.floor(Math.random()*1001);
		var pars = 'email=' + $('lemail').value + '&password=' + $('lpassword').value;
		
		var myAjax = new Ajax.Updater(
			'video', 
			url, 
			{
				method: 'get', 
				parameters: pars, 
				evalScripts: true
			});
	
	} else {
	
		window.alert('You must complete both fields using a valid email address and password.');
	
	}


} // login


function validate_login() {

	// set defaults
	var emailtest = false;
	var pwtest = false;

	//check for valid email
	var emailRegExp  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
	emailtest = emailRegExp.test($('lemail').value);
	
	if($('lpassword').value)
		pwtest = true;
		
	if(emailtest && pwtest)
		return true;
	else
		return false;

} // validate_login()