var undefined;
var linkActionned = false;

function perform(f, actionName, confirmMsg) {
	if ( !linkActionned ) {
		if (confirmMsg == undefined || confirm(confirmMsg)) {
			f.ACTION.value = actionName;
			f.AUTHENTIFICATE.value = 'true';			
			if (f.ACTION_ID != undefined)
				f.ACTION_ID.value = new Date().getTime();
			linkActionned = true;
			f.submit();
		}
	}
}

function download(f, actionName, id) {
	f.DOWNLOAD.value = id;
	f.ACTION.value = actionName;
	f.ACTION_ID.value = new Date().getTime();
	f.AUTHENTIFICATE.value = 'true';				
	f.submit();
}

function goOver(text) {
	window.status=text;
	return true;
}

function goOut() {
	window.status="";
	return true;
}

function goTo(f, nextPage) {
	f.NEXT_PAGE.value = nextPage;
	f.ACTION.value = 'GoTo';
	f.AUTHENTIFICATE.value = 'false';	
	f.submit();
}

function changeLang(f, language, nextPage) {
	f.NEXT_PAGE.value = nextPage;
	f.LANGUAGE.value = language;
	f.AUTHENTIFICATE.value = 'false';
	perform(f, 'ChangeLanguage');
}

function trim(str) {
	var pattern = /^\s*(\S*)\s*$/;
	var result = str.match (pattern);
	if (result!=null)
		return result[1];
	return str;
}

function changeStyle(id, style) {
	var tmpInner;  
	if ( document.getElementById )
  		tmpInner = document.getElementById(id).innerText;
	else if ( document.all )
  		tmpInner = document.all[id2].innerText;

  	if (style != undefined)
  		tmpInner = "<a style='" + style + "'>" + tmpInner + "</a>";
	
	if ( document.getElementById )
  		document.getElementById(id).innerHTML = tmpInner;
	else if ( document.all )
  		document.all[id2].innerHTML = tmpInner;
}

function checkLogin (login){
	var unauthChars = /[^\w\d_\-]/;
	if (trim(login)=="" || login.match(unauthChars)!=null){
		return false;
	}
	return true;
}

function centeredPopup(page,largeur,hauteur,options) {
  var top=(screen.height-hauteur)/2;
  var left=(screen.width-largeur)/2;
  window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

function pageLoad(alertMessage, notificationMessage) {
	if (alertMessage != '' && alertMessage.length>0)
		alert(alertMessage)
	if (notificationMessage != '' && notificationMessage.length>0) {
		centeredPopup('/frontoffice/notification.jsp', 300,100,'menubar=no,resizable=no,scrollbars=yes,status=no');
	}
}



