function graphit(g,gwidth, Perc, DispTotale, LabelTotale, ClassBar, ClassTotal, barHeight)
{
	var Valore;
	var ValoreSimbolo;

	total=0
	for (i=0;i<g.length;i++)
	total+=parseInt(g[i][1])

	output='<table border="0" cellspacing="0" cellpadding="0">'
	for (i=0;i<g.length;i++)
	{
		calpercentage=Math.round(g[i][1]*100/total)
		calwidth=Math.round(gwidth*(calpercentage/100))

		if (Perc == true)
		{
			Valore = calpercentage;
			ValoreSimbolo = '%';
		}
		else
		{
			Valore = g[i][1];
			ValoreSimbolo = '';
		}
			

		output+='<tr><td><font class="' + ClassBar + '">'+g[i][0]+'&nbsp;&nbsp;</font></td><td><img src="'+graphimage+'" width="'+calwidth+'" height="' + barHeight + '"> <font class="' + ClassBar + '">'+ Valore + ValoreSimbolo + '</font></td></tr>'
	}
	output+='</table>'
	if (DispTotale == true)
		document.write(output+'<br><Font class="' + ClassTotal + '" >' + LabelTotale + ' '+total + ' </Font>')
	else
		document.write(output)

}

//restituisce il numero di decimali in un numero
function FindNumDecimal(valore, Separatore)
{
	var DecimalSeparator;
	var Length;
	
	Length = valore.length;
	DecimalSeparator = valore.indexOf(Separatore);
	
	if (DecimalSeparator>0)
		return Length - (DecimalSeparator+1)
	else
		return 0
}

function OpenPopUp(MyURL, MyWidth, MyHeight)
{
	var newWindow;
	var myurl = MyURL;
			
	var MyLeft=(screen.width - MyWidth) / 2;
	var MyTop=(screen.height - MyHeight) / 2;


	if (navigator.appName == "Microsoft Internet Explorer") 
		{
		 var props = 'scrollBars=yes,resizable=no,toolbar=no,menubar=no,location=no,directories=no,width=' + MyWidth + ',height=' + MyHeight + ',left=' + MyLeft + ',top=' + MyTop ;
		}
	else 
		{
		var props = 'scrollBars=yes,resizable=no,toolbar=no,menubar=no,location=no,directories=no,width=' + MyWidth + ',height=' + MyHeight + ',screenX=' + MyLeft + ',screenY=' + MyTop;
		}
				
	newWindow = window.open(myurl, "NewsWindow", props);
}

function SubstChar(Valore, CharSource, CharReplace)
{
	var Tag;
	var Length;
	var NewString;
	
	//Length = valore.length;
	
	Tag = Valore.indexOf(CharSource);
	if (Tag>0)
		NewString = Valore.substr(0, Tag) + CharReplace + Valore.substr(Tag +1);
	else
		NewString = Valore;
	
	return NewString
}


function FindNumDecimal(valore, Separatore)
{
	var DecimalSeparator;
	var Length;
	
	Length = valore.length;
	DecimalSeparator = valore.indexOf(Separatore);
	
	if (DecimalSeparator>0)
		return Length - (DecimalSeparator+1)
	else
		return 0
}



function isComboSelected(cmbCombo)
{
	vValue=cmbCombo.options[cmbCombo.selectedIndex].value
	return vValue!=-1
}

		
function isEmpty(txtText)
{
	re=/^\s*$/
	return re.test(txtText)
}

			
function isNumeric(txtText)
{
	re=/^\d+$/
	return re.test(txtText)
}


function isFloat(txtText)
{
	re=/(^\d+$)|(^\d+\,\d+$)|(^\d+\.\d+$)/
	return re.test(txtText)
}			


