// JavaScript Document
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//'******************************************************************************************************
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];}
}
//'******************************************************************************************************
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve essere una E-Mail valida.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' deve essere numerico.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' deve essere un numero tra '+min+' e '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' è un campo obbligatorio.\n'; }
  } if (errors) alert('Si sono verificati i seguenti errori:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//'******************************************************************************************************
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//'******************************************************************************************************
function cancella(nome, ID){
	risposta = confirm("Cancellare la voce \n" + nome + "?");
	if(risposta){
		MM_goToURL('parent','salvaCancella.asp?ID=' + ID);
		return document.MM_returnValue
	}
}
//'******************************************************************************************************
function inviaNewsLetter(){
	risposta = confirm("Confermate l'invio della newsletter?");
	if(risposta){
		MM_goToURL('parent','/admin/inviaNewsLetter.asp');
		return document.MM_returnValue
	}
}
//'******************************************************************************************************
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//'******************************************************************************************************
function submitForm(id){ //v3.0
  document.getElementById(id).submit;
}
//'******************************************************************************************************
function formatStr(v, form_name, foto)
{ 

	var modulo_name = selezionata;
//	if(navigator.appName.indexOf("Microsoft") > -1)
	{
		if(document.selection)
		{
			var str = document.selection.createRange().text;
			if(str) {
				if(v == "br")
					document.selection.createRange().text = str + '<'+v+'>';
				else if(v == "hr")
					document.selection.createRange().text = str + '<'+v+'>';
				else if(v == "link")
					document.selection.createRange().text = '<a href="' + prompt("inserire il link", "http://") + '">' + str + '</a>';
				else if(v == "email")
					document.selection.createRange().text = '<a href="mailto:' + prompt("inserire l'email", "") + '">' + str + '</a>';
				else if(v == "foto")
					document.selection.createRange().text = str + '<img src="/foto/' + foto + '">';
				else if(v == "size")
					document.selection.createRange().text = '<span style="font-size:' + form_name + 'px">' + str + '</span>';
				else if(v == "color")
					document.selection.createRange().text = '<span style="color:#' + form_name + '">' + str + '</span>';
				else
					document.selection.createRange().text = '<'+v+'>' + str + '</'+v+'>';
			}
		}

			
	}
}

function insertLink(form_name)
{
	var modulo_name = selezionata;
	var txtInput="Inserisci indirizzo:";
	if(navigator.appName.indexOf("Microsoft") > -1)
	{
		if(document.selection)
		{
			var str = document.selection.createRange().text;
			if(str)
			{
				var my_link = prompt(txtInput, '');
				if (my_link != null)
					document.selection.createRange().text = '<$>' + str + "|" + my_link + '<$>';
			}
		}
	}
	else
	{
		var oldText = document.forms[form_name].elements[modulo_name].value;
		var my_link = prompt(txtInput, ''); 
		var newText = oldText.substring(0,document.forms[form_name].elements[modulo_name].selectionStart)+
		"<$>" + oldText.substring(document.forms[form_name].elements[modulo_name].selectionStart,document.forms[form_name].elements[modulo_name].selectionEnd)+
		"|" + my_link + "<$>" + oldText.substring(document.forms[form_name].elements[modulo_name].selectionEnd,oldText.length);
		document.forms[form_name].elements[modulo_name].value = newText;		
	}
}

var selezionata;
function selected_textarea(name_textarea) {
	selezionata=name_textarea;
}

function pulsantiera()
{
	document.write('<table align="center" border="0" cellspacing="0" cellpadding="0">');
	document.write('<tr><td align="left">');
	document.write('<input type="button" value="Grassetto" class="button" onmouseover="className=\'buttonon\'" onmouseout="className=\'button\'" onclick="formatStr(\'strong\', \'reg\')" style="width: 60px">');
	document.write('<input type="button" value="Corsivo" class="button" onmouseover="className=\'buttonon\'" onmouseout="className=\'button\'" onclick="formatStr(\'em\', \'reg\')" style="width: 60px">');
	document.write('<input type="button" value="Sottolinea" class="button" onmouseover="className=\'buttonon\'" onmouseout="className=\'button\'" onclick="formatStr(\'u\', \'reg\')" style="width: 60px">');
	//document.write('<br>')
	document.write('<input type="button" value="Rientro" class="button" onmouseover="className=\'buttonon\'" onmouseout="className=\'button\'" onclick="formatStr(\'blockquote\', \'reg\')" style="width: 60px">');
	document.write('<input type="button" value="Email" class="button" onmouseover="className=\'buttonon\'" onmouseout="className=\'button\'" onclick="formatStr(\'email\', \'reg\')" style="width: 60px">');
	document.write('<input type="button" value="Link" class="button" onmouseover="className=\'buttonon\'" onmouseout="className=\'button\'" onclick="formatStr(\'link\', \'reg\')" style="width: 60px">');
	document.write('<br>')
	document.write('Dimensioni&nbsp;&nbsp;')
	document.write('<select onChange="formatStr(\'size\', this.value)">')
		for(i=5;i<20;i++){
			document.write('<option value="' + i + '">' + i + '</option>')
		}
	document.write('</select>')
	/*
	document.write('&nbsp;&nbsp;Colore&nbsp;&nbsp;')
	document.write('<select onChange="formatStr(\'color\', this.value)">')
		document.write('<option style="background-color:#000000;color:#000000;" value="000000"<%IF RS(Campo) = "000000" THEN Response.Write(" selected")%>>Nero</option>')
		document.write('<option style="background-color:#660066;color:#660066;" value="660066"<%IF RS(Campo) = "660066" THEN Response.Write(" selected")%>>Viola scuro</option>')
		document.write('<option style="background-color:#990099;color:#990099;" value="990099"<%IF RS(Campo) = "990099" THEN Response.Write(" selected")%>>Viola</option>')
		document.write('<option style="background-color:#666666;color:#666666;" value="666666"<%IF RS(Campo) = "666666" THEN Response.Write(" selected")%>>Grigio scuro</option>')
		document.write('<option style="background-color:#CCCCCC;color:#CCCCCC;" value="CCCCCC"<%IF RS(Campo) = "CCCCCC" THEN Response.Write(" selected")%>>Grigio</option>')
		document.write('<option style="background-color:#EEEEEE;color:#EEEEEE;" value="EEEEEE"<%IF RS(Campo) = "EEEEEE" THEN Response.Write(" selected")%>>Grigio chiaro</option>')
		document.write('<option style="background-color:#FFFFFF;color:#FFFFFF;" value="FFFFFF"<%IF RS(Campo) = "FFFFFF" THEN Response.Write(" selected")%>>Bianco</option>')
		document.write('<option style="background-color:#C30000;color:#C30000;" value="C30000"<%IF RS(Campo) = "C30000" THEN Response.Write(" selected")%>>Rosso Scuro</option>')
		document.write('<option style="background-color:#FF0000;color:#FF0000;" value="FF0000"<%IF RS(Campo) = "FF0000" THEN Response.Write(" selected")%>>Rosso</option>')
		document.write('<option style="background-color:#FF6666;color:#FF6666;" value="FF6666"<%IF RS(Campo) = "FF6666" THEN Response.Write(" selected")%>>Rosso Chiaro</option>')
		document.write('<option style="background-color:#FF9900;color:#FF9900;" value="FF9900"<%IF RS(Campo) = "FF9900" THEN Response.Write(" selected")%>>Arancione</option>')
		document.write('<option style="background-color:#996633;color:#996633;" value="996633"<%IF RS(Campo) = "996633" THEN Response.Write(" selected")%>>Marrone</option>')
		document.write('<option style="background-color:#00FF00;color:#00FF00;" value="00FF00"<%IF RS(Campo) = "00FF00" THEN Response.Write(" selected")%>>Verde</option>')
		document.write('<option style="background-color:#009900;color:#009900;" value="009900"<%IF RS(Campo) = "009900" THEN Response.Write(" selected")%>>Verde Scuro</option>')
		document.write('<option style="background-color:#0000FF;color:#0000FF;" value="0000FF"<%IF RS(Campo) = "0000FF" THEN Response.Write(" selected")%>>Blu</option>')
		document.write('<option style="background-color:#000099;color:#000099;" value="000099"<%IF RS(Campo) = "000099" THEN Response.Write(" selected")%>>Blu Scuro</option>')
		document.write('<option style="background-color:#99FFFF;color:#99FFFF;" value="99FFFF"<%IF RS(Campo) = "99FFFF" THEN Response.Write(" selected")%>>Celeste</option>')
		document.write('<option style="background-color:#FFFF00;color:#FFFF00;" value="FFFF00"<%IF RS(Campo) = "FFFF00" THEN Response.Write(" selected")%>>Giallo</option>')
		document.write('<option style="background-color:#FFFF99;color:#FFFF99;" value="FFFF99"<%IF RS(Campo) = "FFFF99" THEN Response.Write(" selected")%>>Giallo Canarino</option>')
		document.write('<option style="background-color:#FF99FF;color:#FF99FF;" value="FF99FF"<%IF RS(Campo) = "FF99FF" THEN Response.Write(" selected")%>>Rosa</option>')
	document.write('</select>')
	*/
	document.write('</td></tr>');
	document.write('</table>');
	document.write('&nbsp;');
}
//'******************************************************************************************************
function segnaColore(id, colore)
{
	document.getElementById(id).value = colore;
}
//'******************************************************************************************************
//-->