//ferro di cavallo palermo

function MM_swapImgRestore() {
  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 MM_findObj(n, d) {
  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 && document.getElementById) x=document.getElementById(n); return x;
}
//
function MM_swapImage() {
  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 yodaNum(objName){
 if(isNaN(objName.value)){
  alert("E' consentito inserire soltanto valori numerici.");
  objName.value="";
  objName.focus();
 }
}
// validazione email 
var emailverify = /^([0-9,a-z]+)([.,_,-]([0-9,a-z,A-Z]+))*@([a-z0-9]+)([.,_,-]([0-9,a-z,A-Z]+))*\.[a-z]{2,4}$/i 
//
function correct_email(str) {
        return emailverify.test(str) 
} 
//
function validateEmail(nomeForm) {
	var myform;
		myform = document[nomeForm];
		if(!correct_email(myform.email.value)) { 
		alert("Inserire un indirizzo e-mail corretto.") 
		myform.email.focus() 
		myform.email.select() 
		myform.email.className = "boxHigh";
		return false; 
	} else { 
		myform.email.className = "boxForm"; 
	}
   return true 
} 
//
function eraseFormCliente() {
	myform = document.formCliente;	
	myform.reset();
	myform.nome.className = "boxForm";
	myform.cognome.className = "boxForm";
	myform.indirizzo.className = "boxForm";
	myform.cap.className = "boxForm";
	myform.citta.className = "boxForm";
	myform.provincia.className = "boxForm";
	myform.email.className = "boxForm";
	myform.confermaEmail.className = "boxForm";
	return true;
}
//
function checkFormSouvenir(nomeFormo){
var myform;
	myform = document[nomeFormo];
		if (myform.quantita.selectedIndex=="0") { 
            alert("Specificare la quantità.");
            myform.quantita.focus() 
            myform.quantita.className = "boxHigh";
             return false; 
         } else { 
              myform.quantita.className = "boxForm"; 
        }
		if (myform.taglia.selectedIndex=="0") { 
            alert("Specificare la taglia.");
            myform.taglia.focus() 
            myform.taglia.className = "boxHigh";
             return false; 
         } else { 
              myform.taglia.className = "boxForm"; 
        }
		if (myform.colore.selectedIndex=="0") { 
            alert("Specificare il colore.");
            myform.colore.focus() 
            myform.colore.className = "boxHigh";
             return false; 
         } else { 
              myform.colore.className = "boxForm"; 
        }
		if (myform.maniche.selectedIndex=="0") { 
            alert("Specificare la lunghezza delle maniche.");
            myform.maniche.focus() 
            myform.maniche.className = "boxHigh";
             return false; 
         } else { 
              myform.maniche.className = "boxForm"; 
        }
		if (myform.modello.selectedIndex=="0") { 
            alert("Specificare il modello.");
            myform.modello.focus() 
            myform.modello.className = "boxHigh";
             return false; 
         } else { 
              myform.modello.className = "boxForm"; 
        }
	myform.submit();
}
//
function checkFormCliente(){
var myform;
    myform = document.formCliente;
        if (myform.nome.value=="") { 
            alert("Inserire il nome.");
            myform.nome.focus() 
            myform.nome.select()
            myform.nome.className = "boxHigh";
             return false; 
         } else { 
              myform.nome.className = "boxForm"; 
        }
        if (myform.cognome.value=="") { 
            alert("Inserire il cognome.");
            myform.cognome.focus() 
            myform.cognome.select()
            myform.cognome.className = "boxHigh";
             return false; 
         } else { 
              myform.cognome.className = "boxForm"; 
        }
        if (myform.indirizzo.value=="") { 
            alert("Indicare l'indirizzo.");
            myform.indirizzo.focus() 
            myform.indirizzo.select()
            myform.indirizzo.className = "boxHigh";
             return false; 
         } else { 
              myform.indirizzo.className = "boxForm"; 
        }
        if (myform.cap.value=="") { 
            alert("Indicare il CAP.");
            myform.cap.focus() 
            myform.cap.select()
            myform.cap.className = "boxHigh";
             return false; 
         } else {
             if (myform.cap.value.length<5) {
                alert("CAP non corretto.");
                myform.cap.focus() 
                 myform.cap.select() 
                myform.cap.className = "boxHigh";
                return false;
            } else {
                 myform.cap.className = "boxForm";
            }
        }
        if (myform.citta.value=="") { 
            alert("Indicare la città.");
            myform.citta.focus() 
            myform.citta.select()
            myform.citta.className = "boxHigh";
             return false; 
         } else { 
              myform.citta.className = "boxForm"; 
        }
        if (myform.provincia.selectedIndex=="0") { 
            alert("Indicare la provincia.");
            myform.provincia.focus() 
            myform.provincia.className = "boxHigh";
             return false; 
         } else { 
              myform.provincia.className = "boxForm"; 
        }
        if (myform.email.value=="") { 
            alert("Fornire un indirizzo e-Mail valido.");
            myform.email.focus() 
            myform.email.select()
            myform.email.className = "boxHigh";
             return false; 
         } else { 
              myform.email.className = "boxForm"; 
        }
        if (!validateEmail("formCliente")) { 
            return false; 
        }
        if (myform.confermaEmail.value=="") { 
            alert("Digitare nuovamente l'e-Mail per conferma.");
            myform.confermaEmail.focus() 
            myform.confermaEmail.select()
            myform.confermaEmail.className = "boxHigh";
             return false; 
         } else { 
              myform.confermaEmail.className = "boxForm"; 
        }
        if (myform.confermaEmail.value!=myform.email.value) { 
            alert("e-Mail non corrispondenti.");
            myform.email.className = "boxHigh";
            myform.confermaEmail.focus() 
            myform.confermaEmail.select()
            myform.confermaEmail.className = "boxHigh";
             return false; 
         } else {
            myform.email.className = "boxForm";
              myform.confermaEmail.className = "boxForm"; 
        }
        if (!myform.privacy.checked){
            alert("Attenzione.\nL'autorizzazione al trattamento dei dati è obbligatoria.");
            myform.privacy.select() 
            return false;
        }
    myform.submit();
}
//
function eraseFormInfo() {
	myform = document.formInfo;	
	myform.reset();
	myform.nome.className = "boxForm";
	myform.cognome.className = "boxForm";
	myform.email.className = "boxForm";
	myform.confermaEmail.className = "boxForm";
	myform.informazione.className = "boxForm";
	myform.messaggio.className = "boxForm";
	return true;
}
//
function checkFormInfo(){
var myform;
    myform = document.formInfo;
        if (myform.nome.value=="") { 
            alert("Inserire il nome.");
            myform.nome.focus() 
            myform.nome.select()
            myform.nome.className = "boxHigh";
             return false; 
         } else { 
              myform.nome.className = "boxForm"; 
        }
        if (myform.cognome.value=="") { 
            alert("Inserire il cognome.");
            myform.cognome.focus() 
            myform.cognome.select()
            myform.cognome.className = "boxHigh";
             return false; 
         } else { 
              myform.cognome.className = "boxForm"; 
        }
        if (myform.email.value=="") { 
            alert("Fornire un indirizzo e-Mail valido.");
            myform.email.focus() 
            myform.email.select()
            myform.email.className = "boxHigh";
             return false; 
         } else { 
              myform.email.className = "boxForm"; 
        }
        if (!validateEmail("formInfo")) { 
            return false; 
        }
        if (myform.confermaEmail.value=="") { 
            alert("Digitare nuovamente l'e-Mail per conferma.");
            myform.confermaEmail.focus() 
            myform.confermaEmail.select()
            myform.confermaEmail.className = "boxHigh";
             return false; 
         } else { 
              myform.confermaEmail.className = "boxForm"; 
        }
        if (myform.confermaEmail.value!=myform.email.value) { 
            alert("e-Mail non corrispondenti.");
            myform.email.className = "boxHigh";
            myform.confermaEmail.focus() 
            myform.confermaEmail.select()
            myform.confermaEmail.className = "boxHigh";
             return false; 
         } else {
            myform.email.className = "boxForm";
              myform.confermaEmail.className = "boxForm"; 
        }
        if (myform.informazione.selectedIndex=="0") { 
            alert("Specificare il tipo di informazione richiesta.");
            myform.informazione.focus() 
            myform.informazione.className = "boxHigh";
             return false; 
         } else { 
              myform.informazione.className = "boxForm"; 
        }
        if (myform.messaggio.value=="") { 
            alert("Inserire un messaggio/richiesta informazioni.");
            myform.messaggio.focus() 
            myform.messaggio.select()
            myform.messaggio.className = "boxHigh";
             return false; 
         } else { 
              myform.messaggio.className = "boxForm"; 
        }
        if (!myform.privacy.checked){
            alert("Attenzione.\nL'autorizzazione al trattamento dei dati e' obbligatoria.");
            myform.privacy.select() 
            return false;
        }
    myform.submit();
}
//
var qTipTag = "a"; //Which tag do you want to qTip-ize? Keep it lowercase!//
var qTipX = 15; //This is qTip's X offset//
var qTipY = 5; //This is qTip's Y offset//
var pageCounter = 0;
//There's No need to edit anything below this line//
tooltip = {
 name : "qTip",
 offsetX : qTipX,
 offsetY : qTipY,
 tip : null
}

tooltip.init = function () {
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
	if(!tipContainerID){ var tipContainerID = "qTip";}
	var tipContainer = document.getElementById(tipContainerID);

	if(!tipContainer) {
	 tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
		tipContainer.setAttribute("id", tipContainerID);
	 document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	}

	if (!document.getElementById) return;
	this.tip = document.getElementById (this.name);
	if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)};

	var a, sTitle;
	var anchors = document.getElementsByTagName (qTipTag);

	for (var i = 0; i < anchors.length; i ++) {
		a = anchors[i];
		sTitle = a.getAttribute("title");
		if(sTitle) {
			a.setAttribute("tiptitle", sTitle);
			a.removeAttribute("title");
			a.onmouseover = function() {tooltip.show(this.getAttribute('tiptitle'))};
			a.onmouseout = function() {tooltip.hide()};
		}
	}
}

