// Funzione che apre un div e chiude tutti gli altri //

function THISonTHAToff(code) {

    ff = document.getElementsByTagName("div");
    for (i = 0; i < ff.length; i++) {
        if (ff[i].id.substr(0,5)=="onOff") {
            ff[i].style.display = "none";
        }
    }   
    for (i = 0; i < ff.length; i++) {
        if (ff[i].id == code) {
            if (ff[i].style.display == "none") {
                ff[i].style.display = "";
            }
        }
    }
}

// Funzione che apre e chiude un div cliccando sul link //

function THISonTHISoff(code) {
    ff = document.getElementById(code);
		if (ff.style.display == "") {
			ff.style.display = "none";
		} else
		if (ff.style.display == "none") {
			ff.style.display = "";
		}
}

// Funzione che apre la popup //

function Popup(url, stile) {
	window.open(url, "", stile);
	}
	
	// popup opener function, used for popups from content
function popupExtWin(wurl, wname, size, resize, navi) {
	size=new String(size);
	if (navi == 0) {
		var wfeatures = 'toolbar=no,location=no,directories=no,status=no,menubar=no,';
	} else {
		var wfeatures = 'toolbar=yes,menubar=yes,location=yes,status=yes,directories=yes,';
	}
	
	if (resize == 0) {
		wfeatures = wfeatures + 'scrollbars=no,resizable=no,'
		widthOffSet = 0;
	} else {
		wfeatures = wfeatures + 'scrollbars=yes,resizable=yes,'
		widthOffSet = 16;
	}
	
	newWinSize = size.charAt(0);
	switch(parseInt(newWinSize)) {
		case 0: 
			theFirst	= size.indexOf("-");
			theSecond	= size.lastIndexOf("-");
			winWidth	= size.slice(theFirst+1,theSecond) ;
			winHeight	= size.slice(theSecond+1) ;
			break;
		case 1:
			// 5 columns - old: width=400,height=400
			winWidth	= 390;
			winHeight	= 393;
			break;
		case 2:
			// 7 columns - old: width=600,height=500
			winWidth	= 546;
			winHeight	= 493;
			break;
		case 3:
			// 8 columns - old: width=800,height=600
			winWidth	= 624;
			winHeight	= 493;
			break;
		case 4:
			// ?
			winWidth	= 1024;
			winHeight	= 768;
			break;
		default:
			// 8 columns is default - old: width=800,height=600
			winWidth	= 624;
			winHeight	= 493;
			break;
	} 
	wfeatures = wfeatures + 'width=' + (parseInt(winWidth)+parseInt(widthOffSet)) + ',height=' + winHeight
	jetzt = new Date();
	windowName = "newExtPopupWin" + jetzt.getHours() + jetzt.getMinutes() + jetzt.getSeconds();

	//now we need to escape th wurl afer the second questionmark. this could be when a visuaal scope is used
	wurllist = wurl.split('?');
	newwurlback = '';
	i = 2;
	while ( i < wurllist.length) {
		newwurlback = newwurlback + '?' + wurllist[i];
		i++;
	}
	
	newwurlback = escape(newwurlback);
	wurl = wurllist[0];
	
	if (wurllist.length > 1) {wurl = wurl + '?' + wurllist[1];}
	wurl = wurl + newwurlback;
    
	newCmd = windowName + "= window.open(wurl, windowName, wfeatures);";
	eval(newCmd);
}


// mostra layer nascosto

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

// Cambia classe //

function classChange(element,newclass) 
{
     document.getElementById(element).className = newclass;
}

function classSwitch(element, class1, class2) 
{
     var elemento = document.getElementById(element);
	 
	 if (elemento.className == class1)
	 	elemento.className = class2;
	 else
	 	elemento.className = class1;
}
