function request_update_comanda (what, where) {
	if ( (what != '') && (where != '') )

        $('#'+where).load(Path+'_procespass.php?getSection=' + what  , {forcePost:1})
		$('#'+where+'-alert').html('');
	//	console.log($('#mainmodules'));

}

function post_form (what_type, what_to, what_prod, comofcomid) {
   switch (what_type) {
		
		case 'trimite_pass':
				
	msg_alert = '';
	send_form = 'true';

  if (!isValidEmailAddress($('#fogpass_email').val())) {
		send_form = 'false';
		msg_alert += "<br />" + 'Va rugam completati adresa de email!';
	}

	
	if (send_form == 'true') {
		//submit form
         $.ajax({type: 'POST', url: Path+'_procespass.php', data: $('#'+what_to).serializeArray(), success: update_comanda});
		}
		
		else { alert_x(msg_alert); }
	return false;


		break;

	}
}

function update_comanda(returned_response) {
		//console.log('trece');
		if(returned_response=='') {
		request_update_comanda('parola_trimisa', 'recuperare-parola');
		
		}
		
		else {
		obj = document.getElementById('recuperare-parola-alert');
		obj.innerHTML = returned_response;
	}
		
}


function alert_x(msg) {
		 $('<div id="alert" title="Alerta!">'+msg+'</div>').dialog({
			bgiframe: true,
			modal: true,
			width: 420,
			buttons: {
				Ok: function() {
					$(this).dialog('close');
				}
			}
		});
	}
	

function isValidEmailAddress(emailAddress) {

var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);

return pattern.test(emailAddress);

}