function isDate(txtText)
{
	//Verifica la corretta formattazione della stringa #0/#0/0000
	re=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/
	if (!re.test(txtText)) return 0
				
	//Suddivide la data in giorno, mese e anno
	vDatePart=re.exec(txtText)
	vDay=parseInt(vDatePart[1],10)
	vMonth=parseInt(vDatePart[2],10)
	vYear=parseInt(vDatePart[3],10)

	//Verifica il mese
	if (vMonth<1||vMonth>12) return 0
				
	//Determina il numero di giorni presenti nel mese
	switch(vMonth)
	{
		case 2:
			vDaysPerMonth=((vYear % 4 == 0) && ( (!(vYear % 100 == 0)) || (vYear % 400 == 0) ) ) ? 29 : 28
			break
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			vDaysPerMonth=31
			break
		case 4:
		case 6:
		case 9:
		case 11:
			vDaysPerMonth=30
			break
	}
				
	//Verifica se il giorno è corretto
	if (vDay<1||vDay>vDaysPerMonth) return 0
				
	//La data è valida
	return -1
}


function Replace(strString,CharOut,CharIn)
{
	strToSplit = new String (strString)

	pattern = CharOut

	ArrayString = strToSplit.split (pattern)

	FinalString=""
	for ( i = 0; i < ArrayString.length; i++) {
	   if (i==ArrayString.length-1)
			{	   
			FinalString=FinalString+(ArrayString[i])
			}
	   else
			{	   
			FinalString=FinalString+(ArrayString[i] + CharIn)
			}		
	}
	return FinalString;
}


function CheckEmail(TextBoxValue)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(TextBoxValue))
	{
	return (true)
	}
	return (false)
}


function OpenWindow(MyURL, MyWidth, MyHeight)
{
	var newWindow;
	var myurl = MyURL;
	//var props = 'scrollBars=no,resizable=no,toolbar=no,menubar=no,location=no,directories=no,width=' + MyWidth + ',height=' + MyHeight;
	newWindow = window.open(myurl, "NewsWindow");
}


function CloseWindow()
{
	window.close();
}

// Inizio Generazione Password (Funzione GetPassword)-->
function getRandomNum(lbound, ubound) {
return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}
function getRandomChar(number, lower, upper, other, extra) {
var numberChars = "0123456789";
var lowerChars = "abcdefghijklmnopqrstuvwxyz";
var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var otherChars = "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? ";
var charSet = extra;
if (number == true)
charSet += numberChars;
if (lower == true)
charSet += lowerChars;
if (upper == true)
charSet += upperChars;
if (other == true)
charSet += otherChars;
return charSet.charAt(getRandomNum(0, charSet.length));
}
function getPassword(length) {
var rc = "";
if (length > 0)
rc = rc + getRandomChar(false, true, false, false, '');
for (var idx = 1; idx < length; ++idx) {
rc = rc + getRandomChar(false, true, false, false, '');
}
return rc;
}
// Fine Generazione Password -->


//Apertura Popup Parametrica
function OpenPopUpParametric(MyURL, MyWidth, MyHeight, Title, scrollbars, resizable, menubar)
{
	var newWindow;
	var myurl = MyURL;

			
	var MyLeft=(screen.width - MyWidth) / 2;
	var MyTop=(screen.height - MyHeight) / 2;
			
	if (navigator.appName == "Microsoft Internet Explorer") 
		{
		 var props = 'scrollBars=' + scrollbars + ',resizable=' + resizable + ',toolbar=no,menubar=' + menubar + ',location=no,directories=no,width=' + MyWidth + ',height=' + MyHeight + ',left=' + MyLeft + ',top=' + MyTop ;
		}
	else 
		{
		var props = 'scrollBars=' + scrollbars + ',resizable=' + resizable + ',toolbar=no,menubar=' + menubar + ',location=no,directories=no,width=' + MyWidth + ',height=' + MyHeight + ',screenX=' + MyLeft + ',screenY=' + MyTop;
		}

	newWindow = window.open(MyURL,Title, props);
}


