//se il browser supporta javascript nascondo i campi
if(document.getElementById && document.createElement){
document.write('<style type="text/css">#divt1, #divt2, #divt3, .testimonianze blockquote{display:none} .testimonianze {height:107px}</style>');
}
//funzione usata nei form di registrazione e richiesta servizi x mostrare-nascondere i campi
  // _w : which ID (1) or (2)
  // _h : (h)ide or (s)how
function toggleT(_w,_h)
{
  if (document.all)
  { //  IE
    if (_h == 's') eval("document.all." + _w + ".style.display='block';");
    if (_h == 'h') eval("document.all." + _w + ".style.display='none';");
  }
  else
  { // non e' IE
    mio = document.getElementById(_w);
    if (_h == 's') {
	mio.style.display='block';
	}
    if (_h == 'h'){
	mio.style.display='none';
	}
  }
}

//funzione per far vedere i sottomenu in IE (suckerfish menu)
startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

// funzioni usate negli esempi dei cv per mostrare-nascondere i suggerimenti
function HideList(ID){
			document.getElementById(ID).className='';
		}
		
function ShowList(ID){
			document.getElementById(ID).className='over';
		}
		
//funzione per aprire i link con target _blank
function linkExt(){
if(!document.getElementsByTagName) return;
l=document.getElementsByTagName("a");
for(i=0;i<l.length;i++){
  if(l[i].className.indexOf("esterno")!=-1){
    l[i].title+=" link esterno, si apre in una nuova finestra";
    l[i].onclick=function(){window.open(this.href);return(false)};
    }
  if(l[i].className.indexOf("suono")!=-1){
    l[i].title+=", si apre in una nuova finestra";
    l[i].onclick=function(){window.open(this.href);return(false)};
    }
  if(l[i].className.indexOf("ext")!=-1){
    l[i].title+=" link esterno, si apre in una nuova finestra";
    l[i].onclick=function(){window.open(this.href);return(false)};
    }
  }
}

//funzione per colorare le righe delle tabelle a colori alterni
function zebraTable(){
    var tables = document.getElementsByTagName("table");
    for ( var t = 0; t < tables.length; t++ ) {
	  if(tables[t].className.indexOf("db")!=-1){

        var rows = tables[t].getElementsByTagName("tr");
        for ( var i = 1; i < rows.length; i += 2 )
            if ( !/(^|\s)odd(\s|$)/.test( rows[i].className ) )
                rows[i].className += " odd";
    }
	}
}
	function testimonianze() {
		if ($('.testimonianze').length){
		jQuery.each($(".testimonianze blockquote p"), function() {
		var $quote = $(this);
		$quote.css("line-height", "1.4");
		var $numWords = $quote.text().split(" ").length;
		if (($numWords >= 1) && ($numWords < 25)) {
			$quote.css("font-size", "16px");
		}
		else if (($numWords >= 23) && ($numWords < 40)) {
			$quote.css("font-size", "15px");
		}
		else if (($numWords >= 41) && ($numWords < 65)) {
			$quote.css("font-size", "14px");
		}
		else {
			$quote.css("font-size", "12px");
		}
		});
		$('.testimonianze').innerfade({
			speed: 'slow',
			timeout: 5000,
			type: 'random',
			containerheight: '107px'
		});
		}
	}
//inizializzazione delle funzioni
$(document).ready(function() {
	$("#social a").tooltip({
		effect: 'slide',
		delay: 300,
		predelay: 100,
		offset: [10, 0]
	});
	startList();
	linkExt();
    Shadowbox.init();
	zebraTable();
	testimonianze();
});
