

var bookmarkurl="http://www.elledihouse.it"
var bookmarktitle="EllediHouse"

function addbookmark(){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

// immagini piccole
function afficheVignette(cheminVignette,cheminMaxi)
	{
	document.write('<A HREF="javascript:afficheMaxi(\''+cheminMaxi+'\')"><IMG SRC="'+cheminVignette+'" HSPACE="10" VSPACE="10" BORDER="0" ALT="Clicca qui per ingrandire" class="bordimg"></A>');
	}
function afficheMaxi(chemin)
	{
	i1 = new Image;
	i1.src = chemin;
	html = '<HTML>\n<HEAD>\n<TITLE>Dettaglio immagine</TITLE>\n</HEAD>\n<BODY LEFTMARGIN="0" MARGINWIDTH="0" TOPMARGIN="0" MARGINHEIGHT="0">\n<a title="Fai click qui per chiudere questa finestra" href="#" onclick="window.close()"><IMG SRC="'+chemin+'" BORDER="0" NAME="imageTest" alt="Fai click qui per chiudere questa finestra" onLoad="window.resizeTo(document.imageTest.width+25,document.imageTest.height+55)"></a>\n</BODY>\n</HTML>';
	popupImage = window.open('','_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0');
	popupImage.document.open();
	popupImage.document.write(html);
	popupImage.document.close()
	};

	
function setCookie(name,value,expdays){   //memorizza il cookie
var now = new Date();
var exp = new Date(now.getTime() + (1000*60*60*24*expdays));
document.cookie = name + "=" + escape(value) + ";" + "expires=" + exp.toGMTString() + ";" + "path=/";
}

function getCookie(name){    //restituisce il cookie
var cname = name + "=";
var dc = document.cookie;
if (dc.length > 0) {
    var start = dc.indexOf(cname);
    if (start != -1) {
        start += cname.length;
        var stop = dc.indexOf(";", start);
        if (stop == -1) stop = dc.length;
        return unescape(dc.substring(start,stop));
        }
    }
return null;
}


//conferma eliminazione

function CheckDelete (url,mess)
{
  if (confirm(mess))
  {
   parent.location=url;
  }
  else
  {
    return ("#");
  }
}

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_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 avere un indirizzo di email valido, come: mariorossi@libero.it\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' deve contenere un numero.\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 contenere contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- Il campo "'+nm+'" è obbligatorio.\n'; }
  } if (errors) alert('Si sono verificati i seguenti errori:\n'+errors);
  document.MM_returnValue = (errors == '');
}

//apre la popup con i suggerimenti per inserire o modificare un prodotto
function suggerimenti(linkv) {
w = window.open(linkv,'Suggerimenti','height=400,width=350,scrollbars=yes,toolbar=no,menubar=no');
if (w.location.href.indexOf('suggerimenti.html')<0) w.location.href='suggerimenti.html'
w.focus(); 
}

//converte in minuscolo tutto il testo di una form
function  minuscolo(formv) {
formv.value=formv.value.toLowerCase();
	}


//calcola il prezzo scontato
function prezzoscontato() {
if (document.strumenti.prezzo_iniziale.value!="0,00" && document.strumenti.sconto.value!="0") {
var sconto=eval(document.strumenti.sconto.value.replace(',','.'));
var prezzoiniziale=eval(document.strumenti.prezzo_iniziale.value.replace(',','.'));
var finale=(prezzoiniziale-(prezzoiniziale*sconto/100));
finale=finale+''
finale=finale.replace('.',',');
document.strumenti.prezzo.value=finale;
	}
	}



/* trim e pulizia da caratteri non validi */
function Trim(stringa)
   {
   reTrim=/\s+$|^\s+/g;
   return stringa.replace(reTrim,"");
   }


/* verifica che siano inseriti solo numeri */
function verif_nombre(champ)
{
var chiffres = new RegExp("[0-9\.]"); 
var verif;
var points = 0; 

for(x = 0; x < champ.value.length; x++)
{
verif = chiffres.test(champ.value.charAt(x));
if(champ.value.charAt(x) == "."){points++;} 
if(points > 1){verif = false; points = 1;} 
if(verif == false){champ.value = champ.value.substr(0,x) + champ.value.substr(x+1,champ.value.length-x+1); x--;}
}

}

// controlla ordine per lo stato e il nuovo feedback
function controllaordine() {
if (document.getElementById('numero').value=="") {
	alert("Scrivi il tuo numero d'ordine\nEsempio: 000024");
	document.getElementById('numero').focus();
	return false;
	}
if (document.getElementById('gg').value=="") {
	alert("Seleziona il giorno in cui hai effettuato l'ordine dal nostro sito");
	document.getElementById('gg').focus();
	return false;
	}
if (document.getElementById('mm').value =="") {
	alert("Seleziona il mese in cui hai effettuato l'ordine dal nostro sito");
	document.getElementById('mm').focus();
	return false;
	}
if (document.getElementById('anno').value =="") {
	alert("Seleziona l'anno in cui hai effettuato l'ordine dal nostro sito");
	document.getElementById('anno').focus();
	return false;
	}
}