

var bookmarkurl="http://www.staebari.it"
var bookmarktitle="Servizio Tecnico Assistenza Elettrodomestici"

function addbookmark(){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}


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;
}


// immagini piccole
function afficheVignette(cheminVignette,cheminMaxi)
	{
	document.write('<A HREF="javascript:afficheMaxi(\''+cheminMaxi+'\')"><img src="'+cheminVignette+'" hspace="10" vspace="10" alt="Clicca qui per ingrandire" class="bordonero"></A>');
	}
function afficheMaxi(chemin)
	{
	i1 = new Image;
	i1.src = chemin;
	html = '<HTML>\n<HEAD>\n<TITLE>Dettaglio immagine</TITLE>\n<script language="JavaScript1.2" src="script/daniele.js"></script>\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+'" class="bordonero" 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()
	};

	


// Invio e-mail x info prodotti
function infoprodotto(nome) {
 location.href = "mailto:info@staebari.it?Subject=Domanda su " + nome + ""; 
return 
}

//conferma eliminazione
function CheckDelete (url,mess)
{
  if (confirm(mess))
  {
   parent.location=url;
  }
  else
  {
    return ("#topic");
  }
}


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 && getElementById) x=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);
  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.getElementById('scontato').checked) {
		if(document.getElementById('scontato').checked==true) {
if (document.getElementById("prezzo_iniziale").value!="0,00" && document.getElementById("sconto").value!="0") {
	
var sconto=eval(document.getElementById("sconto").value.replace(',','.'));
var prezzoiniziale=eval(document.getElementById("prezzo_iniziale").value.replace(',','.'));
var finale=(prezzoiniziale-(prezzoiniziale*sconto/100));
finale=finale+'';
finale=finale.replace('.',',');
document.getElementById("prezzo").value=finale;
	}
	}
	}
	}
	

/* 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--;}
}
}

//apre la popup con i suggerimenti per inserire o modificare un prodotto
function codici(linkv) {
w = window.open(linkv,'Codici','height=360,width=650,scrollbars=yes,toolbar=no,menubar=no');
if (w.location.href.indexOf(linkv)<0) w.location.href=linkv
w.focus(); 
}