// JavaScript Document
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*Popup*/

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// *********************************
//FUNZIONI PER IL CONTROLLO DEI DATI
// *********************************
/*

function setNomeAzienda(){
//	window.document.form_preventivo.nome_azienda.value="";
		window.document.form_preventivo.nome_azienda.value = curr_nome_azienda;
}

function storeNomeAzienda(){
//	window.document.form_preventivo.nome_azienda.value="";
		curr_nome_azienda = window.document.form_preventivo.nome_azienda.value;
}

*/
function IsNumeric(sText){
for (i=0;i<sText.length;i++){if("0123456789".indexOf(sText.charAt(i))==-1){return false;}}
return true;
}

function IsMoney(sText){
if ( ! /^\d*(,\d{1,2})?$/.test(sText) && ! /^\d{1,3}(\.\d{3})*(,\d{1,2})?$/.test(sText)) return false;
else return true;
}

function IsEmail(sText){
if ( ! /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})\.)+([a-zA-Z]{2,3})$/.test(sText)) return false;
else return true;
}

/*
function IsEmail(sText){

while (sText.substring(0,1) == ' ')
{
sText = sText.substring(1, sText.length);
}
return sText;

if ( ! /^[a-z]+([\.]?[a-z0-9_-]+)*@[a-z0-9]+([\.]?[a-z0-9-]+)*\.[a-z]{2,3}$/.test(sText)) return false;
else return true;

}
*/


function isDate(mm,dd,yyyy) {
   var d = new Date(mm + "/" + dd + "/" + yyyy);
   return d.getMonth() + 1 == mm && d.getDate() == dd && d.getFullYear() == yyyy;
}


//Funzione per il MouseOver - MouseOut 

function swap_image_unico(id_td,id_span){

	td = window.document.getElementById(id_td);
	bg = td.getAttributeNode('background');
	if(bg.value=="img/menu_alto_bottone2.gif"){
		bg.value='img/menu_alto_bottone.gif';
		window.document.getElementById(id_span).style.color='#003366';
		window.document.getElementById(id_span).style.fontWeight='normal';
		}
	else {
		bg.value='img/menu_alto_bottone2.gif';
		window.document.getElementById(id_span).style.color='#FFFFFF';
		window.document.getElementById(id_span).style.fontWeight='bold';
		}
	//alert(div.style.color);
/*	class = div.getAttributeNode('class');
	class.value='text_menu_up2';
	alert(div.getAttribute('class'));
*/
}

function trim(stringa){
    while (stringa.substring(0,1) == ' '){
        stringa = stringa.substring(1, stringa.length);
    }
    while (stringa.substring(stringa.length-1, stringa.length) == ' '){
        stringa = stringa.substring(0,stringa.length-1);
    }
    return stringa;
}



