$(document).ready(function() { 
	$("ul#menu li a").removeClass("current");
	$("ul#menu li a[href='"+location.pathname+location.search+"']").addClass("current").attr("href","javascript:void(0);");
	$("ul#menu > li:last").addClass("last");
	$('ul#menu').superfish({ 
		delay: 100,//Ritardo
		animation: {opacity:0.95,height:'show'},
		autoArrows: false,// disabilito le frecce
		dropShadows: false,// disabilito l'ombreggiatura
		speed: "fast"
	});
	$('#slideshow-img').cycle({fx: 'fade'});	
	$('ul#menu').find("a").each(function(index){
		if($(this).html()=="Blog"){
			$(this).attr("href","javascript:void(0);");
		}
	});
});

function CallToAction(form){
	$("#"+form).expose({color:'#000'});
	$.scrollTo("#header",1000);
}

function getCookie(c_name) {
    if (document.cookie.length>0) {
        c_start=document.cookie.indexOf(c_name + "=");
        if (c_start!=-1) {
            c_start=c_start + c_name.length+1;
            c_end=document.cookie.indexOf(";",c_start);
        if (c_end==-1) c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
        }
    }
    return "";
}
function Invia(formName) {
	var email_exp = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    var validation = true;
	var privacy = document.forms[formName].Privacy.value;
	
	switch(formName){
		case "callback":
			var arrow = "arrow1";
			var btn_invia = "invia_callback";
			var tel = document.forms[formName].Telefono.value;
			if (tel == "") {
				validation = false;
				alert("Inserire il Numero di Telefono!");
				document.forms[formName].Telefono.focus();
				return false;
			}
			//var orario = document.forms[formName].Orario.value;
		break;
		
		case "contatta":
			var arrow = "arrow2";
			var btn_invia = "invia_contatta";
			var email = document.forms[formName].Email.value;
			var email2 = document.forms[formName].conferma_email.value;
			if (email.search(email_exp) == -1) {
				validation = false;
				alert("Inserire un\'indirizzo E-mail valido!");
				document.forms[formName].Email.focus();
				return false;
			} else {
				if(email != email2){
					alert("Conferma il tuo indirizzo E-mail!");
					document.forms[formName].conferma_email.focus();
					return false;
				}
			}
			var messaggio = document.forms[formName].Messaggio.value;
			if (messaggio == "" || messaggio == "Messaggio:") {
				validation = false;
				alert("Inserire un Messaggio!");
				document.forms[formName].Messaggio.focus();
				return false;
			}
		break;
	}
	if(document.forms[formName].Privacy.checked==false){
		validation = false;
		alert("Devi accettare i Termini della Privacy!");
		document.forms[formName].Privacy.focus();
		$("#"+arrow).parent().addClass("privacyred");
		$("#"+arrow).fadeIn("normal");
		return false;
	}
	
    if (validation == true) {
		try{$("a#"+btn_invia).css({opacity:0.4});
		$("a#"+btn_invia).attr("onlick", "");
		$("a#"+btn_invia).attr("ondblclick", "");}catch(e){}
		document.forms[formName]._utmz.value = getCookie('__utmz');
        document.forms[formName].submit();
        return true;
    } else {
        return false;
    }
}



function getWindowWidth() {
    if (window.innerWidth!=window.undefined) return window.innerWidth;
    if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth;
    if (document.body) return document.body.clientWidth;
    return window.undefined;
}

function getWindowHeight() {
    if (window.innerHeight!=window.undefined) return window.innerHeight;
    if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
    if (document.body) return document.body.clientHeight;
    return window.undefined;
}
    
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}
    
    
function getPageSize(){ 
    var xScroll, yScroll;
    
    if (window.innerHeight && window.scrollMaxY) {  
        xScroll = window.innerWidth + window.scrollMaxX;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    
    var windowWidth, windowHeight;
    if (self.innerHeight) { // all except Explorer
        if(document.documentElement.clientWidth){
            windowWidth = document.documentElement.clientWidth; 
        } else {
            windowWidth = self.innerWidth;
        }
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }   
    if(yScroll < windowHeight){
        pageHeight = windowHeight;
    } else { 
        pageHeight = yScroll;
    }
    if(xScroll < windowWidth){  
        pageWidth = xScroll;        
    } else {
        pageWidth = windowWidth;
    }
    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
    return arrayPageSize;
}

function getObjectSize(DOMelement){ 
    var objectWidth, objectHeight;
    if (DOMelement.innerHeight) {   // all except Explorer
        if(document.documentElement.clientWidth){
            objectWidth = DOMelement.clientWidth; 
        } else {
            objectWidth = DOMelement.innerWidth;
        }
        objectHeight = DOMelement.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        objectWidth = DOMelement.clientWidth;
        objectHeight = DOMelement.clientHeight;
    } else if (document.body) { // other Explorers
        objectWidth = DOMelement.clientWidth;
        objectHeight = DOMelement.clientHeight;
    }
    arrayPageSize = new Array(objectWidth,objectHeight) 
    return arrayPageSize;
}


function showSelectBoxes(){
    var selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
        selects[i].style.visibility = "visible";
    }
}

