/*=================================================*
 *     Variabili Globali                           * 
 *=================================================*/

// *************************
// separatori delle stringhe
// contenenti le preferenze 
// delle edizioni
// *************************
var edizioniListSep = ", ";
var edizioniCodeSep = "|";
var edizListCodeDataSep = " - ";

/*=================================================*
 *     Funzioni utilizzabili dalle pagine          * 
 *=================================================*/

/*
 Esegue il submit del form con l'attributo "id" specificato.
 */
function submitFormByID(formID, action, cmd, target) {

  var theForm = getFormByID(formID);
  if(action)
    theForm.action = action;

  if(target) 
    theForm.target = target;
  else 
    theForm.target = '';

  theForm.submit();
}

/*
 Cerca un form con l'id specificato.
 */
function getFormByID(formID) {
  if (! document.getElementById)
    alert("Browser non supportato !\n(document.getElementById) !");
    
  if (formID == null) {
    alert("parametro formID nullo");
    return null;
  }
  
  var theForm = document.getElementById(formID);
  
  if (theForm == null) {    
    return null;
  }
  
  return theForm;
}

/**
	Inibisce l'inserimento di uno
	spazio vuoto
	Da usare tipicamente
	con gli Input Text e l'evento
	onKeyPress
*/
function noBlankSpaces(e)
{
	var unicode=e.charCode? e.charCode : e.keyCode
	
	if (unicode==32)
		return false;
	/*{ 
		// if the key isn't the backspace key (which we should allow)
		if (unicode<48||unicode>57) //if not a number
			return false //disable key press
	}*/
}

/**
	forza l'inserimento di 
	soli caratteri numerici
*/
function numberOnly(e)
{
	var unicode=e.charCode? e.charCode : e.keyCode

	if (unicode<48||unicode>57) //if not a number
			return false //disable key press
}

/**
	Funzione che invoca il submit
	della form, impostandone Action
	e command
*/
function sub(action, cmd)
{
	var f = document.getElementById("mainForm");
	
	if (cmd)
		f.cmd.value = cmd;
	
	if (action)
		f.action = action;
	
	f.submit();
}

function checkCmd()
{
	var f = document.getElementById("mainForm");
}

/*
Escaping della stringa
*/
function escapeJs(value)
{
	var regExprBackSl = /\\/g;
	var regExprSingleQuote = /'/g;
	
	var r = value;
    r =	r.replace(regExprBackSl, "\\\\");
    r =	r.replace(regExprSingleQuote, "\\'");
 
	return r;
}
