function Calendario(textBox) {
	var data = document.getElementById(textBox);
	window.open('../controls/calendar.aspx?TextBox=' + textBox + '&data=' + data.value, '', 'width=250,height=270,status=no,help=no,resizable=no,scrollbars=no');
}

function EnterPressed(evt)
{
	evt = (evt) ? evt : (window.event) ? event : null;
	if (evt) 
	{
		var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
		if (charCode == 13) return true;
	}
	
	return false;
}
		
function CheckPrice(theField) {
	if (isNaN(theField.value)) {
		alert("Il numero inserito non è valido");
		
		return;
	}
}

/* Controlla che l'input sia un numero intero */
function ValidateInt(evt) {
	evt = (evt) ? evt : (window.event) ? event : null;
	if (evt) {
		var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
		if ((charCode < 48 || charCode > 57) && charCode != 8 && charCode != 9)
			return false;
	}
	return true;
}

/* Controlla che l'input sia un numero decimale */
function ValidateDecimal(evt) {
	evt = (evt) ? evt : (window.event) ? event : null;
	if (evt) {
		var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
		if ((charCode < 48 || charCode > 57) && charCode != 8 && charCode != 46 && charCode != 44 && charCode != 9)
			return false;
	}
	return true;
}

/* Verifica se il numero è un decimale valido altrimento lo converte */
function CheckDecimal(theField) {
	var newstr = theField.value.replace(',', '.') ;
	if (isNaN(newstr)) {
		alert('Numero inserito non valido!');
		theField.value = '';
	} else {
		newstr = theField.value.replace('.', ',') ;
		theField.value = newstr;
	}
}

/* Verifica se il numero è un intero valido altrimento lo converte */
function CheckInt(theField) {
	if (isNaN(theField.value)) {
		alert('Numero inserito non valido!');
		theField.value = '';
	}
}

function CheckInt(theField, maxValue) {
	if (isNaN(theField.value)) 
	{
		alert('Numero inserito non valido!');
		theField.value = '';
	}
	else if (theField.value > maxValue)
	{
		alert('Numero inserito superiore al valore massimo!');
		theField.value = maxValue;
	}
}

function openCenteredWindow(url, name, width, height, parms) 
{
   var left = Math.floor( (screen.width - width) / 2);
   var top = Math.floor( (screen.height - height) / 2);
   var winParms = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
   if (parms) { winParms += "," + parms; }
   var win = window.open(url, name, winParms);
   if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
   return win;
}

function Redirect(url)
{
	var version = navigator.appVersion;
	if (version.indexOf("MSIE") >= -1)
	{ window.location.href=url; }
	else
	{ window.open(url, target="_self");	}
}

function MM_findObj(n, d) 
{
	var p,i,x;

	// La ricorsione per la ricerca inizia a livello del documento
	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];
		
	// Ricorsione per tutti i layer. Ci si interrompe se si trova l'oggetto
	for (i=0; !x && d.layers && i < d.layers.length; i++)
			x = MM_findObj(n, d.layers[i].document);
		
	// Se infine non si è ancora trovato l'oggetto si usa il metodo GetElementById 
	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];
		}
}

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_preloadImages() 
{ 
  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 WriteMediaPlayerObject(Filename, Width, Height)
{
document.write('<object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codeBase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" style="WIDTH: ' + Width + 'px HEIGHT: ' + Height + 'px" id="mediaPlayer" type="application/x-mplayer2" standby="Loading Microsoft Windows Media Player components..." VIEWASTEXT>');
document.write('<param name="filename" value="' + Filename + '" />');
document.write('<param name="transparentatstart" value="false" />');
document.write('<param name="autostart" value="true" />');
document.write('<param name="bufferingtime" value="5" />');
document.write('<param name="showcontrols" value="true" />');
document.write('<param name="showstatusbar" value="true" />');
document.write('<param name="loop" value="false" />');									
document.write('<embed src="' + Filename + '" width="' + Width + '" height="' + Height + '" id="mediaPlayer" type="application/x-mplayer2" pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" displaysize="4" autosize="1" bgcolor="darkblue" showcontrols="1" showtracker="1" showdisplay="0" showstatusbar="1" videoborder3d="0" autostart="1" designtimesp="5311" loop="0"/>');
document.write('</object>');
}
