<!-- // v.1
// variabili base
var nome = navigator.appName;
var generazione = navigator.appVersion;
var piattaforma = navigator.platform;
var browser = navigator.userAgent;
var ie = (nome.indexOf('Microsoft') > -1 );
var ie_array_versione = generazione.split('MSIE');
var ie_versione = parseFloat(ie_array_versione[1]);
var activex = ( !window.ActiveXObject > -1 );
var xmlhttp = ( !window.XMLHttpRequest > -1 );
var lingua = navigator.language;
var cookie = navigator.cookieEnabled;
var js = navigator.javaEnabled();
var ajax;
var ajax_attivo = true;
var nf;
var dom = (( !document.getElementById && !document.getElementsByTagName ) > -1 );
var url = location.href;
var title = document.title;
var referer = document.referrer;
var encode_url = encodeURIComponent(location.href);
var encode_title = encodeURIComponent(document.title);
var encode_referer = encodeURIComponent(document.referrer);
var data = new Date();
var info_testo;

// Funzione gestione ajax - creata 14/03/2010
function ajax_browser() {
	var ajax_oggetto;
	if (xmlhttp) {
		try {
			ajax_oggetto = new XMLHttpRequest();
			return ajax_oggetto;
		} catch(e) {
			if (ie && activex && (ie_versione < 7)) {
				try {
					ajax_oggetto = new ActiveXObject('Msxml2.XMLHTTP');
					return ajax_oggetto;
				} catch(e) {
					try {
						ajax_oggetto = new ActiveXObject('Microsoft.XMLHTTP');
						return ajax_oggetto;
					} catch(e) {
						ajax_attivo = false;
					}
				}
			} else {
				ajax_attivo = false;
			}
		}
	} else {
		ajax_attivo = false;
	}
	if (!ajax_attivo) {
		alert('Se leggi questo messaggio molto probabilmente il tuo browser è troppo obsoleto, aggiornalo e torna a trovarci.');
	}
}

// Funzione status skype - creata 10/02/2011
function status_skype_richiesta() {
	ajax = ajax_browser();
	if (ajax_attivo && dom) {
		var div = document.getElementById('status-ajax');
		var url = 'status_skype.aspx';
		ajax.open('post', url, true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState == 4) {
				if (ajax.responseText != '' && ajax.status == 200) {
					if (ajax.responseText == '0'){ div.innerHTML = 'Ignoto'; }
					if (ajax.responseText == '1'){ div.innerHTML = 'Non in linea'; }
					if (ajax.responseText == '2'){ div.innerHTML = 'Staff in linea'; }
					if (ajax.responseText == '3'){ div.innerHTML = 'Staff assente'; }
					if (ajax.responseText == '4'){ div.innerHTML = 'Staff non disponibile'; }
					if (ajax.responseText == '5'){ div.innerHTML = 'Staff occupato'; }
					if (ajax.responseText == '6'){ div.innerHTML = 'Staff non in linea'; }
					if (ajax.responseText == '7'){ div.innerHTML = 'Chiamami'; }
				}
			}
		}
		ajax.setRequestHeader('content-type', 'application/x-www-form-urlencoded; charset=iso-8859-1');
		ajax.setRequestHeader('connection', 'close');
		ajax.send(null);
	}
}

// Funzione gestione errori client - creata 01/03/2011
function modulo_change(id) {
	if (dom) {
		var campo = document.getElementById(id);var txt = document.getElementById('errore-'+id);switch(id) { case 'email': if (campo.value == '') txt.innerText = 'Devi inserire l\'Email.'; else txt.innerText = '';break;case 'nome_ragione_sociale': if (campo.value == '') txt.innerText = 'Devi inserire almeno un nome identificativo.'; else txt.innerText = '';break;case 'messaggio': if (campo.value == '') txt.innerText = 'Devi inserire un Messaggio.'; else txt.innerText = '';break;case 'captcha':	if (campo.value == '') txt.innerText = 'Devi inserire il codice Captcha.'; else txt.innerText = '';break; }
	}
}

// Funzione gestione div - creata 10/01/2011 - 10/02/2011
function gestione_div(id) {
	if (dom) {
		if (document.getElementById(id).style.display == 'none' || document.getElementById(id).style.display == '') { document.getElementById(id).style.display = 'block'; } else { document.getElementById(id).style.display = 'none'; }
	}
}

// Funzioni homepage e preferiti - 14/03/2010 - 27/02/2011

