/**
 * Javascript for edit customer form.
 * 
 * @version $Id$
 * @package ARTIO Booking
 * @subpackage assets
 * @copyright Copyright (C) 2010 ARTIO s.r.o.. All rights reserved.
 * @author ARTIO s.r.o., http://www.artio.net
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 * @link http://www.artio.net Official website
 */

window.addEvent('domready', function() {
   var login = document.getElement('#user2 #username');
   var email = document.getElement('#user3 #email');
   var pass = document.getElement('#user4 #password');
   var pass2 = document.getElement('#user5 #password2');
   var create = document.getElement('#select_new_user');
   if (login && email && pass && pass2 && create) {
       if (login.value.trim() !== '' || email.value.trim() !== '' || pass.value.trim() !== '' || pass2.value.trim() !== '') {
           ViewCustomer.selectNewUser();
           create.checked = true;
       }
   }
});

var ViewCustomer = {

	/**
	 * Submit page to display customers reservations list.
	 */
	displayReservations : function() {
		var form = ACommon.getForm();
		form.controller.value = 'reservation';
		form.task.value = '';
		form.submit();
	},
	
	selectExistingUser : function() {
		document.id('user1').setStyle('display', '');
		document.id('user2').setStyle('display', 'none');
		document.id('user3').setStyle('display', 'none');
		document.id('user4').setStyle('display', 'none');
		document.id('user5').setStyle('display', 'none');
	},
	
	selectNewUser : function() {
		document.id('user1').setStyle('display', 'none');
		document.id('user2').setStyle('display', '');
		document.id('user3').setStyle('display', '');
		document.id('user4').setStyle('display', '');
		document.id('user5').setStyle('display', '');
	}
}