/*************************************************************************************************************
GOAL	: Cette fonction evalue si une chaine de caracteres suis un modèle(pattern) determiner

INPUT 	: str, pattern

		str 	: 	une chaine de caracteres a evaluer
		pattern	:	pattern a respecter

OUTPUT	: vrai si le pattern est respecter, faux sinon

------------------------------------------------------------------------------------------------------------
data type			regular expression									accepts 					rejects
------------------------------------------------------------------------------------------------------------
whitespace 				/^\s+$/											spaces, tabs, etc. 			0 a 
single letter 			/^[a-zA-Z]$/									a A							0 . - 
alphabetic string 		/^[a-zA-Z]+$/									aAbB 						a1 23 
single digit 			/^\d/											0 							00 1a 
single letter or digit 	/^([a-zA-Z]|\d)$/								0 a 						00 1a 
alphanumeric string 	/^[a-zA-Z0-9]+$/								a1b2 						2.5 1.a 
integer 				/^\d+$/											0 23 						23.5 
signed integer 			/^(+|-)?\d+$/									-1 +12 						-1.1 
floating point number 	/^((\d+(\.\d*)?)|((\d*\.)?\d+))$/ 				1.1    .9     8. 			-1.1  . 
signed float 			/^(((+|-)?\d+(\.\d*)?)|((+|-)?(\d*\.)?\d+))$/ 	-1.1   1.1  .9   8. 		1a 
email address 			/^.+\@.+\..+$/									a@b.c 						a@b 
------------------------------------------------------------------------------------------------------------
*************************************************************************************************************/
function isPattern(str, pattern)
{
	var valid_format = pattern;

	// pattern respecter
	if (str.match(valid_format))
	{
		return true;
	}
	// pattern non respecter
	else
	{
		return false;
	}
}

/***************************************************************
*  Function Name:                                              *
*  Author:                                                     *
*  Creation Date:  2004/04/04                                  *
*  Function:                                                   *
*  Notes:                                                      *
****************************************************************/
function window_open_centered_to_screen(asp_function, window_width, window_height, window_name, current_form, window_features_more) //"resizable=yes,toolbar=no,scrollbars=yes"
{
	var left, top, window_features, window_handle;
	var screen_width = screen.width;
	var screen_height = screen.height;

	/* center calculation */
	left = (screen_width/2)  - (window_width/2);
	top  = (screen_height/2) - (window_height/2);
	
	//alert('x=' + left + ' y=' +top);
	
	/* window parameter */
	window_features = "height=" + window_height + ",width=" + window_width + ",left=" + left + ",top=" + top + "," + window_features_more;
	//alert(window_features);
	window_handle = window.open(asp_function, window_name, window_features);
	
	/* posting form if available*/
	if(current_form != '')
	{
		current_form.target = window_name;
		current_form.submit();
	}
	window_handle.focus();
	return false;
}