function imposta_homepage() {
	if (document.all) {document.body.style.behavior='url(#default#homepage)';document.body.setHomePage('http://www.studiopubblicita.it/');} else {alert('Utilizza il menù Strumenti -> Opzioni del tuo browser per impostare manualmente Studio Pubblicita come Home Page');}
}

function aggiungi_preferiti() {
	if (window.sidebar) {window.sidebar.addPanel('Tipografia on line Studio Pubblicita', 'http://www.studiopubblicita.it/', '');} else if(document.all) {window.external.AddFavorite('http://www.studiopubblicita.it/', 'Tipografia on line Studio Pubblicita');} else {alert('Premi Ctrl+D per aggiungere ai preferiti (Command+D per Mac)');}
}

// Funzione gestione header utility - creata 19/02/2011
function header_utility() {
	if (dom) {
		document.write('<div id=\"header-utility\"><ul><li><img src=\"images/icon_home.png\" alt=\"Imposta come Homepage\" id=\"icon_home\" class=\"header-utility-icon\" onmouseover=\"javascript:opacita(this.id, 0)\" onmouseout=\"javascript:opacita(this.id, 1)\" onclick=\"javascript:imposta_homepage();\" /></li><li><img src=\"images/icon_bookmark.png\" alt=\"Aggiungi ai preferiti\" id=\"icon_bookmark\" class=\"header-utility-icon\" onmouseover=\"javascript:opacita(this.id, 0)\" onmouseout=\"javascript:opacita(this.id, 1)\" onclick=\"javascript:aggiungi_preferiti();\" /></li><li><img src=\"images/icon_skype.png\" alt=\"Chiamami con Skype\" id=\"icon_skype\" onclick=\"javascript:location.href=\'skype:studiopubblicitamontebelluna?call\';\" /></li></ul><div id=\"status-ajax\"></div></div>');
	}
}

// Funzione opacita - creata 11/02/2011
function opacita(id, direzione) {
	if (dom) {
		if (direzione == 0) {document.getElementById(id).style.opacity = 1.0;document.getElementById(id).style.filter = 'alpha(opacity=100)';} else if (direzione == 1) {document.getElementById(id).style.opacity = 0.4;document.getElementById(id).style.filter = 'alpha(opacity=40)';}
	}
}

// funzione aumenta testo - 22/02/2011
function aumenta_testo(id) {
	if (dom) {
		var p = document.getElementById('descrizione').style;switch(id){case 0:p.fontSize='13px';p.lineHeight='17px';break;case 1:p.fontSize='14px';p.lineHeight='18px';break;case 2:p.fontSize='16px';p.lineHeight='20px';break;}
	}
}