// ---------------------------------------------------

function hideSelectBoxes(){
    var selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
        selects[i].style.visibility = "hidden";
    }
}

function openPrivacy() {
    var objBody = document.getElementsByTagName('body').item(0);
        var objForm = document.getElementsByTagName('form').item(0);
        var objOverlay = document.getElementById('overlay');
        var objPopup = document.getElementById('testo_privacy');
        if(objOverlay == null) {
            var objOverlay = document.createElement('div');
            objOverlay.setAttribute('id','overlay');
            objBody.appendChild(objOverlay);
        }

        var arrayPageSize = getPageSize();
        //arrayPageSize[1] += 200;
        objOverlay.style.backgroundColor = "#000000"; 
        objOverlay.style.position = 'absolute';
        objOverlay.style.top = "0px";
        objOverlay.style.left = "0px";
        // objOverlay.style.zIndex = 80;
        objOverlay.style.opacity = "0.7";
        objOverlay.style.filter = 'alpha(opacity=80)';
        objOverlay.style.width = arrayPageSize[0] + "px";
        objOverlay.style.height = arrayPageSize[1] + "px";
        objOverlay.onclick = function() { closePopup('testo_privacy'); }
        
		nascondiObjects();
        showPopup('testo_privacy');
}

function nascondiObjects() {
    var Obj = document.body.getElementsByTagName("object");
    for(i=0;i<Obj.length;i++){
        Obj[i].style.visibility = 'hidden';
    }
}
function mostraObjects() {
    var Obj = document.body.getElementsByTagName("object");
    for(i=0;i<Obj.length;i++){
        Obj[i].style.visibility = 'visible';
    }
}
        
function closePopup(divName) {
    var objOverlay = document.getElementById('overlay');
    try{var objPopup = document.getElementById('testo_privacy');
    objOverlay.style.visibility = 'hidden';
    objOverlay.style.zIndex = -1;
    objPopup.style.visibility = 'hidden';
    objPopup.style.display = 'none';
    objPopup.style.zIndex = -1;
	}catch(e){}
	try{var objPopup = document.getElementById('popup');
    objOverlay.style.visibility = 'hidden';
    objOverlay.style.zIndex = -1;
    objPopup.style.visibility = 'hidden';
    objPopup.style.display = 'none';
    objPopup.style.zIndex = -1;
	}catch(e){}
    // showSelectBoxes();
    mostraObjects();
}

var AcceptMessage=true;

if(document.implementation && document.implementation.createDocument) var isMozilla=true;
    else var isMozilla=false;

function showPopup(divName){    
    var objOverlay = document.getElementById('overlay');
    var popupDiv = document.getElementById(divName);
    objOverlay.onclick = function() { closePopup(divName); }
    objOverlay.style.zIndex = 99998;
    objOverlay.style.visibility = "visible";
    popupDiv.style.visibility = "hidden";
    popupDiv.style.display = "block";
    popupDiv.style.zIndex = 99999;
    var scrollTop = getScrollXY()[1];
    var objSize = getObjectSize(popupDiv);
    var popupPositionTop = Math.round(scrollTop + getWindowHeight()/2 - parseInt(objSize[1])/2);
    var popupPositionLeft = Math.round(getWindowWidth()/2 - parseInt(objSize[0])/2);
    popupDiv.style.top  = (popupPositionTop) + "px";
    popupDiv.style.left = popupPositionLeft + "px";
    popupDiv.style.visibility = "visible";
}

function stripSlashes(content) {
    // Strip Slashes
    re = /\\\"/gi;
    content = content.replace(re, '"');
    re = /\\\'/gi;
    content = content.replace(re, "'");
    return content;
}