tooltip.move = function (evt) {
	var x=0, y=0;
	if (document.all) {//IE
		x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		x += window.event.clientX;
		y += window.event.clientY;
		
	} else {//Good Browsers
		x = evt.pageX;
		y = evt.pageY;
	}
	this.tip.style.left = (x + this.offsetX) + "px";
	this.tip.style.top = (y + this.offsetY) + "px";
}

tooltip.show = function (text) {
	if (!this.tip) return;
	this.tip.innerHTML = text;
	this.tip.style.display = "block";
}

tooltip.hide = function () {
	if (!this.tip) return;
	this.tip.innerHTML = "";
	this.tip.style.display = "none";
}

window.onload = function () {
	tooltip.init ();
}
//
var ss = {
  fixAllLinks: function() {
    // Get a list of all links in the page
    var allLinks = document.getElementsByTagName('a');
    // Walk through the list
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if ((lnk.href && lnk.href.indexOf('#') != -1) && 
          ( (lnk.pathname == location.pathname) ||
	    ('/'+lnk.pathname == location.pathname) ) && 
          (lnk.search == location.search)) {
        // If the link is internal to the page (begins in #)
        // then attach the smoothScroll function as an onclick
        // event handler
        ss.addEvent(lnk,'click',ss.smoothScroll);
      }
    }
  },

  smoothScroll: function(e) {
    // This is an event handler; get the clicked on element,
    // in a cross-browser fashion
    if (window.event) {
      target = window.event.srcElement;
    } else if (e) {
      target = e.target;
    } else return;

    // Make sure that the target is an element, not a text node
    // within an element
    if (target.nodeName.toLowerCase() != 'a') {
      target = target.parentNode;
    }
  
    // Paranoia; check this is an A tag
    if (target.nodeName.toLowerCase() != 'a') return;
  
    // Find the <a name> tag corresponding to this href
    // First strip off the hash (first character)
    anchor = target.hash.substr(1);
    // Now loop all A tags until we find one with that name
    var allLinks = document.getElementsByTagName('a');
    var destinationLink = null;
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if (lnk.name && (lnk.name == anchor)) {
        destinationLink = lnk;
        break;
      }
    }
  
    // If we didn't find a destination, give up and let the browser do
    // its thing
    if (!destinationLink) return true;
  
    // Find the destination's position
    var destx = destinationLink.offsetLeft; 
    var desty = destinationLink.offsetTop;
    var thisNode = destinationLink;
    while (thisNode.offsetParent && 
          (thisNode.offsetParent != document.body)) {
      thisNode = thisNode.offsetParent;
      destx += thisNode.offsetLeft;
      desty += thisNode.offsetTop;
    }
  
    // Stop any current scrolling
    clearInterval(ss.INTERVAL);
  
    cypos = ss.getCurrentYPos();
  
    ss_stepsize = parseInt((desty-cypos)/ss.STEPS);
    ss.INTERVAL =