// funzione galleria - 24/01/2011 - 01/04/2011
var galleria_attiva = false;
function Galleria() {
	if (dom) {
		galleria_attiva = true;var body = document.getElementsByTagName('body')[0];var ul = document.getElementById('foto-gallery-scorrimento');var li = ul.getElementsByTagName('li');var opacita = document.createElement('div');opacita.id = 'opacita';var galleria = document.createElement('div');galleria.id = 'galleria';var galleria_img = document.createElement('img');galleria.appendChild(galleria_img);var controlli = document.createElement('div');controlli.id = 'galleria-controlli';var img_chiudi = document.createElement('img');img_chiudi.src = '/images/galleria_chiudi.png';if (ie) {img_chiudi.attachEvent('onclick',function(){istanza.close();});} else {img_chiudi.addEventListener('click',function(){istanza.close();},false);}var img_sx = document.createElement('img');var img_dx = document.createElement('img');if (ie) {img_sx.attachEvent('onclick',function(){istanza.change_img(sx);});} else {img_sx.addEventListener('click',function(){istanza.change_img(sx);},false);}if (ie) {img_dx.attachEvent('onclick',function(){istanza.change_img(dx);});} else {img_dx.addEventListener('click',function(){istanza.change_img(dx);},false);}controlli.appendChild(img_sx);controlli.appendChild(img_chiudi);controlli.appendChild(img_dx);var miniature = document.createElement('div');miniature.id = 'galleria-miniature';var sx = -1;var dx = -1;var istanza = this;var a = new Array();var a_left = new Array();for(var i=0; i<li.length; i++) {li[i].getElementsByTagName('img')[0].id = 'img_galleria'+i;if (ie) {li[i].getElementsByTagName('img')[0].attachEvent('onclick',function(){istanza.click(event.srcElement);});} else {li[i].getElementsByTagName('img')[0].addEventListener('click',function(){istanza.click(this);},false);}a[i] = li[i];a_left[i] = 200*(i+1);var miniature_img = document.createElement('img');miniature_img.id = 'miniature_galleria'+i;miniature_img.src = li[i].getElementsByTagName('img')[0].src;miniature_img.alt = li[i].getElementsByTagName('img')[0].alt;miniature_img.style.width = '50px';miniature_img.style.height = '32px';if (ie) {miniature_img.attachEvent('onclick',function(){istanza.change_img(Math.round(event.srcElement.id.replace('miniature_galleria','')));});} else {miniature_img.addEventListener('click',function(){istanza.change_img(Math.round(this.id.replace('miniature_galleria','')));},false);}miniature.appendChild(miniature_img);}
		this.intervallo = setInterval(function(){istanza.move()},50);
		this.move = function(){for(var i=0; i<a.length; i++) {a_left[i] = a_left[i]-1;if (a_left[i] == '-200') { a_left[i] = 200*(a.length-1); }a[i].style.left = a_left[i]+'px';}}
		this.click = function(e){clearInterval(this.intervallo);this.change_img(Math.round(e.id.replace('img_galleria','')));var scrollTop = document.documentElement.scrollTop;if (document.documentElement.scrollTop > 0) {scrollTop = document.documentElement.scrollTop;} else if (document.body.scrollTop > 0) {scrollTop = document.body.scrollTop;}opacita.style.height = screen.height+'px';galleria.style.top = (scrollTop+10)+'px';galleria.style.width = document.documentElement.clientWidth+'px';controlli.style.top = (document.documentElement.clientHeight-125)+'px';controlli.style.left = (document.documentElement.clientWidth-100)/2+'px';miniature.style.top = (document.documentElement.clientHeight-75)+'px';if (!document.getElementById('opacita')) { document.body.appendChild(opacita); }if (!document.getElementById('galleria')) { document.body.appendChild(galleria); }if (!document.getElementById('galleria-controlli')) { document.body.appendChild(controlli); }if (!document.getElementById('galleria-miniature')) { document.body.appendChild(miniature); }galleria_img.src = e.src.replace('small','big');opacita.style.display = 'block';galleria.style.display = 'block';controlli.style.display = 'block';miniature.style.display = 'block';}
		this.change_img = function(id){if (id != -1) {if (id > 0) { sx = id-1; } else { sx = -1; }if ((id+1) < a.length) { dx = id+1; } else { dx = -1; }if (sx == -1) { img_sx.src = '/images/galleria_sx_no.png'; } else { img_sx.src = '/images/galleria_sx.png'; }if (dx == -1) { img_dx.src = '/images/galleria_dx_no.png'; } else { img_dx.src = '/images/galleria_dx.png'; }galleria_img.src = li[id].getElementsByTagName('img')[0].src.replace('small','big');galleria_img.alt = li[id].getElementsByTagName('img')[0].alt;}}
		this.close = function(){opacita.style.display = 'none';galleria.style.display = 'none';controlli.style.display = 'none';miniature.style.display = 'none';this.intervallo = setInterval(function(){istanza.move()},50);}
	}
}

// funzione onclick prodotti in offerta - 22/02/2011 - 31/03/2011
function prodotti_offerta_onclick() {
	if (dom) {
		if (!document.getElementById('prodotti-offerta')) {
			var div = document.createElement('div');
			div.id = 'prodotti-offerta';
			div.innerHTML = '<h2>Le offerte di Luglio 2011</h2><p>1) Tovagliette pubblicitarie asettiche <a href="http://www.studiopubblicita.it/offerte-del-mese.aspx" title="Offerte del mese">Vai al prodotto</a> <br /><em>Lo staff di StudioPubblicit&agrave; ti ringrazia.</em></p>';
			var img_chiudi = document.createElement('img');
			img_chiudi.id = 'prodotti-offerta-chiudi';
			img_chiudi.src = '/images/icon_chiudi.png';
			img_chiudi.style.position = 'fixed';
			img_chiudi.style.top = '434px';
			if (ie) {img_chiudi.attachEvent('onclick',function(){document.body.removeChild(img_chiudi);document.body.removeChild(div);});} else {img_chiudi.addEventListener('click',function(){document.body.removeChild(img_chiudi);document.body.removeChild(div);},false);}
			if (document.documentElement.clientWidth <= 1018) {div.style.left = (document.documentElement.clientWidth-670)+'px';img_chiudi.style.left = (document.documentElement.clientWidth-72)+'px';} else {div.style.left = ((document.documentElement.clientWidth/2)-162)+'px';img_chiudi.style.left = ((document.documentElement.clientWidth/2)+436)+'px';}
			document.body.appendChild(div);
			document.body.appendChild(img_chiudi);
		}
	}
}