function openPopup(citta) {
    var objBody = document.getElementsByTagName('body').item(0);
        var objForm = document.getElementsByTagName('form').item(0);
        var objOverlay = document.getElementById('overlay');
        var objPopup = document.getElementById('popup');
        if(objOverlay == null) {
            var objOverlay = document.createElement('div');
            objOverlay.setAttribute('id','overlay');
            objBody.appendChild(objOverlay);
        }

        var arrayPageSize = getPageSize();
        //arrayPageSize[1] += 200;
        objOverlay.style.backgroundColor = "#000000"; 
        objOverlay.style.position = 'absolute';
        objOverlay.style.top = "0px";
        objOverlay.style.left = "0px";
        // objOverlay.style.zIndex = 80;
        objOverlay.style.opacity = "0.7";
        objOverlay.style.filter = 'alpha(opacity=80)';
        objOverlay.style.width = arrayPageSize[0] + "px";
        objOverlay.style.height = arrayPageSize[1] + "px";
        objOverlay.onclick = function() { closePopup('popup'); }
        
		nascondiObjects();
        $("#popup > .indent > h3 > span").html(Mappe[citta][0]);
		$("#popup > .indent > #Gmap").html(iFrameCode+Mappe[citta][1]+'"></iframe>');
        showPopup('popup');
}


var Mappe = new Array();
//Aggiungere qui le città
//Titoli e Query string MAP (depurata del codice iframe - solo SRC)
var iFrameCode = '<iframe width="650" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="';

