function ajaxVideoLogin() {
	$('videoLoginAjaxIcon').style.display='inline';
	new Ajax.Request( 'login.php', {
		onSuccess: function(resp) {
			if( resp.responseText != '0' ){
				if( resp.responseText == 'buyed' ) {
					window.location = 'videos.php';
				} else {
					if( url = $('videoURL') ) {
						window.location = url.value;
					} else {
						$( 'os0' ).value = resp.responseText;
						$( 'paypalForm' ).submit();
					}
				}
			} else {
				mark( 'loginNameVideo', '', true );
				$( 'loginErrorsVideo' ).style.display='block';
				$('videoLoginAjaxIcon').style.display='none';
			}
		}, 
		parameters:$('ajaxLoginVideo').serialize(true) 
	} );
	return false;
}

function checkSignupVideo() {
	_errorMessage='';
	$( 'ajaxIconVideo' ).style.display = 'inline';

	if( markIfEmpty( 'username', 'Insert the username' ) )
		userEmpty = true;
	if( !markIfEmpty( 'password', 'Insert the password' ) )
		mark( 'password', 'The passwords are different', ( $( 'password' ).value != $( 'confirm' ).value ) );
	mark( 'agree', 'You must read the Terms and Conditions', !$( 'agree' ).checked );
	
	if( _errorMessage != '' ){
		$( 'signupErrorsVideo' ).innerHTML = _errorMessage;
		$( 'signupErrorsVideo' ).style.display = 'block';
		$( 'ajaxIconVideo' ).style.display = 'none';
	} else {
		new Ajax.Request( 'login.php', {
			onSuccess : function(resp) {
				if( resp.getHeader('Content-Type') == 'text/javascript' ){
					$( 'signupErrorsVideo' ).style.display='block';
					$('ajaxIconVideo').style.display='none';
				} else { 
					if( url = $('videoURL') ) {
						window.location = url.value;
					} else {
						$( 'os0' ).value = resp.responseText;
						$( 'paypalForm' ).submit();
					}
				}
					
			},
			onFailure : function() {
				alert("The server is not responding.");
			},
			parameters : $( 'signupFormVideo' ).serialize( true )
		} );
	}
	return false;
}