setInterval('ss.scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10);
  
    // And stop the actual click happening
    if (window.event) {
      window.event.cancelBubble = true;
      window.event.returnValue = false;
    }
    if (e && e.preventDefault && e.stopPropagation) {
      e.preventDefault();
      e.stopPropagation();
    }
  },

  scrollWindow: function(scramount,dest,anchor) {
    wascypos = ss.getCurrentYPos();
    isAbove = (wascypos < dest);
    window.scrollTo(0,wascypos + scramount);
    iscypos = ss.getCurrentYPos();
    isAboveNow = (iscypos < dest);
    if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
      // if we've just scrolled past the destination, or
      // we haven't moved from the last scroll (i.e., we're at the
      // bottom of the page) then scroll exactly to the link
      window.scrollTo(0,dest);
      // cancel the repeating timer
      clearInterval(ss.INTERVAL);
      // and jump to the link directly so the URL's right
      location.hash = anchor;
    }
  },

  getCurrentYPos: function() {
    if (document.body && document.body.scrollTop)
      return document.body.scrollTop;
    if (document.documentElement && document.documentElement.scrollTop)
      return document.documentElement.scrollTop;
    if (window.pageYOffset)
      return window.pageYOffset;
    return 0;
  },

  addEvent: function(elm, evType, fn, useCapture) {
    // addEvent and removeEvent
    // cross-browser event handling for IE5+,  NS6 and Mozilla
    // By Scott Andrew
    if (elm.addEventListener){
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent){
      var r = elm.attachEvent("on"+evType, fn);
      return r;
    } else {
      alert("Handler could not be removed");
    }
  } 
}

ss.STEPS = 25;

ss.addEvent(window,"load",ss.fixAllLinks);
//
function counterUp(){
	pageCounter = pageCounter+1;
//	alert(pageCounter);
}
//
function pagePrev(){
	if (pageCounter!=0) {
		history.go(-2);
	} else {
		history.back();
	}
}