Mappe['bari'] = new Array('Bari','http://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=it&amp;geocode=&amp;q=implantologia+dentale+bari&amp;aq=&amp;sll=41.106002,16.887016&amp;sspn=0.0119,0.026007&amp;ie=UTF8&amp;hq=implantologia+dentale&amp;hnear=Bari,+Puglia&amp;cid=4721555169146033884&amp;ll=41.120159,16.886845&amp;spn=0.045263,0.11158&amp;z=13&amp;iwloc=A&amp;output=embed');
Mappe['bologna'] = new Array('Bologna','http://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=it&amp;geocode=&amp;q=Piazza+dei+Martiri+1+-+40121+BOLOGNA&amp;aq=&amp;sll=41.126177,16.863499&amp;sspn=0.091937,0.208054&amp;ie=UTF8&amp;hq=&amp;hnear=Piazza+dei+Martiri+1943-1945,+1,+40121+Bologna,+Emilia+Romagna&amp;ll=44.510444,11.341753&amp;spn=0.021426,0.05579&amp;z=14&amp;iwloc=A&amp;output=embed');
Mappe['cagliari'] = new Array('Cagliari','http://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=it&amp;geocode=&amp;q=studio+implantologia+dentaria+cagliari&amp;aq=&amp;sll=44.503285,11.343555&amp;sspn=0.011264,0.026007&amp;ie=UTF8&amp;hq=studio+implantologia+dentaria&amp;hnear=Cagliari,+Sardegna&amp;cid=15439766771609579250&amp;ll=39.235178,9.126549&amp;spn=0.023268,0.05579&amp;z=14&amp;iwloc=A&amp;output=embed');
Mappe['carrara'] = new Array('Massa-Carrara','http://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=it&amp;geocode=&amp;q=Via+Piave,+22+%E2%80%93+54033++massa+CARRARA&amp;aq=&amp;sll=39.22597,9.123759&amp;sspn=0.023637,0.052013&amp;ie=UTF8&amp;hq=&amp;hnear=Via+Piave,+22,+54033+Carrara+Massa-Carrara,+Toscana&amp;ll=44.072109,10.082445&amp;spn=0.021583,0.05579&amp;z=14&amp;iwloc=A&amp;output=embed');
Mappe['firenze'] = new Array('Firenze','http://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=it&amp;geocode=&amp;q=Via+Giuseppe+Montanelli+3+%E2%80%93+50129+FIRENZE&amp;aq=&amp;sll=44.063367,10.078111&amp;sspn=0.011348,0.026007&amp;ie=UTF8&amp;hq=&amp;hnear=Via+Giuseppe+Montanelli,+2,+50129+Firenze,+Toscana&amp;ll=43.785977,11.250992&amp;spn=0.021685,0.05579&amp;z=14&amp;iwloc=A&amp;output=embed');
Mappe['genova'] = new Array('Genova','http://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=it&amp;geocode=&amp;q=Via+Pammatone+5+%E2%80%93+16121+GENOVA&amp;aq=&amp;sll=43.784292,11.240508&amp;sspn=0.011402,0.026007&amp;ie=UTF8&amp;hq=&amp;hnear=Via+Pammatone,+16121+Genova,+Liguria&amp;ll=44.413245,8.937292&amp;spn=0.021458,0.05579&amp;z=14&amp;iwloc=A&amp;output=embed');
Mappe['milano'] = new Array('Milano','http://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=it&amp;geocode=&amp;q=Piazza+Napoli+38+%E2%80%93+20146+MILANO&amp;aq=&amp;sll=44.408193,8.938204&amp;sspn=0.011282,0.026007&amp;ie=UTF8&amp;hq=&amp;hnear=Piazza+Napoli,+38,+20146+Milano,+Lombardia&amp;ll=45.45989,9.155817&amp;spn=0.021071,0.05579&amp;z=14&amp;iwloc=A&amp;output=embed');
Mappe['napoli'] = new Array('Napoli','http://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=it&amp;geocode=&amp;q=Via+Servio+Tullio+101+%E2%80%93+80126+NAPOLI&amp;aq=&amp;sll=45.452491,9.15287&amp;sspn=0.011079,0.026007&amp;ie=UTF8&amp;hq=&amp;hnear=Via+Servio+Tullio,+101,+80126+Napoli,+Campania&amp;ll=40.853488,14.201374&amp;spn=0.022722,0.05579&amp;z=14&amp;iwloc=A&amp;output=embed');
Mappe['padova'] = new Array('Padova','http://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=it&amp;geocode=&amp;q=Via+Alessandro+Tassoni+13,++35125+Padova+PD&amp;aq=&amp;sll=40.845508,14.199136&amp;sspn=0.011947,0.026007&amp;ie=UTF8&amp;hq=&amp;hnear=Via+Alessandro+Tassoni,+13,+35125+Padova,+Veneto&amp;ll=45.388324,11.867809&amp;spn=0.021098,0.05579&amp;z=14&amp;iwloc=A&amp;output=embed');
Mappe['palermo'] = new Array('Palermo','http://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=it&amp;geocode=&amp;q=Via+Galileo+Galilei+161+D+-+90145+PALERMO&amp;aq=&amp;sll=45.380721,11.867332&amp;sspn=0.011093,0.026007&amp;ie=UTF8&amp;hq=&amp;hnear=Via+Galileo+Galilei,+161,+90145+Palermo,+Sicilia&amp;ll=38.145425,13.335085&amp;spn=0.023625,0.05579&amp;z=14&amp;iwloc=A&amp;output=embed');
Mappe['pisa'] = new Array('Pisa','http://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=it&amp;geocode=&amp;q=Montopoli+val+d%E2%80%99Arno+(PISA)&amp;aq=&amp;sll=43.591366,10.866352&amp;sspn=1.464085,3.328857&amp;ie=UTF8&amp;hq=&amp;hnear=Montopoli+In+Val+Arno+Pisa,+Toscana&amp;ll=43.690598,10.74292&amp;spn=0.043444,0.11158&amp;z=13&amp;iwloc=A&amp;output=embed');
Mappe['roma'] = new Array('Roma','http://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=it&amp;geocode=&amp;q=Via+Emilio+De+Marchi+21+-+00141+ROMA&amp;aq=&amp;sll=43.674761,10.745318&amp;sspn=0.09138,0.208054&amp;ie=UTF8&amp;hq=&amp;hnear=Via+Emilio+De+Marchi,+21,+00141+Roma,+Lazio&amp;ll=41.946851,12.546215&amp;spn=0.022343,0.05579&amp;z=14&amp;iwloc=A&amp;output=embed');
Mappe['roma2'] = new Array('Roma2','http://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=it&amp;geocode=&amp;q=Via+Flavio+Stilicone+210,+00175+ROMA&amp;aq=&amp;sll=43.674761,10.745318&amp;sspn=0.09138,0.208054&amp;ie=UTF8&amp;hq=&amp;hnear=Via+Flavio+Stilicone+210,+00175+Roma,+Lazio&amp;ll=41.86984,12.55994&amp;spn=0.022343,0.05579&amp;z=14&amp;iwloc=A&amp;output=embed');
Mappe['torino'] = new Array('Torino','http://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=it&amp;geocode=&amp;q=Corso+Filippo+Turati+10+bis+%E2%80%93+10128+TORINO&amp;aq=&amp;sll=41.93848,12.542502&amp;sspn=0.011748,0.026007&amp;ie=UTF8&amp;hq=&amp;hnear=Corso+Filippo+Turati,+10,+10128+Torino,+Piemonte&amp;ll=45.0617,7.674122&amp;spn=0.021219,0.05579&amp;z=14&amp;iwloc=A&amp;output=embed');