// Funzione gestione load - creata 11/02/2011 - 23/02/2011
function gestione_load() {
	if (dom) {
		var torna_top = document.createElement('div');
		torna_top.id = 'torna-top';
		torna_top.innerHTML = '<a href=\"javascript:;\" title=\"torna su\" onclick=\"javascript:window.scrollTo(0,0);\">torna su</a>';
		torna_top.style.top = (document.documentElement.clientHeight-22)+'px';
		torna_top.style.left = (document.documentElement.clientWidth-102)+'px';
		document.getElementsByTagName('body')[0].appendChild(torna_top);
		var apri_prodotti_offerta = document.createElement('div');
		apri_prodotti_offerta.id = 'apri-prodotti-offerta';
		if (document.documentElement.clientWidth <= 1018) {apri_prodotti_offerta.style.left = (document.documentElement.clientWidth-50)+'px';} else {apri_prodotti_offerta.style.left = ((document.documentElement.clientWidth/2)+458)+'px';}
		if (ie) {apri_prodotti_offerta.attachEvent('onclick',function(){prodotti_offerta_onclick()});} else {apri_prodotti_offerta.addEventListener('click',function(){prodotti_offerta_onclick()},false);}
		document.getElementsByTagName('body')[0].appendChild(apri_prodotti_offerta);
	}
}

// Funzione gestione scroll - creata 11/02/2011 - 24/02/2011
function gestione_scroll() {
	if (dom) {
		var scrollTop = document.documentElement.scrollTop;if (document.documentElement.scrollTop > 0) {scrollTop = document.documentElement.scrollTop;} else if (document.body.scrollTop > 0) {scrollTop = document.body.scrollTop;}
		if (document.getElementById('torna-top')) {var torna_top = document.getElementById('torna-top');if (scrollTop < 300) {torna_top.style.display = 'none';} else {torna_top.style.display = 'block';}}
	}
}

// Funzione gestione resize - creata 11/02/2011 - 23/02/2011
function gestione_resize() {
	if (dom) {
		var torna_top = document.getElementById('torna-top');
		torna_top.style.top = (document.documentElement.clientHeight-22)+'px';
		torna_top.style.left = (document.documentElement.clientWidth-102)+'px';
		var apri_prodotti_offerta = document.getElementById('apri-prodotti-offerta');
		if (document.documentElement.clientWidth <= 1018) {apri_prodotti_offerta.style.left = (document.documentElement.clientWidth-50)+'px';} else {apri_prodotti_offerta.style.left = ((document.documentElement.clientWidth/2)+458)+'px';}
		if (document.getElementById('prodotti-offerta')) {var prodotti_offerta = document.getElementById('prodotti-offerta');var img_chiudi = document.getElementById('prodotti-offerta-chiudi');if (document.documentElement.clientWidth <= 1018) {prodotti_offerta.style.left = (document.documentElement.clientWidth-670)+'px';img_chiudi.style.left = (document.documentElement.clientWidth-72)+'px';} else {prodotti_offerta.style.left = ((document.documentElement.clientWidth/2)-162)+'px';img_chiudi.style.left = ((document.documentElement.clientWidth/2)+436)+'px';}}
	}
}

// Gestione eventi
if (window.addEventListener) {
	window.addEventListener('load', function(){gestione_load();}, false);
	window.addEventListener('load', function(){status_skype_richiesta();}, false);
	window.addEventListener('scroll', function(){gestione_scroll();}, false);
	window.addEventListener('resize', function(){gestione_resize();}, false);
} else if (window.attachEvent) {
	window.attachEvent('onload', function(){gestione_load();});
	window.attachEvent('onload', function(){status_skype_richiesta();});
	window.attachEvent('onscroll', function(){gestione_scroll();});
	window.attachEvent('onresize', function(){gestione_resize();});
} else if (dom) {
	window.onload = function(){gestione_load();};
	window.onload = function(){status_skype_richiesta();};
	window.onscroll = function(){gestione_scroll();};
	window.onresize = function(){gestione_resize();};
}
//-->
