﻿var imgGalleryHeader;
var hs_gruppo_corrente = "Presentazione_1";

// Browser detect

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

//document.write('<p class="accent">Stai usando ' + BrowserDetect.browser + ' ' + BrowserDetect.version + ' on ' + BrowserDetect.OS + '!</p>');

// fine Browser detect



if (window.addEventListener) {
window.addEventListener("load", init_script, false);
} else if (window.attachEvent) {
window.attachEvent("onload", init_script);
} else {
window.onload = init_script;
}

if (window.addEventListener) {
window.addEventListener("load", domCaricato, false);
} else if (window.attachEvent) {
window.attachEvent("onload", domCaricato);
} else {
window.onload = domCaricato;
}


function rif_sitoweb() {
var indirizzo = window.location.href;
var chips_rif_origine = indirizzo.split("/");

var chips_dom_provenienza = chips_rif_origine[2].replace("www.","");
return chips_dom_provenienza;
}

//var provenienza = querySt("ws");
var rif_chips_dominio = rif_sitoweb();

//document.write(rif_chips_dominio);



/*
if (window.addEventListener) {
window.addEventListener("load", mostra_gallery, false);
} else if (window.attachEvent) {
window.attachEvent("onload", mostra_gallery);
} else {
window.onload = mostra_gallery;
}
*/



// caricamento pagine

var percorso = document.location.pathname;
var array_dir = (percorso.split("/"));
var conta_dir = array_dir.length;

var ultimoslash = percorso.lastIndexOf("/");
var senza_penultimo = (percorso.slice(0,ultimoslash));
var penultimoslash = senza_penultimo.lastIndexOf("/") + 1;
var risultato = (senza_penultimo.slice(penultimoslash,penultimoslash + 5));

//var pathcompleto = window.location.href;
//var cerca_chips = (pathcompleto.slice(0,27));
//var controllo_chips = 'http://www.chipsmachine.com';

//alert(penultimoslash);

function domCaricato(){
	var nuovoDiv = document.createElement("div");
	nuovoDiv.setAttribute("id","domReadyDiv");
	nuovoDiv.setAttribute("style","display:none");
	nuovoDiv.innerHTML = "";
	document.body.appendChild(nuovoDiv);
}


function ch_page(num){

if (document.getElementById("Progettazione")){
	document.getElementById(num).style.display = "none";
	document.mainform.c_utente.value = "page";
	registra(num);
} else {
	ch_pageOk(num);
}

}


function ch_subpage(num){

if (document.getElementById("Progettazione")){
	document.getElementById(num).style.display = "none";
	document.mainform.c_utente.value = "subpage";
	registra(num);
} else {
	ch_subpageOk(num);
}

}


function ch_pageOk(num){
	if (risultato=="page_") {
		cambiopagina="../page_"+num+"/index.php";
		self.location.href=cambiopagina;
	} else {
		cambiopagina="../../page_"+num+"/index.php";
		self.location.href=cambiopagina;
	}
}

function ch_subpageOk(num){
	if (risultato=="s_pg_") {
		cambiopagina="../s_pg_"+num+"/index.php";
		self.location.href=cambiopagina;
	} else {
		cambiopagina="s_pg_"+num+"/index.php";
		self.location.href=cambiopagina;
	}
}







function apriloginResArea() {
	if (authSession == "ok") {
		ch_page("0000000ResArea");
		return false;
	}
	new Effect.Appear("over", {duration:0.6, from: 0.0, to: 0.7, fps:90});
	var loginWindow = document.getElementById("loginAreaRis");
	loginWindow.style.left = "-600px";
	loginWindow.style.top = 300 + "px";
	var posX = document.body.clientWidth / 2 - 100 + 600;
	new Effect.Appear(loginWindow, {duration:1.5});
	new Effect.Morph(loginWindow, {style:' margin-left:'+posX+'px;', duration:3.3, transition:Effect.Transitions.slowstop, fps:90});
}

function chiudiloginResArea() {
	new Effect.Fade("over", {duration:0.6, from: 0.7, to: 0.0, fps:90});
	var loginWindow = document.getElementById("loginAreaRis");
	new Effect.Fade(loginWindow, {duration:0.9, fps:90});
}




/*
function ch_pageOk(num){
if (cerca_chips==controllo_chips) {
	if (conta_dir==4) {
		cambiopagina="../page_"+num+"/index.php";
		self.location.href=cambiopagina;
		}
	if (conta_dir==5) {
		cambiopagina="../../page_"+num+"/index.php";
		self.location.href=cambiopagina;
		}
	} else {
	if (conta_dir==3) {
		cambiopagina="../page_"+num+"/index.php";
		self.location.href=cambiopagina;
		}
	if (conta_dir==4) {
		cambiopagina="../../page_"+num+"/index.php";
		self.location.href=cambiopagina;
		}
	}
}

function ch_subpageOk(num){
if (cerca_chips==controllo_chips) {
	if (conta_dir==4) {
		cambiopagina="s_pg_"+num+"/index.php";
		self.location.href=cambiopagina;
		}
	if (conta_dir==5) {
		cambiopagina="../s_pg_"+num+"/index.php";
		self.location.href=cambiopagina;
		}
	} else {
	if (conta_dir==3) {
		cambiopagina="s_pg_"+num+"/index.php";
		self.location.href=cambiopagina;
		}
	if (conta_dir==4) {
		cambiopagina="../s_pg_"+num+"/index.php";
		self.location.href=cambiopagina;
		}
	}
}
*/





/*
function pagelink(collega){
//alert(collega);
self.location.href = collega;
}
*/



function azioniElem(nome,indirizzo,elemId) {
//alert(indirizzo);
}

function collegaElem(nome,indirizzo,elemId) {
//alert(indirizzo);
}

function apriElem(nome,indirizzo,elemId) {
//alert(indirizzo);
}


//****************************************************** Autofit iframe

function calcHeight(frame) // controllare se utilizzato
{
	var frame = frame.id;
	//var the_height=document.frames['the_iframe'].document.body.scrollHeight;//find the height of the internal page
	var the_height=document.getElementById(frame).contentWindow.document.body.scrollHeight;//find the height of the internal page

	//document.getElementById('the_iframe').style.height=the_height;//change the height of the iframe
	document.getElementById(frame).height=the_height;//change the height of the iframe
	//document.getElementById(frame).style.visibility = 'visible';
}




//****************************************************** INIT IMPOSTAZIONI LINGUA E FORUM

//echo "<a href='" . $_SERVER['PHP_SELF'] . "?lang=it'>IT</a> - ";


function init_script() {
	
	var alt_footer = ($('footerBox').getHeight()) + 'px';
	
	$('extraBottomBar').style.height = alt_footer;
	$('extraBottomBar').style.marginTop = '-' + alt_footer;
	
	//*********** reset Card
	$$('.chips_ArrowCardActive').each(function(element) {
		element.className = "chips_ArrowCard";
		element.nextSibling.style.display = "none";
	});
	
	//*********** reset NewsCard
	$$('#news_cont div.chips_NewsCard').each(function(element) {
		element.style.display = "none";
	});
	$('news_cont').style.display = "block";
	

	//var alt_header = ($('headerBG').getHeight()) + 'px';
	//$('topBody').style.height = alt_header;

//******************** colore selettore lingua attuale
	
	if (document.getElementById(lingua_corrente)) {
	document.getElementById(lingua_corrente).className = "chips_"+lingua_corrente+"_chips_sel";
	}

//******************** Browser Logs
	if (cur_PageN == "'1'") {
		if ((BrowserDetect.browser == "Explorer") && (BrowserDetect.version <= "6")) {
			var datiBrowser = 'utente='+prev;
			//alert(datiBrowser);
			var creaBrowserLog = new Ajax.Request('http://www.chipsmachine.com/chips/_private/browserAlert/creaBrowserLog.php', {
				method:'post',
				postBody:datiBrowser,
				onSuccess: function(transport){
					//alert(datiBrowser);
					//var response = transport.responseText || "no response text"; 
					//risultatoVerS(response);
				},
				onFailure: function(){
					//alert(alert_033);
				}
			});
		}
	//if (prev = 'demo_chips') {
		if ((BrowserDetect.browser == 'Explorer') && (BrowserDetect.version <= '5')) {
		alert('Per visualizzare correttamente questo sito si consiglia l\'utilizzo di Explorer v.7 o superiore.');
		}
	//}
		//alert('Stai usando ' + BrowserDetect.browser + ' ' + BrowserDetect.version + ' on ' + BrowserDetect.OS + '!');
	}
	
	// preferenze Galleria Immagini
	if (document.getElementById("Progettazione")) {
		//if ($('galleryframe')) {
			if (galleryTransitionType == 'Crossfading') {document.getElementById("selectTransition").selectedIndex = 0;}
			if (galleryTransitionType == 'KenBurns') {document.getElementById("selectTransition").selectedIndex = 1;}
			if (galleryTransitionType == 'Push') {document.getElementById("selectTransition").selectedIndex = 2;}
			//if (galleryTransitionType == 'Slide') {document.getElementById("selectTransition").selectedIndex = 3;}
			if (galleryTransitionType == 'SlideUp') {document.getElementById("selectTransition").selectedIndex = 3;}
			if (galleryTransitionType == 'Flash') {document.getElementById("selectTransition").selectedIndex = 4;}
			if (galleryTransitionType == 'Fold') {document.getElementById("selectTransition").selectedIndex = 5;}
			document.getElementById("InputGalleryWidth").value = galleryWidth;
			document.getElementById("InputGalleryHeight").value = galleryHeight;
			if (imgGalleryTitle == 'true') {document.galleryOptionForm.galleryTitleN.checked=true;}
			if (imgGalleryThumbs == 'true') {document.galleryOptionForm.galleryThumbsN.checked=true;}
			if (imgGalleryContr == 'true') {document.galleryOptionForm.galleryControllerN.checked=true;}
			if (imgGalleryCapt == 'true') {document.galleryOptionForm.galleryCaptionN.checked=true;}
			if (imgGalleryPaused == 'false') {document.galleryOptionForm.galleryPausedN.checked=true;}
			if (imgGalleryResize == 'true') {document.galleryOptionForm.galleryResizeN.checked=true;}
			if (imgGalleryRandom == 'true') {document.galleryOptionForm.galleryRandomN.checked=true;}
			if (imgGalleryZoom == 'true') {document.galleryOptionForm.galleryZoomN.checked=true;}
			if (imgGalleryDid == 'true') {document.galleryOptionForm.galleryDidN.checked=true;}
			if (imgGalleryLoop == 'true') {document.galleryOptionForm.galleryLoopN.checked=true;}
			if (galleryTransitionType == 'KenBurns') {document.galleryOptionForm.galleryResizeN.disabled=true;}
			if (imgGalleryZoom == 'false') {document.galleryOptionForm.galleryDidN.disabled=true;}
			document.getElementById("galleryTimer").value = imgGalleryTimer;
			if ((galleryTransitionType == 'Push') || (galleryTransitionType == 'Slide')) {
				$("galleryDuration").value = imgGalleryDuration * 0.2;
			} else if (galleryTransitionType == 'SlideUp') {
				$("galleryDuration").value = imgGalleryDuration * 0.5;
			} else if (galleryTransitionType == 'Fold') {
				$("galleryDuration").value = imgGalleryDuration * 0.3;
			} else {
				$("galleryDuration").value = imgGalleryDuration;
			}
			ctrlAutoplayGall();
			ctrlRandomGall();
		//}
	}
	
	
		if (imgGalleryHeader == 'true') {
			var header_h = $('headerBG').getHeight();
			if (controlloEdit == ".edit") {
				var fileGallery = "gallery.php";
			} else {
				var fileGallery = "gallery.html";
			}
				
			var HeaderGallery = '<div class="chips_GalleryBox" id="galleryHeaderBox" style="top:' + imgGalleryTop + 'px; left:' + imgGalleryLeft + 'px; height:' + galleryHeight + 'px; overflow:hidden; position:absolute; z-index: 1;"><iframe allowtransparency="true" class="chips_Gallery_frame" id="galleryframe" src="' + fileGallery + '" name="galleryframe" frameborder="0" scrolling="no" style="float:left; visibility: hidden;" style="visibility:hidden;" onload="this.style.visibility = \'visible\';" width="' + galleryWidth + '" height="' + galleryHeight + '"></iframe><div id="handle_headerGallery" style="display:none; position:absolute; top: 0px; left: 0px; width: ' + galleryWidth + 'px; height: ' + galleryHeight + 'px; background: url(http://www.chipsmachine.com/chips/immagini/blank.gif); cursor:move;"></div></div>';
			document.getElementById("site_title").style.zIndex = "91";
			document.getElementById("site_subtitle").style.zIndex = "91";
			document.getElementById("langBar").style.zIndex = "91";
			
			$('headerGallery').style.position = 'absolute';
			$('headerGallery').style.width = $('headerBG').getStyle('width');
			$('headerGallery').style.height = $('headerBG').getStyle('height');
			$('headerGallery').style.overflow = 'hidden';
			if (controlloEdit != ".edit") {
				$('headerGallery').style.zIndex = "90";
			}
			$('headerGallery').innerHTML = HeaderGallery;
		}
	
	
	/* da finire per la traduzione automatica
	if (lingua_corrente != "it") {
	document.getElementById("pulsanteTraduzione").style.display = "block";
	}
	*/	
	
//******************** fine init Lingua


//******************** init Carousel


		function startCarousel(idCarousel) {
			var larghezzaSlideBoxWrap = $('slideBox_Wrap'+idCarousel+'').getWidth();
			var countSlide = 0;
			$$('#slideBox'+idCarousel+' .slide').each(function(element) {
				countSlide++;
			})
			var larghezzaSlideBox = (larghezzaSlideBoxWrap * countSlide) + "px";
			$('slideBox'+idCarousel+'').style.width = larghezzaSlideBox;
			
			var idCarousel = new Carousel('slideBox_Wrap'+idCarousel+'', $$('#slideBox'+idCarousel+' .slide'), $$('#tabsContenitore'+idCarousel+' li a.carousel-jumper'), {
				wheel: false,
				afterMove: function(){
					idCarousel.controls.each(function (elm) {
						elm.removeClassName(idCarousel.options.selectedClassName);
					});
					idCarousel.controls.each(function (elm) {
						if (elm.rel == idCarousel.current.id) {
							elm.addClassName(idCarousel.options.selectedClassName);
						}
					});
			    }
		 	});
		 	clearTimeout(idCarousel.timer);
		 	idCarousel.options.duration = "0.5";
		 	idCarousel.options.circular = false;
		 	idCarousel.options.effect = "scroll";
		 	
		 	//if(typeof(opzioniUtente) != 'undefined'){  
		 	if (typeof opzioniUtente === 'function') {
		 		opzioniUtente(idCarousel);
		 	}
		}
		
		var iC = 0;
		var idCarouselBox;
		$$('.slideBox').each(function(element) {
			iC++;
			idCarouselBox = element.id;
			idCarouselBox = idCarouselBox.replace("slideBox","");
			startCarousel(idCarouselBox);
			//alert(idCarouselBox);
			
		})
		
		$$('.carousel-jumper').each(function(element) {
			if (element.hasClassName('noTab')) {
				element.className = "carousel-jumper noTab";
			} else {
				element.className = "carousel-jumper";
			}
		})
		$$('.tabs').each(function(element) {
			if (element.firstChild.firstChild.hasClassName('noTab')) {
				element.firstChild.firstChild.className = "carousel-jumper noTab carousel-selected";
			} else {
				element.firstChild.firstChild.className = "carousel-jumper carousel-selected";
			}
		})
		
		
//******************** fine init Carousel


//******************** init Forum

	if (controlloEdit != ".edit") {
		if (document.getElementById("BlogNameCont")) {
			showpreviewForum();
			var editabili = new Array("BlogNameCont","BlogTitleCont","BlogPostCont");
			for (i=0; i<editabili.length; i++) {
				var editForum = document.getElementById( editabili[i] );
				editForum.contentEditable = true;
			}
	
			// Flash Player detect
			// Version check based upon the values entered above in "Globals"
			var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
			// Check to see if the version meets the requirements for playback
			if (!hasReqestedVersion) {
			alert("Per caricare gli allegati ai post del forum occorre una versione recente di Flash Player!");	
			}
		}
	}
	
//******************** fine init Forum



	
}

//******************** fine init Script






var questa_pagina = document.location.href;



function ch_lang(lingua_scelta) {

if (lingua_scelta.id == lingua_corrente) {
return false;
}

nuova_lingua = lingua_scelta.id;

if (questa_pagina.indexOf(".edit/") != -1) {
	
	var pagina_path = questa_pagina.replace("http://www.chipsmachine.com","");
	var pagina_path = pagina_path.replace("index.php","page_contents");
	var par_ctrLingua = 'c_newLang='+nuova_lingua+'&c_pagina_path='+pagina_path;
	var nuovaAR = new Ajax.Request('http://www.chipsmachine.com/chips/php/verifica_esist_versione.php', { method:'post', parameters: par_ctrLingua, 
	onSuccess: function(transport){
			var response = transport.responseText || "no response text";
			if (response == "yes") {
			ch_lang_ok(lingua_scelta);
			} else {
			alert("La versione in "+lingua_scelta.title+" di questa pagina non e' stata ancora creata.\nPuoi farlo da:\n\nmenu inserisci -> versioni in altre lingue\n\n");
			////////oppure usando il traduttore automatico nella barra comandi in alto.
			}
		},
		onFailure: function(){
			alert("Si e' verificato un errore...");
			return false;
		}
	});
	
	} else {
	new Effect.Appear("over_ch_language", {duration:0.6, from: 0.0, to: 0.9});
	timerCambioLingua = window.setTimeout("cambioLingua(nuova_lingua);", 1500);
	}
}

function ch_lang_ok(lingua_scelta) {	
if(!confirm("Vuoi passare alla versione in "+lingua_scelta.title+"?")) {
		return false;
		}
		document.mainform.c_utente.value = "noalert";
		timerRegistra = window.setTimeout("registra();", 100);
		new Effect.Appear("over_ch_language", {duration:0.6, from: 0.0, to: 0.9});
		timerCambioLingua = window.setTimeout("cambioLingua(nuova_lingua);", 1500);	
}	
	
	
	

function cambioLingua(lingua_scelta) {
	var par_lingua = 'lang='+lingua_scelta;
	//alert(par_lingua);
	if (prev != 'demo_chips') {
	if (questa_pagina.indexOf(".edit/") == -1) {
		var publ_pagina = questa_pagina.replace("?lang="+lingua_corrente,"");
		publ_pagina = publ_pagina + "?" + par_lingua;
		self.location.href = publ_pagina;
		return false;
	}
	}
	var nuovaAR = new Ajax.Request('http://www.chipsmachine.com/chips/php_pubbl/cambio_lingua.php', { method:'get', parameters: par_lingua, onSuccess: ricaricaPagina });
}
	
/*
questa_pagina = questa_pagina.replace("?lang="+lingua_corrente,"");
	if (questa_pagina.indexOf("?lang=") > -1){
	//da completare
	} else {
	nuova_pagina = questa_pagina+"?lang="+lingua_scelta.id;
	self.location.href=nuova_pagina;
	}
*/	
	

function ricaricaPagina() {
	//alert(questa_pagina);
	nuova_pagina = questa_pagina.replace("?lang="+lingua_corrente,"");
	self.location.href = nuova_pagina;
}



//****************************************************** id Carousel

var riferimentoCarousel = 0;
function rifSlide(el) {
	if ($("Progettazione")) {
		/*
		riferimentoCarousel = el;
		riferimentoCarousel = riferimentoCarousel.replace("slide","");
		riferimentoCarousel = riferimentoCarousel.replace("a","");
		riferimentoCarousel = riferimentoCarousel.replace("b","");
		riferimentoCarousel = riferimentoCarousel.replace("c","");
		*/
	}
}

//************************************************* fine id Carousel



function editMode(elem) {
if ($("Progettazione")) {
	$("campo_controlFormat").value = elem.id;
	var contParagr = document.getElementById("campo_controlFormat").value;
	//document.getElementById("riferimentoParSelez").innerHTML = elem.previousSibling.innerHTML;
	document.filmatiFormN.AddFilmatiButton.disabled = false;
	document.filmatiFormN.AddFilmatiButton.value = "Inserisci";
	
	if (idMode == "edit") {
		//contrSelezioneImg = "";
		safariWin();
		showMedia();
		memSelez();
		if ($('newControlliTabelle_wrap')) {
			if (controlloPaletteTabelle == "1") {
				//var timerApriPalette = window.setTimeout(showHideControlliItem('newControlliTabelle_wrap'), 20);
			} else {
				disabilitaTabella();
			}
		}
		if  ((controlloPaletteImmagini == "0") && ($("label_newControlliMedia_wrap").className == "label_palette_selected")) {
				showHideControlliItem('newControlliMedia_wrap');
				//controlloPaletteImmagini = "0";
		}
		
		if  ((controlloPaletteFilmati == "0") && ($("label_newControlliFilmati_wrap").className == "label_palette_selected")) {
				showHideControlliItem('newControlliFilmati_wrap');
				//controlloPaletteFilmati = "0";
		}
		//var timerApriPalette = window.setTimeout(mostraPaletteControlliTesto(), 600);
		
		if  ((controlloPaletteGallerie == "0") && ($("label_newControlliGalleria_wrap").className == "label_palette_selected")) {
				showHideControlliItem('newControlliGalleria_wrap');
				//controlloPaletteImmagini = "0";
		}
		
		if  ((controlloPaletteNews == "0") && ($("label_newControlliNews_wrap").className == "label_palette_selected")) {
				showHideControlliItem('newControlliNews_wrap');
				//controlloPaletteImmagini = "0";
		}
		
		if  (controlloPaletteSlideBox == "0") {
			
			var ctrlSlideBox = contParagr.replace("Text","");
			ctrlSlideBox = ctrlSlideBox.replace("a-","");
			ctrlSlideBox = "tab"+ctrlSlideBox;
		
			if ( ($(ctrlSlideBox)) ) {
				var idTabs = $(ctrlSlideBox).parentNode.id;
				var contenitoreSlideBox = $(ctrlSlideBox).parentNode.parentNode.parentNode.parentNode.id;
				rifCrsl = idTabs.replace("tabs","");
				
				if ($(idTabs).firstChild.firstChild.hasClassName('noTab')) {
					$('SlideBoxTabs_cb').disabled = false;
					$('SlideBoxTabs_cb').checked = false;
				} else {
					$('SlideBoxTabs_cb').disabled = false;
					$('SlideBoxTabs_cb').checked = true;
				}
				
				scalaSlideBox(rifCrsl, contenitoreSlideBox);
				
				if ($("label_newControlliSlideBox_wrap").className == "label_palette") {
					mostraPaletteControlliSlideBox();
				}
			} else {
				if (contParagr != 'slogan') {
					if ($("label_newControlliSlideBox_wrap").className == "label_palette_selected") {
						closePaletteControlliSlideBox();
					}
				}
			}
		}
		
		if  ($("label_newControlliLink_wrap").className == "label_palette_selected") {
				//alert(elem.id);
				//hideLink();
				//controlloPaletteImmagini = "0";
		}
		
		}
	}
}



//****************************************************** Scrolling News



function startNEWscrollNews(){


var elencoNews=(document.getElementById("newsScrollBox").childNodes.length);
numNews = new Array(elencoNews);
box_news = document.getElementById("newsScrollBox");
var altezzaNews = box_news.childNodes.id;
numNewsll = new Array(altezzaNews);


alunni =new Array("Aldo","Giovanni","Giacomo","Mario","Gianni","Monica");
voti= new Array(3,8,5,7,4,4); // a ogni nome corrisponde un voto




for (i=0; i<numNews.length; i++) { 
alert(voti[i]);
  
 
  

//fine blocco di istruzioni 
} 



}


//ele = box_news.childNodes[3].offsetHeight;
//alert (ele);

	
		

function NEWscrollNews(scrollH){
//var tHeight = $('NewsText1219662539731').scrollHeight;
//var NextNews = document.getElementById('newsScrollBox').style.height;
//new Effect.ScrollVertical('newsScrollBox', {duration:3.7, transition:Effect.Transitions.slowstop, to: scrollH});
//window.setTimeout("alert(scrollH)", (4000));
alert(scrollH);
}


/*
function startscrollNews(){
timerstart = window.setTimeout("scrollNews();", 4500);
}

function scrollNews(){
	//clearTimeout(timerId);
	new Effect.ScrollVertical('newsScrollID', {duration:3.7, transition:Effect.Transitions.slowstop, to: 200});
	timerId = window.setTimeout("scrollNews();", 4500);
}

function stopscrollNews(){
	clearTimeout(timerId);
	timerId = window.setTimeout("scrollNews();", 4255500);
}
*/

function frecceOn(){
//document.getElementById('contFrecce').style.display="block";
}

function frecceOff(){
//document.getElementById('contFrecce').style.display="none";
}


//****************************************************** Scrolling Banner

var ultimoBanner = 0;
var interrompiScroll = 0;


function startscrollBanner(){
ultimoBanner = document.getElementById('bannerScrollBox').lastChild;
timerstart = window.setTimeout("scrollBanner();", 2000);
}

function scrollBanner(){
	var primoBanner = document.getElementById('bannerScrollBox').firstChild;
	//var ultimoBanner = document.getElementById('bannerScrollBox').lastChild;
	var tuttiIBanner = document.getElementById('bannerScrollBox').childNodes;
	if (ultimoBanner != primoBanner) {
		new Effect.DropOut(ultimoBanner, { delay:4.0, duration:0.7, afterFinish: function() {
			ultimoBanner = ultimoBanner.previousSibling;
			scrollBanner();
			} 
		});
	} else {
	
	//startscrollBanner();
}
	
	
	//alert(tuttiIBanner[i].id);
	
	//new Effect.DropOut(tuttiIBanner[i], { duration:0.7 });
		//rendidragab = document.getElementById( dragab[i] );
		//new Effect.DropOut(rendidragab, { duration:0.7 });
	//}
	/*
	new Effect.DropOut(ultimoBanner, { duration:0.7 });
	ultimoBanner = ultimoBanner.previousSibling;
	timerBanner = window.setTimeout("scrollBanner();", 5000);
	*/
}

	
function stopscrollBanner(){
	clearTimeout(timerBanner);
	//timerId = window.setTimeout("scrollBanner();", 4255500);
}



/*

function nascondi_gallery() {
	if (document.getElementById("wrap_gallery").style.display = "block") {
	document.getElementById("wrap_gallery").style.display = "none";
	}
}


function mostra_gallery() {
	new Effect.BlindDown('wrap_gallery', {duration:0.7});
}

*/


/*
var Timer;
function Animate()
{
  document.getElementById("headerBG").scrollTop = 1000;
  clearInterval(Timer);
  Timer = setInterval("ScrollToLeft()", 20);
}
function ScrollToLeft()
{
  document.getElementById("headerBG").scrollLeft -= 2;
  if (document.getElementById("headerBG").scrollLeft == 0 ){
    document.getElementById("headerBG").scrollLeft = 1000;
  }
}
*/


/*
var timerId;
var curPos = 0;
var news_list;

function scrolldown(){
	clearTimeout(timerId);
	var curPos = news_list.scrollTop + 1;
	document.getElementById("wrapNews").scrollTop += curPos;
	timerId =  window.setTimeout("scrolldown();", 30);
}
function scrollup(){
	clearTimeout(timerId);
	var curPos = news_list.scrollTop - 1;
	document.getElementById("wrapNews").scrollTop += curPos;
	timerId =  window.setTimeout("scrollup();", 30);
}
function scrolldownV(){
	clearTimeout(timerId);
	var curPos = news_list.scrollTop + 2;
	document.getElementById("wrapNews").scrollTop += curPos;
	timerId =  window.setTimeout("scrolldownV();", 10);
}
function scrollupV(){
	clearTimeout(timerId);
	var curPos = news_list.scrollTop - 2;
	document.getElementById("wrapNews").scrollTop += curPos;
	timerId =  window.setTimeout("scrollupV();", 10);
}
function stopscroll()  {
	clearTimeout(timerId);
}
*/






//****************************************************** Controllo Card

//  function highlightCard(OpenCard){
//  	new Effect.Highlight(OpenCard, {startcolor:'#ffff99', endcolor:'#ffffff'});
//  }



var currentCard;
var contentsPosY = 0;
var titleCardPosY = 0;
var newPosY = 0;
var oldPosY = 0;
var idCard = 0;
var idArrowCard = 0;

function openCard(card){

if ((currentCard !== undefined) && (document.getElementById(currentCard))){
	var idCard = currentCard.slice(4);
	var idArrowCard = "Arrow"+idCard;
	document.getElementById(idArrowCard).className = "chips_ArrowCard";
	if (currentCard !== card) {
		new Effect.BlindUp(currentCard, {duration:0.7});
	}
}
if (document.getElementById){
	currCard = document.getElementById( card );	
	var Qcard = document.getElementById(card);
	var nAnchor = Qcard.parentNode.parentNode.parentNode;
	var idCard = card.slice(4);
	var idArrowCard = "Arrow"+idCard;
	
	if (currCard.style.display == "none"){
		document.getElementById(idArrowCard).className = "chips_ArrowCardActive";
		document.getElementById( card ).style.height = "";
		new Effect.BlindDown(card, { duration:1.1, afterFinish: function() {
		//alert(nAnchor.id);
				/*
				if(navigator.appName.indexOf("Firefox") <-1) {
				var nAnchorFirefox = Qcard.parentNode.parentNode.parentNode;
				alert("ff");
				//new Effect.ScrollTo(nAnchorFirefox.id,{offset: -29});
				} else {
				new Effect.ScrollTo(nAnchor.id,{offset: -29});
				}
				*/
				if ((BrowserDetect.browser !== "Firefox") && (BrowserDetect.browser !== "Explorer")) {	
				new Effect.ScrollTo(nAnchor.id);
				}
			}
		});
		
		} else {
		document.getElementById(idArrowCard).className = "chips_ArrowCard";
		new Effect.BlindUp(card, { duration:0.7 });
		document.getElementById( card ).style.height = "";
		//alert("Stiamo effettuando un aggiornamento del programma.\nQuesto e' un messaggio temporaneo di servizio.\nGrazie.\n\n"+currCard.id);
			//new Effect.BlindUp(card, {transition:Effect.Transitions.exponential, fps:90});
		}
	}
	currentCard=card;
}

function closeCurrentCard() {
	if (currentCard !== undefined) {
		var idCard = currentCard.slice(4);
		var idArrowCard = "Arrow"+idCard;
		document.getElementById(idArrowCard).className = "chips_ArrowCard";
		resetCard=document.getElementById( currentCard );
		resetCard.style.display = "none";
		currentCard=undefined;
	}
}


/*scaleY:false, scaleX:true*/




//************************************************** Controllo NewsCard

var currentNewsCard;
var bloccaRiapertura = "0";

function openNewsCard(newscard){

if (newsSchede == 'newsSchede_OFF') {
	return false;
}
if (bloccaRiapertura == "1") {
		return false;
}
if (currentNewsCard !== undefined) {
	if (currentNewsCard !== newscard) {
		new Effect.BlindUp(currentNewsCard, {duration:0.5});
		//currentNewsCard.style.display = "none";
	}
}

if (document.getElementById) {
	currNewsCard = document.getElementById( newscard );

	var currNewsCardText = currNewsCard.firstChild.nextSibling;
	var currNewsCardButt = currNewsCard.firstChild;
	/*// da rivedere (forse per IE 7)
	var currNewsCardText_w = currNewsCard.firstChild.nextSibling.getStyle('width');
	currNewsCardText_w = currNewsCardText_w.replace('px', '');
	var currNewsCardText_margin = currNewsCard.firstChild.nextSibling.getStyle('marginLeft');
	currNewsCardText_margin = currNewsCardText_margin.replace('px', '');
	var currNewsCard_w = (currNewsCardText_w * 1) + (currNewsCardText_margin * 2) + 'px';
	var currNewsButt_left = (currNewsCardText_w * 1) + (currNewsCardText_margin * 1) + 'px';
	*/
	if (controlloEdit != ".edit") {
		currNewsCard.style.width = '620px';
		//currNewsCardButt.style.left = currNewsButt_left;
	}
	
	if ((currNewsCard.style.display == "none") && (bloccaRiapertura == "0")) {
		bloccaRiapertura = "1";
		//alert(bloccaRiapertura);
		//var bloccaScrollNews = window.setInterval("clearTimeout(timerNews)", 20);
		new Effect.CenterNewsCard(newscard);
		//currNewsCard.style.display = "block";
		new Effect.Grow(newscard, {direction: 'center', duration: 1.0, afterFinish: function() { var project_h = $('project').getHeight(); var ncard_h = $(newscard).getHeight(); $('over').style.height = (project_h + ncard_h + 29) + 'px'; bloccaRiapertura = 0; new Effect.Appear("over", {duration:0.6, from: 0.0, to: 0.7}); }
		});
	} else {
		/*
		window.clearInterval(bloccaScrollNews);
		clearTimeout(timerNews);
		window.setTimeout('autoScrollNews();',(3000));
		*/
		new Effect.Shrink(newscard, {duration:0.9});
		new Effect.Fade("over", {duration:0.6, from: 0.7, to: 0.0, fps:90});
		//currNewsCard.style.display = "none";
		//new Effect.BlindUp(newscard, {transition:Effect.Transitions.exponential, fps:90});
	}
}
	currentNewsCard=newscard;
}

function closeCurrentNewsCard() {
	if (currentNewsCard !== undefined) {
		resetNewsCard=document.getElementById( currentNewsCard );
		resetNewsCard.style.display = "none";
		currentNewsCard=undefined;
	}
}

function exitNewsCard() {
	if (bloccaRiapertura == "0") {
		if (currentNewsCard !== undefined) {
			resetNewsCard=document.getElementById( currentNewsCard );
			new Effect.Shrink(resetNewsCard, {duration:0.9});
			new Effect.Fade("over", {duration:0.6, from: 0.7, to: 0.0, fps:90});
			currentNewsCard=undefined;
		}
	}
}


//************************************************** Effetti

//apertura nuova pagina utente con Morph (da finire)

function morphRightBox() {
new Effect.Morph('userPageframe', {style:'width:100%; height:1000px; background-color: #ff0000;', duration:3.3, transition:Effect.Transitions.slowstop, fps:90});
}


//rollover menuBar

function menuOver(menuID) {
}

function menuOut(menuID) {
}


//************************************************** Immagini e Filmati


function rollOverImg(imgId) {
}

function rollOutImg(imgId) {
}




function direct_popupMovie(elem) {
	var newSrc = elem.src.replace("media/movies_img","media/movies");
	var newSrc = newSrc.replace("chips33escape.png","");
	myLightWindow.activateWindow({
	width:740,
	height:280,
	href:newSrc,
	title: elem.id,
	author: "",
	caption: elem.title});	
}

function direct_popupFlash(elem) {
	var newSrc = elem.src.replace("media/flash_img","media/flash");
	var newSrc = newSrc.replace("chips33escape.png","");
	myLightWindow.activateWindow({
	width:740,
	height:280,
	href:newSrc,
	title: elem.id,
	author: "",
	caption: elem.title});	
}



/*
function popupYouTube(elem) {
	if (BrowserDetect.browser !== "Firefox") {
		myLightWindow.activateWindow({
		width:425,
		height:344,
		href: "http://www.youtube.com/v/"+elem.alt,
		title: "",
		author: "",
		caption: elem.title});
	} else {
		var winl = (screen.width - 424) / 2;
		var wint = (screen.height - 344) / 2;
		var newwindow = window.open('http://www.youtube.com/v/'+elem.alt, elem.title, 'width=424,height=344,top='+wint+',left='+winl+',scrollbars=no, status=no');
	}
}
*/




function popupImmagine(elem) {
if (((BrowserDetect.browser == "Explorer") && (BrowserDetect.version <= "10")) || ((BrowserDetect.browser == "Safari") && (BrowserDetect.version <= "312.8"))) {
	popupImmagineIE(elem);
	} else {
  		Lightview.show({
    	href: elem.src,
    	rel: 'image',
    	title: '',
    	caption: elem.title,
    		options: {
				autosize: true,
				topclose: true
    		}
  		});
  	}
}

var w_2 = null;
function popupImmagineIE(foto1) {

	var foto1 = foto1.src;
	
	if (w_2 != null && w_2.open) w_2.close();
	
	w_2 = window.open("", "popup", "width=200px,height=200px,top=0px,left=0px,resizable=yes,scrollbars=no");
	d = w_2.document;
	d.writeln("<h"+"tml>");
	d.writeln("<h"+"ead>");
	d.writeln("<t"+"itle>" + foto1 + "</t"+"itle>");
	d.writeln( "<scrip" + "t language='javascript' type='text/javascript'>function ridimensiona(){window.setTimeout(function() {onsetTimeoutRidimensiona();}, 300);}function onsetTimeoutRidimensiona(){var foto1 = document.getElementById('im1');var maxW = screen.width - 70;var maxH = screen.height - 100;var fattoreW, fattoreH, oldW, oldH, newW, newH;oldW = foto1.width;oldH = foto1.height;fattoreW = maxW / oldW;fattoreH = maxH / oldH;if(fattoreW >= fattoreH){ newW = oldW * fattoreH; newH = oldH * fattoreH; } else { newW = oldW * fattoreW; newH = oldH * fattoreW; } if(newW < foto1.width) {foto1.width = newW;} var w, h;if (self.innerHeight) /* all except Explorer */{w = self.innerWidth;h = self.innerHeight;}else if (document.documentElement && document.documentElement.clientHeight)/*Explorer 6 Strict Mode*/{w = document.documentElement.clientWidth;h = document.documentElement.clientHeight;}else if (document.body) /* other Explorers*/{w = document.body.clientWidth;h = document.body.clientHeight;}window.resizeBy(foto1.width - w, foto1.height - h); } </scrip" + "t>");
	d.writeln( "</h"+"ead>" );
	d.writeln( "<b"+"ody topmargin='0' leftmargin='0' scroll='no' style='margin:0;overflow: hidden'>" );
	d.writeln( "<img alt='' src='" + foto1 + "' id='im1' onload='ridimensiona()' />" ) ;
	d.writeln( "</b"+"ody>" );
	d.writeln( "</h"+"tml>" );
	d.close();
	w_2.focus();
}

function window_onunload() 
{
    if (w_2 != null && w_2.open) w_2.close(); 
}


function  impostaGruppo(curr_gr) {
	hs_gruppo_corrente = curr_gr;
	//alert(curr_gr);
}


function popupYouTube(elem) {

/*
if (((BrowserDetect.browser == "Explorer") && (BrowserDetect.version <= "6")) || ((BrowserDetect.browser == "Safari") && (BrowserDetect.version <= "312.8"))) {
	popupYouTubeIE(elem);
	} else {
	
	if (temaCorrente == "risImagem") {
		top.popupYouTube(elem);
		return false;
	}

		Lightview.show({
		href: 'http://www.youtube.com/v/'+elem.alt,
		rel: 'iframe',
		title: '',
		caption: elem.title,
			options: {
				autosize: true,
				topclose: true
			}
		});
		
	}
*/

	var returnValue;
	
	hs.outlineType = 'rounded-white';
	
	// Safari Mobile doesn't have Flash, so we just let the device use the built-in 
	// YouTube viewer.
	
	if (/(iPhone|iPod|iPad)/.test(navigator.userAgent)) {
		elem.href = opener.href.replace('/v/', '/watch?v=');
		returnValue = true;		
	}

	else {
		var tmId = new Date(); 
		var nuovoID = (tmId.valueOf());
	
		var nuovaPopUp = document.createElement("div");
		var now = '<div class="highslide-html-content" id="highslide-html-videoBox_'+nuovoID+'" style="display:none";><div class="highslide-move" style="position:absolute; top:0px; width:90%; height:26px; z-index:1000000;"></div><div class="highslide-header"><span class="header_VideoBox">'+elem.title+'</span><ul><li class="highslide-close"><a href="#" onclick="return hs.close(this)"></a></li></ul></div><div class="highslide-body_serv_message" id="body_serv_message"><object style="width:100%; height:97%" id="FilmObj_'+nuovoID+'"><param name="movie" id="FilmParamMovie_'+nuovoID+'" value="http://www.youtube.com/v/'+elem.alt+'?version=2&rel=0&autoplay=1&loop=0&border=0&color1=0xb1b1b1&color2=0xcfcfcf&fs=1&hd=1&showsearch=0&showinfo=0&iv_load_policy=3&feature=player_embedded" /><param name="allowFullScreen" value="false" /><param name="allowScriptAccess" value="always" /><param name="wmode" value="opaque" /><embed id="FilmEmb_'+nuovoID+'" src="http://www.youtube.com/v/'+elem.alt+'?version=2&rel=0&autoplay=1&loop=0&border=0&color1=0xb1b1b1&color2=0xcfcfcf&fs=1&hd=1&showsearch=0&showinfo=0&iv_load_policy=3&feature=player_embedded" type="application/x-shockwave-flash" allowfullscreen="false" allowScriptAccess="always" wmode="opaque" style="width:100%; height:400px" /></object></div><div class="highslide-footer"><span class="highslide-resize" title="Resize"><span></span></span></div></div>';
		
		nuovaPopUp.innerHTML = now;
		$('messages_Box').innerHTML = '';
		$('messages_Box').appendChild(nuovaPopUp);
		
		//hs.dimmingOpacity = hs_video_dimming;
		//hs.dimmingDuration = 300;
		
		var timerExpand = window.setTimeout("hs.htmlExpand(null, { contentId: 'highslide-html-videoBox_"+nuovoID+"', width: "+hs_video_w+", height: "+hs_video_h+", outlineType: '"+hs_custom+"' } );", 50);
		
		
		/*
		returnValue = hs.htmlExpand(null, {
		contentId: 'highslide-html-videoBox_',
		objectType: 'swf', 
		objectWidth: 480, 
		objectHeight: 385, 
		width: 480, 
		swfOptions: { 
			params: { 
				allowfullscreen: 'true' 
			}
		}, 
		maincontentText: '' 
	});
	*/
	
	return returnValue;
	}

}



function popupVimeo(elem) {
/*
if (((BrowserDetect.browser == "Explorer") && (BrowserDetect.version <= "6")) || ((BrowserDetect.browser == "Safari") && (BrowserDetect.version <= "312.8"))) {
	popupYouTubeIE(elem);
	} else {
	
	if (temaCorrente == "risImagem") {
		top.popupYouTube(elem);
		return false;
	}

		Lightview.show({
		href: 'http://www.youtube.com/v/'+elem.alt,
		rel: 'iframe',
		title: '',
		caption: elem.title,
			options: {
				autosize: true,
				topclose: true
			}
		});
		
	}
*/

	var returnValue;
	
	hs.outlineType = 'rounded-white';
	
	// Safari Mobile doesn't have Flash, so we just let the device use the built-in 
	// YouTube viewer.
	
	if (/(iPhone|iPod|iPad)/.test(navigator.userAgent)) {
		elem.href = opener.href.replace('/v/', '/watch?v=');
		returnValue = true;		
	}

	else {
		var tmId = new Date(); 
		var nuovoID = (tmId.valueOf());
	
		var nuovaPopUp = document.createElement("div");
		var now = '<div class="highslide-html-content" id="highslide-html-videoBox_'+nuovoID+'" style="display:none";><div class="highslide-move" style="position:absolute; top:0px; width:90%; height:26px; z-index:1000000;"></div><div class="highslide-header"><span class="header_VideoBox">'+elem.title+'</span><ul><li class="highslide-close"><a href="#" onclick="return hs.close(this)"></a></li></ul></div><div class="highslide-body_serv_message" id="body_serv_message"><object style="width:100%; height:97%;" id="FilmObj_'+nuovoID+'"><param name="movie" id="FilmParamMovie_'+nuovoID+'" value="http://vimeo.com/moogaloop.swf?clip_id='+elem.alt+'&amp;server=vimeo.com&amp;autoplay=1&amp;loop=0&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=0" /><param name="allowFullScreen" value="false" /><param name="allowScriptAccess" value="always" /><param name="wmode" value="opaque" /><embed id="FilmEmb_'+nuovoID+'" src="http://vimeo.com/moogaloop.swf?clip_id='+elem.alt+'&amp;server=vimeo.com&amp;autoplay=1&amp;loop=0&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=0" type="application/x-shockwave-flash" type="application/x-shockwave-flash" allowfullscreen="false" allowScriptAccess="always" wmode="opaque" style="width:100%; height:400px;" /></object></div><div class="highslide-footer"><span class="highslide-resize" title="Resize"><span></span></span></div></div>';
		
		nuovaPopUp.innerHTML = now;
		$('messages_Box').innerHTML = '';
		$('messages_Box').appendChild(nuovaPopUp);
		
		//hs.dimmingOpacity = hs_video_dimming;
		//hs.dimmingDuration = 300;
		
		var timerExpand = window.setTimeout("hs.htmlExpand(null, { contentId: 'highslide-html-videoBox_"+nuovoID+"', width: "+hs_video_w+", height: "+hs_video_h+", outlineType: '"+hs_custom+"' } );", 50);
		
		
		/*
		returnValue = hs.htmlExpand(null, {
		contentId: 'highslide-html-videoBox_',
		objectType: 'swf', 
		objectWidth: 480, 
		objectHeight: 385, 
		width: 480, 
		swfOptions: { 
			params: { 
				allowfullscreen: 'true' 
			}
		}, 
		maincontentText: '' 
	});
	*/
	
	return returnValue;
	}
}


function popupYouTubeIE(video1) {

if (temaCorrente == "risImagem") {
	top.popupYouTubeIE(video1);
	return false;
}

	var videoTitle = video1.alt;
	var video1 = video1.alt;
	
	var winl = (screen.width - 850) / 2;
	var wint = (screen.height - 500) / 2;
	
	if (w_2 != null && w_2.open) w_2.close();
	
	w_2 = window.open("", "popup", "width=850px,height=500px,top="+wint+",left="+winl+",resizable=0,scrollbars=no");
	d = w_2.document;
	d.writeln("<h"+"tml>");
	d.writeln("<h"+"ead>");
	d.writeln("<t"+"itle>" + videoTitle + "</t"+"itle>");
	d.writeln( "<scrip" + "t language='javascript' type='text/javascript'>function indirizzo() {location.href='http://www.youtube.com/v/"+video1+"';}</scrip" + "t>");
	d.writeln( "</h"+"ead>" );
	d.writeln( "<b"+"ody topmargin='0' leftmargin='0' scroll='no' style='margin:0;overflow: hidden' onload='indirizzo()'>" );
	d.writeln( "</b"+"ody>" );
	d.writeln( "</h"+"tml>" );
	d.close();
	w_2.focus();
}


function popupImmagineP(elem, idImg) {
	hs.slideshowGroup='nessuno';
	/*
	hs.Expander.prototype.onAfterClose = function (sender) {
		//return alert(sender);
	}
	*/
	if (idImg != undefined) {
	

	var newOverlay = document.createElement("div");
	newOverlay.innerHTML = '<div class="closebutton" id="close_hs_'+idImg+'" onclick="return hs.close(this)" title="Close"></div>';
	newOverlay.setAttribute("id","overlay_"+idImg);
	newOverlay.setAttribute("style","display:none");
	document.getElementById("hsOverlay_Box").appendChild(newOverlay);
	
	hs.registerOverlay({
		thumbnailId: idImg,
		overlayId: 'overlay_'+idImg,
		//html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>',
		position: 'top right',
		fade: 2 // fading the semi-transparent overlay looks bad in IE
	});
	
	} else {
	if (prev == 'demo_chips') {
		alert('verifica per utilizzo funzione');
	}
	hs.registerOverlay({
		thumbnailId: null,
		html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>',
		position: 'top right',
		fade: 2 // fading the semi-transparent overlay looks bad in IE
	});
	}
	hs.outlineType = null;
    hs.showCredits = false;
	hs.wrapperClassName = 'borderless';
	return hs.expand(elem);
}

function hs_Overlay(elem, idImg) {
	if (idImg != undefined) {
	
	var newOverlay = document.createElement("div");
	newOverlay.innerHTML = '<div class="closebutton" id="close_hs_'+idImg+'" onclick="return hs.close(this)" title="Close"></div>';
	newOverlay.setAttribute("id","overlay_"+idImg);
	newOverlay.setAttribute("style","display:none");
	document.getElementById("hsOverlay_Box").appendChild(newOverlay);
	
	hs.registerOverlay({
		thumbnailId: idImg,
		overlayId: 'overlay_'+idImg,
		//html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>',
		position: 'top right',
		fade: 2 // fading the semi-transparent overlay looks bad in IE
	});
	
	}
}	

/*
function popupImmagineGallery(elem, did) { // controllare perché questa va su IE (ma solo all'inizio...)
	
	//var w_Natural = window.galleryframe.$('contSlideShow').naturalWidth;
	//var h_Natural = window.galleryframe.$('contSlideShow').naturalHeight;
	var w_SlideShow = window.galleryframe.$('show').getWidth();
	var h_SlideShow = window.galleryframe.$('show').getHeight();
	//alert(w_Natural);
	//var myImage = new Image();
	//myImage.name = "someimg.jpg";
	//myImage.onload = getWidthAndHeight;
	//myImage.onerror = loadFailure;
	//myImage.src = elem;
	//highslide-wrapper-0
	//function getWidthAndHeight() {
    //alert("'" + myImage.name + "' is " + myImage.width + " by " + myImage.naturalHeight + " pixels in size.");
    //return true;
	//}
	//function loadFailure() {
    //alert("'" + this.name + "' failed to load.");
    //return true;
	//}
	
	if (did == true) {
		hs.captionEval = 'this.a.title';
		hs.captionOverlay.position = 'top left';
	} else {
		hs.captionEval = false;
	}
	hs.registerOverlay({
		html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>',
		position: 'top right',
		fade: 2 // fading the semi-transparent overlay looks bad in IE
	});
	//hs.wrapperClassName = 'draggable-header';
    hs.showCredits = false;
	hs.wrapperClassName = 'borderless';
	//alert(window.galleryframe.$('show').getWidth());
	
	var obj = $('galleryframe');
	var curleft = curtop = 0, ele = obj;
	do{ curleft += ele.offsetLeft;
		curtop += ele.offsetTop;
	} while (ele = ele.offsetParent);
	//return [curleft,curtop];
	//alert(curleft);
    
    document.getElementById("rifThumbG").style.top = curtop +'px';
	document.getElementById("rifThumbG").style.left = curleft +'px';
	document.getElementById("rifThumbG").style.width = w_SlideShow +'px';
	document.getElementById("rifThumbG").style.height = h_SlideShow +'px';
    
	var targetThumb = document.getElementById("rifThumbG").id;
	return hs.expand(elem, { thumbnailId: targetThumb });
}
*/

function popupImmagineGallery(elem, did, w_start, h_start) {
	
	//var w_Natural = window.galleryframe.$('contSlideShow').naturalWidth;
	//var h_Natural = window.galleryframe.$('contSlideShow').naturalHeight;
	var w_SlideShow = window.galleryframe.$('show').getWidth();
	var h_SlideShow = window.galleryframe.$('show').getHeight();
	//alert(w_Natural);
	//var myImage = new Image();
	//myImage.name = "someimg.jpg";
	//myImage.onload = getWidthAndHeight;
	//myImage.onerror = loadFailure;
	//myImage.src = elem;
	//highslide-wrapper-0
	//function getWidthAndHeight() {
    //alert("'" + myImage.name + "' is " + myImage.width + " by " + myImage.naturalHeight + " pixels in size.");
    //return true;
	//}
	//function loadFailure() {
    //alert("'" + this.name + "' failed to load.");
    //return true;
	//}
	
	/*
	var myImage = new Image();
	myImage.name = "someimg.jpg";
	myImage.onload = getWidthAndHeight;
	myImage.onerror = loadFailure;
	myImage.src = elem;
	*/
	
	/*
	var newImg = new Image();
	newImg.src = elem;
	var h_elem = newImg.height;
	var w_elem = newImg.width;
	*/

	/*
	if ((w_Natural <= w_SlideShow) && (h_Natural <= h_SlideShow)) {
		return false;
	}
	*/
	if (did == true) {
		hs.captionEval = 'this.a.title';
		hs.captionOverlay.position = 'top left';
	} else {
		hs.captionEval = false;
	}
	/*hs.registerOverlay({
		html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>',
		position: 'top right',
		fade: 2
	});*/
	//hs.wrapperClassName = 'draggable-header';
    hs.showCredits = false;
	hs.wrapperClassName = 'borderless';
	//alert(window.galleryframe.$('show').getWidth());
	
	var obj = $('galleryframe');
	var curleft = curtop = 0, ele = obj;
	do{ curleft += ele.offsetLeft;
		curtop += ele.offsetTop;
	} while (ele = ele.offsetParent);
	//return [curleft,curtop];
	
	curleft = curleft + (w_SlideShow - w_start)/2;
	curtop = curtop + (h_SlideShow - h_start)/2;
    document.getElementById("rifThumbG").style.top = curtop +'px';
	document.getElementById("rifThumbG").style.left = curleft +'px';
	document.getElementById("rifThumbG").style.width = w_start +'px';
	document.getElementById("rifThumbG").style.height = h_start +'px';
    
    if (prev == 'dimorecollection.edit') {
		alert(elem);
	}
	var targetThumb = document.getElementById("rifThumbG").id;
	return hs.expand(elem, { thumbnailId: targetThumb });
}


/*
function OLD_popupIFrameP(elem,w_Pu,h_Pu) {
	if (h_Pu >= 750) {
		if (((BrowserDetect.browser == "Explorer") && (BrowserDetect.version <= "6")) || ((BrowserDetect.browser == "Safari") && (BrowserDetect.version <= "312.8")) || (screen.height <= 800)) {
			window.open(elem.href);
			return false;
		}
	}
	var l_PopUp;
	var a_PopUp;
	if (w_Pu !== undefined) { l_PopUp = w_Pu } else { l_PopUp = hs_iframe_w }
	if (h_Pu !== undefined) { a_PopUp = h_Pu } else { a_PopUp = hs_iframe_h }
	hs.registerOverlay({
		//html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>',
		//position: 'top right',
		//fade: 2, // fading the semi-transparent overlay looks bad in IE
		//useOnHtml: true
	});
	
	hs.dimmingOpacity = 0.5;
	hs.dimmingDuration = 300;
	
	var tmId = new Date(); 
	var nuovoID = (tmId.valueOf());
		
	//var nuovaPopUp = document.createElement("div");
	var nuovaPopUp = '<div class="highslide-html-content" id="highslide-html-popupInterna_" style="display:none";><div class="highslide-body" id="body_popupInterna"><iframe allowtransparency="true" class="" id="popupInternaframe" src="http://www.google.it" name="popupInternaframeN" frameborder="0" scrolling="no" style="visibility: visible;" onload="this.style.visibility = \'visible\';" width="'+l_PopUp+'" height="'+a_PopUp+'"></iframe></div></div>';
		
	//nuovaPopUp.innerHTML = now;
	
	//var timerExpand = window.setTimeout("hs.htmlExpand(null, { slideshowGroup:'nessuno', contentId: 'highslide-html-pdfUploadBox_"+nuovoID+"', width: 490, height: 380, outlineType: '"+hs_custom+"' } );", 50);
	
	var timerExpand = window.setTimeout("hs.htmlExpand(null, { slideshowGroup:'nessuno', contentId: 'highslide-html-popupInterna_"+nuovoID+"', width: 490, height: 380, outlineType: '"+hs_custom+"' } );", 50);
	
	//return hs.htmlExpand(null, { contentId: 'highslide-html-popupInterna_', width: 640, height: 480, outlineType: hs_custom } );
	
	//return hs.htmlExpand(elem, { contentId: 'highslide-html-popupInterna_', width: l_PopUp, height: a_PopUp, objectType: 'iframe', objectWidth: l_PopUp, objectHeight: a_PopUp, outlineType: hs_custom } );
}
*/

function popupIFrameP(elem,w_Pop,h_Pop) {
	if (h_Pop >= 750) {
		if (((BrowserDetect.browser == "Explorer") && (BrowserDetect.version <= "6")) || ((BrowserDetect.browser == "Safari") && (BrowserDetect.version <= "312.8")) || (screen.height <= 800)) {
			window.open(elem.href);
			return false;
		}
	}
	var l_PopUp;
	var a_PopUp;
	if (w_Pop !== undefined) { l_PopUp = w_Pop } else { l_PopUp = hs_iframe_w }
	if (h_Pop !== undefined) { a_PopUp = h_Pop } else { a_PopUp = hs_iframe_h }
	//alert(l_PopUp + '' + a_PopUp);
	var returnValue;
	
		hs.outlineType = hs_custom;
	
		var tmId = new Date(); 
		var nuovoID = (tmId.valueOf());
	
		var nuovaPopUp = document.createElement("div");
		var now = '<div class="highslide-html-content" id="highslide-html-popupInterna_'+nuovoID+'" style="display:none";><div class="highslide-move" style="position:absolute; top:0px; width:90%; height:26px; z-index:1000000;"></div><div class="highslide-header"><ul><li class="highslide-close"><a href="#" onclick="return hs.close(this)"></a></li></ul></div><div class="highslide-body_serv_message" id="body_serv_message"><iframe allowtransparency="true" class="" id="popupInternaframe" src="'+elem+'" name="popupInternaframeN" frameborder="0" scrolling="no" style="visibility: visible;" width="'+l_PopUp+'" height="'+a_PopUp+'"></iframe></div><div class="highslide-footer"><span class="highslide-resize" title="Resize"><span></span></span></div></div>';
		
		nuovaPopUp.innerHTML = now;
		$('messages_Box').innerHTML = '';
		$('messages_Box').appendChild(nuovaPopUp);
		
		hs.dimmingOpacity = hs_video_dimming;
		hs.dimmingDuration = 300;
		
		return hs.htmlExpand(null, { slideshowGroup:'nessuno', contentId: 'highslide-html-popupInterna_'+nuovoID, width: l_PopUp+50, height: a_PopUp+50, outlineType: hs_custom } );
		
		
		/*
		returnValue = hs.htmlExpand(null, {
		contentId: 'highslide-html-videoBox_',
		objectType: 'swf', 
		objectWidth: 480, 
		objectHeight: 385, 
		width: 480, 
		swfOptions: { 
			params: { 
				allowfullscreen: 'true' 
			}
		}, 
		maincontentText: '' 
	});
	*/
	
	return returnValue;
}	

/*
function popupIFrame(elem) {
if (((BrowserDetect.browser == "Explorer") && (BrowserDetect.version <= "6")) || ((BrowserDetect.browser == "Safari") && (BrowserDetect.version <= "312.8"))) {
	popupIFrameIE(elem);
	} else {
	
	if (temaCorrente == "risImagem") {
		top.popupIFrame(elem);
		return false;
	}
		Lightview.show({
		href: elem.alt,
		rel: 'iframe',
		title: '',
		//caption: elem.title,
			options: {
				autosize: true,
				topclose: false,
				width: 850,
        		height: 600,
        		scrolling: false,
        		closeButton: 'small'
			}
		});
	}
}
*/

function popupIFrameIE(video1) {

if (temaCorrente == "risImagem") {
	top.popupIFrameIE(video1);
	return false;
}
	
	var videoTitle = video1.alt;
	var video1 = video1.alt;
	
	var winl = (screen.width - 800) / 2;
	var wint = (screen.height - 600) / 2;
	
	if (w_2 != null && w_2.open) w_2.close();
	
	w_2 = window.open("", "popup", "width=800px,height=600px,top="+wint+",left="+winl+",resizable=0,scrollbars=no");
	d = w_2.document;
	d.writeln("<h"+"tml>");
	d.writeln("<h"+"ead>");
	d.writeln("<t"+"itle>" + videoTitle + "</t"+"itle>");
	d.writeln( "<scrip" + "t language='javascript' type='text/javascript'>function indirizzo() {location.href='"+video1+"';}</scrip" + "t>");
	d.writeln( "</h"+"ead>" );
	d.writeln( "<b"+"ody topmargin='0' leftmargin='0' scroll='no' style='margin:0;overflow: hidden' onload='indirizzo()'>" );
	d.writeln( "</b"+"ody>" );
	d.writeln( "</h"+"tml>" );
	d.close();
	w_2.focus();
}





function resetLogolocale(elem) {
	new Effect.Fade(elem, {duration:0.3});
}

function showLogoSerata(elem) {
var span1 = elem.id+"_span1";
var span2 = elem.id+"_span2";
new Effect.Morph(span1, {style:'margin-left:0px;', duration:0.3, transition:Effect.Transitions.slowstop, afterFinish: function() {
	new Effect.Morph(span2, {style:'margin-left:0px;', duration:0.6, transition:Effect.Transitions.slowstop});
	}
});
}

function hideLogoSerata(elem) {
var span1 = elem.id+"_span1";
var span2 = elem.id+"_span2";
//timerReset1 = window.setTimeout("resetLogolocale('"+span2+"');", 3000);
//timerReset2 = window.setTimeout("resetLogolocale('"+span1+"');", 4000);
//new Effect.Morph(LogoLocale, {style:'margin-left:0px;', duration:3.3, transition:Effect.Transitions.slowstop});
//document.getElementById(LogoLocale).style.margin = "0 0 0 0px";
}





/*
document.observe('lightview:loaded', function() {
  Lightview.show({
    href: '/ajax/',
    rel: 'ajax',
    title: 'Login',
    caption: 'Enter your username and password to login',
    options: {
      autosize: true,
      topclose: true,
      ajax: {
        method: 'get',
        evalScripts: true,
        onComplete: function(){ $('name').focus(); }
      }
    }
  });
});
*/




/***************************** AGGIORNAMENTO textarea contents per Forum ****************************/



// Sostituzione caratteri speciali per Area Paste

String.prototype.htmlEntita = function()
{
  var caratteri = new Array ('&','à','á','â','ã','ä','å','æ','ç','è','é',
                         'ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô',
                         'õ','ö','ø','ù','ú','û','ü','ý','þ','ÿ','À',
                         'Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë',
                         'Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö',
                         'Ø','Ù','Ú','Û','Ü','Ý','Þ','€','\"','ß','<',
                         '>','¢','£','¤','¥','¦','§','¨','©','ª','«',
                         '¬','­','®','¯','°','±','²','³','´','µ','¶',
                         '·','¸','¹','º','»','¼','½','¾');

  var entita = new Array ('amp','agrave','aacute','acirc','atilde','auml','aring',
                            'aelig','ccedil','egrave','eacute','ecirc','euml','igrave',
                            'iacute','icirc','iuml','eth','ntilde','ograve','oacute',
                            'ocirc','otilde','ouml','oslash','ugrave','uacute','ucirc',
                            'uuml','yacute','thorn','yuml','Agrave','Aacute','Acirc',
                            'Atilde','Auml','Aring','AElig','Ccedil','Egrave','Eacute',
                            'Ecirc','Euml','Igrave','Iacute','Icirc','Iuml','ETH','Ntilde',
                            'Ograve','Oacute','Ocirc','Otilde','Ouml','Oslash','Ugrave',
                            'Uacute','Ucirc','Uuml','Yacute','THORN','euro','quot','szlig',
                            'lt','gt','cent','pound','curren','yen','brvbar','sect','uml',
                            'copy','ordf','laquo','not','shy','reg','macr','deg','plusmn',
                            'sup2','sup3','acute','micro','para','middot','cedil','sup1',
                            'ordm','raquo','frac14','frac12','frac34');

  nuovaStringa = this;
  for (var i = 0; i < caratteri.length; i++)
  {
    nuovaRegExp = new RegExp();
    nuovaRegExp.compile(caratteri[i],'g')
    nuovaStringa = nuovaStringa.replace (nuovaRegExp, entita[i]);
  }
  return nuovaStringa;
}
// fine sostituzione caratteri speciali


/*
// inizio htmlEntities -> http://www.dieterraber.net/jsStringFuncs.htm
String.prototype.htmlEntities = function()
{
  var chars = new Array ('&','à','á','â','ã','ä','å','æ','ç','è','é',
                         'ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô',
                         'õ','ö','ø','ù','ú','û','ü','ý','þ','ÿ','À',
                         'Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë',
                         'Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö',
                         'Ø','Ù','Ú','Û','Ü','Ý','Þ','€','\"','ß','<',
                         '>','¢','£','¤','¥','¦','§','¨','©','ª','«',
                         '¬','­','®','¯','°','±','²','³','´','µ','¶',
                         '·','¸','¹','º','»','¼','½','¾');

  var entities = new Array ('amp','agrave','aacute','acirc','atilde','auml','aring',
                            'aelig','ccedil','egrave','eacute','ecirc','euml','igrave',
                            'iacute','icirc','iuml','eth','ntilde','ograve','oacute',
                            'ocirc','otilde','ouml','oslash','ugrave','uacute','ucirc',
                            'uuml','yacute','thorn','yuml','Agrave','Aacute','Acirc',
                            'Atilde','Auml','Aring','AElig','Ccedil','Egrave','Eacute',
                            'Ecirc','Euml','Igrave','Iacute','Icirc','Iuml','ETH','Ntilde',
                            'Ograve','Oacute','Ocirc','Otilde','Ouml','Oslash','Ugrave',
                            'Uacute','Ucirc','Uuml','Yacute','THORN','euro','quot','szlig',
                            'lt','gt','cent','pound','curren','yen','brvbar','sect','uml',
                            'copy','ordf','laquo','not','shy','reg','macr','deg','plusmn',
                            'sup2','sup3','acute','micro','para','middot','cedil','sup1',
                            'ordm','raquo','frac14','frac12','frac34');

  newString = this;
  for (var i = 0; i < chars.length; i++)
  {
    myRegExp = new RegExp();
    myRegExp.compile(chars[i],'g')
    newString = newString.replace (myRegExp, '&' + entities[i] + ';');
  }
  return newString;
}
// fine htmlEntities -> http://www.dieterraber.net/jsStringFuncs.htm
*/

// inizio htmlEntities_demo
String.prototype.htmlEntities_demo = function()
{
  var chars = new Array ('&','à','á','â','ã','ä','å','æ','ç','è','é',
                         'ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô',
                         'õ','ö','ø','ù','ú','û','ü','ý','þ','ÿ','À',
                         'Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë',
                         'Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö',
                         'Ø','Ù','Ú','Û','Ü','Ý','Þ','€','ß',
                         '¢','£','¤','¥','¦','§','¨','©','ª','«',
                         '¬','­','®','¯','°','±','²','³','´','µ','¶',
                         '·','¸','¹','º','»','¼','½','¾');

  var entities = new Array ('amp','agrave','aacute','acirc','atilde','auml','aring',
                            'aelig','ccedil','egrave','eacute','ecirc','euml','igrave',
                            'iacute','icirc','iuml','eth','ntilde','ograve','oacute',
                            'ocirc','otilde','ouml','oslash','ugrave','uacute','ucirc',
                            'uuml','yacute','thorn','yuml','Agrave','Aacute','Acirc',
                            'Atilde','Auml','Aring','AElig','Ccedil','Egrave','Eacute',
                            'Ecirc','Euml','Igrave','Iacute','Icirc','Iuml','ETH','Ntilde',
                            'Ograve','Oacute','Ocirc','Otilde','Ouml','Oslash','Ugrave',
                            'Uacute','Ucirc','Uuml','Yacute','THORN','euro','szlig',
                            'cent','pound','curren','yen','brvbar','sect','uml',
                            'copy','ordf','laquo','not','shy','reg','macr','deg','plusmn',
                            'sup2','sup3','acute','micro','para','middot','cedil','sup1',
                            'ordm','raquo','frac14','frac12','frac34');

  newString = this;
  for (var i = 0; i < chars.length; i++)
  {
    myRegExp = new RegExp();
    myRegExp.compile(chars[i],'g')
    newString = newString.replace (myRegExp, '&' + entities[i] + ';');
  }
  //alert(newString);
  return newString;
}
// fine htmlEntities_demo



// calcolo KB per demo
var utf8 = {}

utf8.toByteArray = function(str) {
    var byteArray = [];
    for (var i = 0; i < str.length; i++)
        if (str.charCodeAt(i) <= 0x7F)
            byteArray.push(str.charCodeAt(i));
        else {
            var h = encodeURIComponent(str.charAt(i)).substr(1).split('%');
            for (var j = 0; j < h.length; j++)
                byteArray.push(parseInt(h[j], 16));
        }
    return byteArray;
};

utf8.parse = function(byteArray) {
    var str = '';
    for (var i = 0; i < byteArray.length; i++)
        str +=  byteArray[i] <= 0x7F?
                byteArray[i] === 0x25 ? "%25" : // %
                String.fromCharCode(byteArray[i]) :
                "%" + byteArray[i].toString(16).toUpperCase();
    return decodeURIComponent(str);
};
// fine calcolo KB


function showpreviewForum(){

	var contenuto_div=document.getElementById("contentsbis").innerHTML;
	contenuto_div=contenuto_div.replace("\\'","\'");
	// testo da modificare 
	var testo=contenuto_div; 
	// stringa da sostituire 
	var parola="_overflow=\"null\""; 
	// stringa che prende il posto di quella da sostituire 
	var sostituzione=""; 
	// espressione regolare per cercare tutte le occorrenze della stringa 
	// da sostituire in maniera case insensitive 
	var espressione=new RegExp(parola,"gi"); 
	// risultato contiene la sostituzione 
	var contenuto_div=testo.replace(espressione, sostituzione);
	
	contenuto_div=contenuto_div.replace(/&amp;/g,"%26");
	contenuto_div=contenuto_div.replace(/\+/g,"%2B");
	contenuto_div=contenuto_div.replace(/&lt;/g,"CHIPSCODIFICASPECIALCHAR_OPEN");
	contenuto_div=contenuto_div.replace(/&gt;/g,"%3E");
	contenuto_div = contenuto_div.replace(/\u00a0/g, ' ');
	
	
	
	
	/*
	var htmlDIV = document.createElement("DIV");
	htmlDIV.innerHTML = html;
	if (htmlDIV.innerText) {
	return htmlDIV.innerText; // Internet Explorer
	}
	return htmlDIV.textContent; // Mozilla Firefox
	*/
	
	/*
	var contenuto_BlogPost = document.getElementById("BlogPostCont");
	if (contenuto_BlogPost.innerText) {
	contenuto_BlogPost = contenuto_BlogPost.innerText; // Internet Explorer
	} else {
	contenuto_BlogPost = contenuto_BlogPost.textContent; // Mozilla Firefox
	}
	
	alert(contenuto_BlogPost);
	*/
	//contenuto_BlogPost = contenuto_BlogPost.htmlEntities();
	
	
	
	document.getElementById("campo_contentsForum").value=contenuto_div;
	
}





/*************************************** Nuovo Articolo Forum ***************************************/


var idSelezPerPaste = "";


function id4paste(elem){
	document.getElementById("campo_controlFormat").value = elem.id;
	idSelezPerPaste = elem;
}


function insertAtCursor(myField, myValue) {
  //IE support
  if (document.selection) {
    myField.focus();
    sel = document.selection.createRange();
    sel.text = myValue;
  }
  //MOZILLA/NETSCAPE support
  else if (myField.selectionStart || myField.selectionStart == '0') {
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    myField.value = myField.value.substring(0, startPos)
                  + myValue 
                  + myField.value.substring(endPos, myField.value.length);
  } else {
    myField.value += myValue;
  }
}







var nuovoinserimento = "";
var range = "";
var selettoreILDN = "0";
var selettoreILDN_schede = "0";


function onPaste(event){
	
	var destinazione = $("campo_controlFormat").value;
	
	$$('#'+destinazione+' font[size="1"]').each(function(element) {
		element.removeAttribute('class');
		element.removeAttribute('size');
	})
	$$('#'+destinazione+' span[style="font-size: 1px;"]').each(function(element) {
		element.removeAttribute('style');
	})
	
	if (selettoreILDN == "1") {
		document.getElementById("indirizzo").innerHTML = document.getElementById("inputIndirizzoLocale").value;
		var valoriImmessi = document.getElementById("indirizzo").innerHTML;
		var parola = "<[^>]*>"; 
		var sostituzione = ""; 
		var espressione = new RegExp(parola,"gi"); 
		var valoriImmessi = valoriImmessi.replace(espressione, sostituzione);
		return false;
	}
	if (selettoreILDN == "2") {
		document.getElementById("TelefonoLocale").innerHTML = document.getElementById("inputTelefonoLocale").value;
		var valoriImmessi = document.getElementById("TelefonoLocale").innerHTML;
		var parola = "<[^>]*>"; 
		var sostituzione = ""; 
		var espressione = new RegExp(parola,"gi"); 
		var valoriImmessi = valoriImmessi.replace(espressione, sostituzione);
		return false;
	}
	if (selettoreILDN == "3") {
		document.getElementById("EmailLocale").innerHTML = document.getElementById("inputEmailLocale").value;
		var valoriImmessi = document.getElementById("EmailLocale").innerHTML;
		var parola = "<[^>]*>"; 
		var sostituzione = ""; 
		var espressione = new RegExp(parola,"gi"); 
		var valoriImmessi = valoriImmessi.replace(espressione, sostituzione);
		return false;
	}
	if (selettoreILDN == "4") {
		document.getElementById("SitoLocale").innerHTML = document.getElementById("inputSitoLocale").value;
		var valoriImmessi = document.getElementById("SitoLocale").innerHTML;
		var parola = "<[^>]*>"; 
		var sostituzione = ""; 
		var espressione = new RegExp(parola,"gi"); 
		var valoriImmessi = valoriImmessi.replace(espressione, sostituzione);
		return false;
	}
	
	var insertion = document.createElement("text");
	//insertion.setAttribute("id","Topic");
	//IE support
  	if (document.selection) {
		insertAtCursor(document.getElementById('BlogPostCont'), 'this value');
		//alert(document.getElementById('BlogPostCont').innerHTML);
	return false;
	} else {
	var selection = window.getSelection();
	var range = selection.getRangeAt(0);
	
	//alert(range.startOffset);
	//alert(range.endOffset);
	//alert(selection.anchorOffset);
	//alert(selection.rangeCount);
	
	range.deleteContents();
	}
		/*if (insertion.innerHTML != "undefined") {
			event.preventDefault();
			range.insertNode(insertion);
		} else {*/
		var areaPaste = document.getElementById('areaPaste');
		areaPaste.innerHTML = "";
		
		// posiziona il div areaPaste per evitare lo scroll di pagina
		areaPaste.style.top = window.pageYOffset + "px";
		if (document.getElementById('over').style.opacity == "0.7") {
		document.getElementById('over').style.opacity = "0.1";
		document.getElementById('over').style.display = "none";
		}
		areaPaste.focus();
		
		setTimeout(function() {
			//idSelezPerPaste.focus();
			//areaPaste.focus();
			//document.execCommand("removeformat", false, null);
			
			// toglie l'ultimo fine riga ////////////// problema con Safari 4 da controllare
			var ultimoBR = areaPaste.innerHTML.lastIndexOf("<br></span>");
			if (ultimoBR != -1) {
			areaPaste.innerHTML = (areaPaste.innerHTML.slice(0,ultimoBR));
			}
			
			if (areaPaste.innerText) {
				//alert(areaPaste.innerHTML);
				insertion.innerHTML = areaPaste.innerText; // Safari
				} else {
				insertion.innerHTML = areaPaste.textContent; // IE ?
				//document.execCommand("paste", false, null);
			}
			//alert(areaPaste.innerHTML);
			insertion.innerHTML = insertion.innerHTML.replace(/\n/g,"<br/>");
			insertion.innerHTML = insertion.innerHTML.replace(/&nbsp;/g," ");
			//alert(insertion.innerHTML);
			
			// Incolla Tabella
			if (document.tableForm.tablePaste.checked == true) {
				var ArrayNuovaTabella = new Array();
				var ricercaElem = areaPaste;
				var Righe = ricercaElem.getElementsByTagName("tr");
				for (var i = 0; i < Righe.length; i++) {
					var ArrayNuovaRiga = new Array();
					ArrayNuovaTabella.push(ArrayNuovaRiga);
					var Celle = Righe[i].getElementsByTagName("td");
					for (var c = 0; c < Celle.length; c++) {
						ArrayNuovaTabella[i].push(Celle[c].innerText);
					}
		
				}
				
				if (Righe.length >= 1) {
				var nRighe = Righe.length;
				var nColonne = ArrayNuovaTabella[0].length;
				var controlloPaste = "1";
				} else {
				alert("I dati che vuoi incollare non contengono nessun elemento di tabella!");
				return false;
				}
				create_Table(controlloPaste,nRighe,nColonne,ArrayNuovaTabella);
				if (document.getElementById('over').style.opacity == "0.1") {
					document.getElementById('over').style.opacity = "0.7";
					document.getElementById('over').style.display = "block";
				}
			} else {
			
				//insertion.innerHTML = insertion.innerHTML.htmlEntita();
				
				if ((insertion.innerHTML.indexOf("<object") != -1) || (insertion.innerHTML.indexOf("<param") != -1) || (insertion.innerHTML.indexOf("<script") != -1)){
					alert("Attenzione!\nStai cercando di incollare caratteri non permessi, come '<' o '>'.");
					return false;
				}
				
				insertion.innerHTML = insertion.innerHTML + '<span id="cursorStart" style"font-size: 0px">|</span>';
				range.insertNode(insertion);
				//$(destinazione).focus();
				var new_selection = window.getSelection();
				var new_range = new_selection.getRangeAt(0);
				//alert(new_selection.baseNode);
				//alert(new_selection.baseOffset);
				//alert(new_selection.extentNode);
				//alert(new_selection.extentOffset);
				//new_selection.collpaseToEnd( );
				//alert(new_selection.anchorOffset);
				new_selection.collapse( $(destinazione), 1 );
				
				//new_selection.focusNode;
				//alert(new_selection.anchorOffset);
				
				/*
				if (document.getElementById('over').style.opacity == "0.1") {
					document.getElementById('over').style.opacity = "0.7";
					document.getElementById('over').style.display = "block";
				}
				*/
				
			
			}
			
			
     
     	}, 30); // 1ms should be enough
     
		//}
		
		
		
		
}




/*
function preformatt(){
	document.getElementById('areaPaste').focus();
	document.execCommand("removeformat", false, null);
}


function postprod(){
	var div_selez = document.getElementById("campo_controlFormat").value;
	var testo_incollato = document.createElement("div");
	document.getElementById('areaPaste').focus();
	document.execCommand("removeformat", false, null);
	testo_incollato.innerHTML = document.getElementById('areaPaste').innerHTML;
	
	var pattern = /<div(.*?)>/gi;
	var stringa = '<div>';
	testo_incollato.innerHTML = testo_incollato.innerHTML.replace(pattern,stringa);
	
	var pattern = /<span(.*?)>/gi;
	var stringa = '<span>';
	testo_incollato.innerHTML = testo_incollato.innerHTML.replace(pattern,stringa);
	
	testo_incollato.setAttribute("style","font-size:smaller;");
	document.getElementById(div_selez).appendChild(testo_incollato);
	chiudi_pasteWind();
}


function chiudi_pasteWind(){
	new Effect.Fade('areaPaste', {duration:0.3, afterFinish: function() {
	$('areaPaste').style.top = "-5000px";
	}
	});
}


function ExtPasteFunction(){
	//document.getElementById('campetto').focus();
	//document.getElementById('areaPaste').focus();
	//document.execCommand("removeformat", false, null);
	//alert("incollato");
}        



function onCopy(event){
	if ((BrowserDetect.browser == "Safari") && (BrowserDetect.OS == "Mac")) {
		var selection = window.getSelection(); 
		event.clipboardData.setData("text/html", selection);
		event.preventDefault();
	}
} 

function onCut(event){ 
	if ((BrowserDetect.browser == "Safari") && (BrowserDetect.OS == "Mac")) {
		var selection = window.getSelection(); 
		event.clipboardData.setData("text/html", selection); 
		var range = selection.getRangeAt(0); 
		range.extractContents();
		event.preventDefault();
	}
}

*/


var nuovoWrapTextBoxForum = "";
var NuovoPostDaInviare = "";
var nuovoForumID = "";


function createArticolo(){
	
	if ((BrowserDetect.browser == "Explorer") && (BrowserDetect.version <= "6")) {
		alert("Per pubblicare un articolo è necessario Internet Explorer 7 o superiore.");
		return false;
	}
	
	if (document.getElementById("BlogPublish")) {
		alert("Post precedente non ancora pubblicato!");
		return false;
	}
	if (document.getElementById("BlogNameCont").innerHTML == "") {
		alert("Campo Nome vuoto!");
		return false;
	}
	if (document.getElementById("BlogTitleCont").innerHTML == "") {
		alert("Campo Titolo vuoto!");
		return false;
	}
	if (document.getElementById("BlogPostCont").innerHTML == "") {
		alert("Campo Articolo vuoto!");
		return false;
	}
	
	
	var tmId = new Date(); 
	nuovoForumID = (tmId.valueOf());
	
	var nome = document.getElementById("BlogNameCont").innerHTML;
	var nuovaNota = nome+ " - chips_SegnapostoData";
	var titoloPost = document.getElementById("BlogTitleCont").innerHTML;
	var newPost = document.getElementById("BlogPostCont").innerHTML;
	
	nuovoWrapTextBoxForum = document.createElement("div");
	nuovoWrapTextBoxForum.setAttribute("class","chips_WrapTextBox");
	nuovoWrapTextBoxForum.setAttribute("id","WrapTextBox"+nuovoForumID);
	nuovoWrapTextBoxForum.style.display = "none";
	
	nuovoWrapTextBoxForum.innerHTML = '<div class="chips_HandleBoxText" id="Handle'+nuovoForumID+'"><div class="chips_removeButton" id="ButtonRemove'+nuovoForumID+'" onclick="rimozione(this.id)"></div></div><div class="chips_TextBox" id="TextBox'+nuovoForumID+'"><div class="chips_noteBlog" id="Nota'+nuovoForumID+'">'+nuovaNota+'</div><div class="chips_CapTitleBlog" id="TextTitle'+nuovoForumID+'">'+titoloPost+'</div><div class="chips_CapBlog" id="Text'+nuovoForumID+'">'+newPost+'</div></div>';
	
	document.getElementById("contentsbis").appendChild(nuovoWrapTextBoxForum);
	
	
	var nuovoBox = document.getElementById("TextBox"+nuovoForumID);
	var nuovoText = document.getElementById("Text"+nuovoForumID);
	
	//Se la stringa è più lunga di 500 caratteri
	if (newPost.length > 500) {
		var seguito = newPost.substr(250);
		cerca_spazio = seguito.indexOf(" ");
	
		var anteprima = newPost.substr(0,250+cerca_spazio);
		var resto_post = newPost.substr(251+cerca_spazio);
	
		nuovoText.innerHTML = anteprima+ '...';
		nuovoBox.appendChild(nuovoText);
	
		var nuovoWrapCardBox = document.createElement("div");
		nuovoWrapCardBox.setAttribute("class","chips_WrapCardBoxForum");
		nuovoWrapCardBox.setAttribute("id","WrapCardBox"+nuovoForumID);
		
		nuovoWrapCardBox.innerHTML = '<div class="chips_TextBox" id="CardBox'+nuovoForumID+'"></div></div><div class="chips_ArrowCard" id="Arrow'+nuovoForumID+'" onclick="openCard(\'Card'+nuovoForumID+'\')"><br>continua...</div><div class="chips_Card" id="Card'+nuovoForumID+'" style="display:none;overflow-x:hidden;overflow-y:hidden;"><div class="chips_CardText" id="CardText'+nuovoForumID+'">'+resto_post+'</div>'
		
		nuovoBox.appendChild(nuovoWrapCardBox);
	
	/*
		var nuovoCBox = document.createElement("div");
		nuovoCBox.setAttribute("class","chips_TextBox");
		nuovoCBox.setAttribute("id","CardBox"+nuovoForumID);	
		nuovoWrapCardBox.appendChild(nuovoCBox);
	
		var nuovaFreccia = document.createElement("div");
		nuovaFreccia.setAttribute("class","chips_ArrowCard");
		nuovaFreccia.setAttribute("id","Arrow"+nuovoForumID);
		//nuovoText.setAttribute("onmouseover", "highlightCard\("+"\'OpenCard"+parseInt(document.getElementById("contents").childNodes.length)+"'\)");
		nuovaFreccia.setAttribute("onclick", "openCard\("+"\'Card"+nuovoForumID+"'\)");
		now="<br />continua...";
		nuovaFreccia.innerHTML=now;
		nuovoBox.appendChild(nuovaFreccia);
	
		var nuovaCard = document.createElement("div");
		nuovaCard.setAttribute("class","chips_Card");
		nuovaCard.setAttribute("id","Card"+nuovoForumID);
		nuovaCard.setAttribute("style","display:none;overflow-x:hidden;overflow-y:hidden;");
		nuovoBox.appendChild(nuovaCard);
	
		var textCard = document.createElement("div");
		textCard.setAttribute("class","chips_CardText");
		textCard.setAttribute("id","CardText"+nuovoForumID);
		//textCard.setAttribute("onblur","chipsEdit\(this\)");
		now=resto_post;
		textCard.innerHTML=now;
		nuovaCard.appendChild(textCard);
		
	*/
	
	}


	var textCard = document.getElementById("CardText"+nuovoForumID);
	
	

	var rifUploadForum = document.getElementById('rifUploadForum').innerHTML;
	if (rifUploadForum != "") {
		var fileCaricato = document.createElement("div");
		fileCaricato.setAttribute("class","chips_ImgForumBox");
		fileCaricato.setAttribute("id","ImgForumBox"+nuovoForumID);
		now="<br><img class=\"chipsImgForum\" src=\"./page_contents/media/img/"+ rifUploadForum +"\">";
		fileCaricato.innerHTML=now;
	if (newPost.length > 500) {
		textCard.appendChild(fileCaricato);
	} else {
		nuovoText.appendChild(fileCaricato);
	}
	}
	
	
	
	nuovoWrapPulsantiBox = document.createElement("div");
	nuovoWrapPulsantiBox.setAttribute("class","chips_WrapPulsantiBox");
	nuovoWrapPulsantiBox.setAttribute("id","chips_WrapPulsantiBox"+nuovoForumID);
	nuovoWrapPulsantiBox.innerHTML = '<div class="chips_BlogPublish" id="BlogPublish" onclick="registraForum()">Pubblica</div><div class="chips_BlogAnnulla" id="BlogAnnulla" onclick="window.location.reload()">Annulla</div>';
	nuovoBox.appendChild(nuovoWrapPulsantiBox);
	
	
	
	/*
	var nuovoBlogPublish = document.createElement("div");
	nuovoBlogPublish.setAttribute("class","chips_BlogPublish");
	nuovoBlogPublish.setAttribute("id","BlogPublish");	
	nuovoBlogPublish.setAttribute("onclick","registraForum\(\)");
	now="<div>Pubblica</div>";
	nuovoBlogPublish.innerHTML=now;
	nuovoBox.appendChild(nuovoBlogPublish);
	
	var nuovoBlogAnnulla = document.createElement("div");
	nuovoBlogAnnulla.setAttribute("class","chips_BlogAnnulla");
	nuovoBlogAnnulla.setAttribute("id","BlogAnnulla");	
	nuovoBlogAnnulla.setAttribute("onclick","window.location.reload\(\)");
	now="<div>Annulla</div>";
	nuovoBlogAnnulla.innerHTML=now;
	nuovoBox.appendChild(nuovoBlogAnnulla);
	*/
	
	// scroll della pagina se esiste un paragrafo precedente 
	//if (document.getElementById("WrapTextBox"+nuovoForumID).previousSibling) {
	
	var primo_paragrafo = document.getElementById("contentsbis").firstChild;
	document.getElementById("contentsbis").insertBefore(nuovoWrapTextBoxForum,primo_paragrafo);
	var nAnchor = document.getElementById("WrapTextBox"+nuovoForumID);
	document.getElementById('rifUploadForum').innerHTML = "";
	var Nota = document.getElementById('Nota'+nuovoForumID);
	Nota.innerHTML = Nota.innerHTML.replace("chips_SegnapostoData",dataEora);
	if (prev == 'demo_chips') {
	//alert(dataEora);
	}
	
	//alert(nuovoWrapTextBoxForum.innerHTML);
	
	
	new Effect.ScrollTo(nAnchor,{offset: -29, afterFinish: function() {
		document.getElementById("BlogNameCont").innerHTML = "";
		document.getElementById("BlogTitleCont").innerHTML = "";
		document.getElementById("BlogPostCont").innerHTML = "";
		new Effect.BlindDown(nuovoWrapTextBoxForum, { duration:1.1 });
		}
	});	
}






/*


function createArticolo(){
	
	if ((BrowserDetect.browser == "Explorer") && (BrowserDetect.version <= "5")) {
		alert("La pagina Forum e' ancora in fase sperimentale.\nSi prega di provarla usando Firefox v 3.0.6 o Safari 3.0.1 o superiori.");
		return false;
	}
	
	if (document.getElementById("BlogPublish")) {
		alert("Post precedente non ancora pubblicato!");
		return false;
	}
	if (document.getElementById("BlogNameCont").innerHTML == "") {
		alert("Campo Nome vuoto!");
		return false;
	}
	if (document.getElementById("BlogTitleCont").innerHTML == "") {
		alert("Campo Titolo vuoto!");
		return false;
	}
	if (document.getElementById("BlogPostCont").innerHTML == "") {
		alert("Campo Articolo vuoto!");
		return false;
	}
	
	
	var tmId = new Date(); 
	var nuovoForumID = (tmId.valueOf());
	
	var nuovoWrapTextBoxForum = document.createElement("div");
	nuovoWrapTextBoxForum.setAttribute("class","chips_WrapTextBox");
	nuovoWrapTextBoxForum.setAttribute("id","WrapTextBox"+nuovoForumID);
	nuovoWrapTextBoxForum.setAttribute("style","display:none");
	document.getElementById("contentsbis").appendChild(nuovoWrapTextBoxForum);
	
	var nuovaHandle = document.createElement("div");
	nuovaHandle.setAttribute("class","chips_HandleBoxText");
	nuovaHandle.setAttribute("id","Handle"+nuovoForumID);
	nuovoWrapTextBoxForum.appendChild(nuovaHandle);
	
	var nButtonClose = document.createElement("div");
	nButtonClose.setAttribute("class","chips_removeButton");
	nButtonClose.setAttribute("id","ButtonRemove"+nuovoForumID);
	nButtonClose.setAttribute("onclick", "rimozione\(this.id\)");
	nuovaHandle.appendChild(nButtonClose);
	
	var nuovoBox = document.createElement("div");
	nuovoBox.setAttribute("class","chips_TextBox");
	nuovoBox.setAttribute("id","TextBox"+nuovoForumID);	
	nuovoWrapTextBoxForum.appendChild(nuovoBox);
	
	var nuovaNota = document.createElement("div");
	nuovaNota.setAttribute("class","chips_noteBlog");
	nuovaNota.setAttribute("id","Nota"+nuovoForumID);	
	now = document.getElementById("BlogNameCont").innerHTML;
	nuovaNota.innerHTML= "di " +now+ " - chips_SegnapostoData";
	nuovoBox.appendChild(nuovaNota);
	
	var nuovoTitle = document.createElement("div");
	nuovoTitle.setAttribute("class","chips_CapTitleBlog");
	nuovoTitle.setAttribute("id","TextTitle"+nuovoForumID);	
	now = document.getElementById("BlogTitleCont").innerHTML;
	nuovoTitle.innerHTML=now;
	nuovoBox.appendChild(nuovoTitle);
			
	var nuovoText = document.createElement("div");
	nuovoText.setAttribute("class","chips_CapBlog");
	nuovoText.setAttribute("id","Text"+nuovoForumID);
	newPost = document.getElementById("BlogPostCont").innerHTML;
	
	
	
	
	
	//Se la stringa è più lunga di 500 caratteri
	if (newPost.length > 500) {
		var seguito = newPost.substr(250);
		cerca_spazio = seguito.indexOf(" ");
	
		var anteprima = newPost.substr(0,250+cerca_spazio);
		var resto_post = newPost.substr(251+cerca_spazio);
	
		nuovoText.innerHTML = anteprima+ '...';
		nuovoBox.appendChild(nuovoText);
	
		var nuovoWrapCardBox = document.createElement("div");
		nuovoWrapCardBox.setAttribute("class","chips_WrapCardBoxForum");
		nuovoWrapCardBox.setAttribute("id","WrapCardBox"+nuovoForumID);	
		nuovoBox.appendChild(nuovoWrapCardBox);
	
		var nuovoCBox = document.createElement("div");
		nuovoCBox.setAttribute("class","chips_TextBox");
		nuovoCBox.setAttribute("id","CardBox"+nuovoForumID);	
		nuovoWrapCardBox.appendChild(nuovoCBox);
	
		var nuovaFreccia = document.createElement("div");
		nuovaFreccia.setAttribute("class","chips_ArrowCard");
		nuovaFreccia.setAttribute("id","Arrow"+nuovoForumID);
		//nuovoText.setAttribute("onmouseover", "highlightCard\("+"\'OpenCard"+parseInt(document.getElementById("contents").childNodes.length)+"'\)");
		nuovaFreccia.setAttribute("onclick", "openCard\("+"\'Card"+nuovoForumID+"'\)");
		now="<br />continua...";
		nuovaFreccia.innerHTML=now;
		nuovoBox.appendChild(nuovaFreccia);
	
		var nuovaCard = document.createElement("div");
		nuovaCard.setAttribute("class","chips_Card");
		nuovaCard.setAttribute("id","Card"+nuovoForumID);
		nuovaCard.setAttribute("style","display:none;overflow-x:hidden;overflow-y:hidden;");
		nuovoBox.appendChild(nuovaCard);
	
		var textCard = document.createElement("div");
		textCard.setAttribute("class","chips_CardText");
		textCard.setAttribute("id","CardText"+nuovoForumID);
		//textCard.setAttribute("onblur","chipsEdit\(this\)");
		now=resto_post;
		textCard.innerHTML=now;
		nuovaCard.appendChild(textCard);
	
	
	} else {
		nuovoText.innerHTML = newPost;
		nuovoBox.appendChild(nuovoText);
	}


	
	
	

	var rifUploadForum = document.getElementById('rifUploadForum').innerHTML;
	if (rifUploadForum != "") {
		var fileCaricato = document.createElement("div");
		fileCaricato.setAttribute("class","chips_ImgForumBox");
		fileCaricato.setAttribute("id","ImgForumBox"+nuovoForumID);
		now="<br><img class=\"chipsImgForum\" src=\"./page_contents/media/img/"+ rifUploadForum +"\">";
		fileCaricato.innerHTML=now;
	if (newPost.length > 500) {
		textCard.appendChild(fileCaricato);
	} else {
		nuovoText.appendChild(fileCaricato);
	}
	}
	
	NuovoPostDaInviare = '<div class="chips_WrapTextBox" id="WrapTextBox' +nuovoForumID+ '">' +nuovoWrapTextBoxForum.innerHTML+ '</div>';
	
	var nuovoBlogPublish = document.createElement("div");
	nuovoBlogPublish.setAttribute("class","chips_BlogPublish");
	nuovoBlogPublish.setAttribute("id","BlogPublish");	
	nuovoBlogPublish.setAttribute("onclick","registraForum\(\)");
	now="<div>Pubblica</div>";
	nuovoBlogPublish.innerHTML=now;
	nuovoBox.appendChild(nuovoBlogPublish);
	
	var nuovoBlogAnnulla = document.createElement("div");
	nuovoBlogAnnulla.setAttribute("class","chips_BlogAnnulla");
	nuovoBlogAnnulla.setAttribute("id","BlogAnnulla");	
	nuovoBlogAnnulla.setAttribute("onclick","window.location.reload\(\)");
	now="<div>Annulla</div>";
	nuovoBlogAnnulla.innerHTML=now;
	nuovoBox.appendChild(nuovoBlogAnnulla);
	
	// scroll della pagina se esiste un paragrafo precedente 
	//if (document.getElementById("WrapTextBox"+nuovoForumID).previousSibling) {
	
	var primo_paragrafo = document.getElementById("contentsbis").firstChild;
	document.getElementById("contentsbis").insertBefore(nuovoWrapTextBoxForum,primo_paragrafo);
	var nAnchor = document.getElementById("WrapTextBox"+nuovoForumID);
	document.getElementById('rifUploadForum').innerHTML = "";
	nuovaNota.innerHTML = nuovaNota.innerHTML.replace("chips_SegnapostoData",dataEora);
	
	alert(nuovoWrapTextBoxForum.innerHTML);
	
	new Effect.ScrollTo(nAnchor,{offset: -29, afterFinish: function() {
		document.getElementById("BlogNameCont").innerHTML = "";
		document.getElementById("BlogTitleCont").innerHTML = "";
		document.getElementById("BlogPostCont").innerHTML = "";
		new Effect.BlindDown(nuovoWrapTextBoxForum, { duration:1.1 });
		}
	});	
}


*/









/***************************************** SALVATAGGIO FORUM ****************************************/





	
var controllo_schede_aperte = 1;
var controllo_salvataggio = 1;


function registraForum(){


if (controllo_salvataggio == 2){
	alert("\nATTENZIONE!\nSalvataggio precedente ancora in corso...");
	return false;
	} else {


controllo_salvataggio = 2;

if (controllo_schede_aperte != 2){
	closeCurrentCard();
	closeCurrentNewsCard();
	if ($('over').style.display = "block"){
	$('over').style.display = "none";
	}
	controllo_schede_aperte = 1;
}

var primo_paragrafo = document.getElementById("contentsbis").firstChild;
var primo_testo = primo_paragrafo.lastChild;
var pulsantiera = primo_testo.lastChild;
primo_testo.removeChild(pulsantiera);
//pulsante_pubblica = primo_testo.lastChild;
//primo_testo.removeChild(pulsante_pubblica);
showpreviewForum();


NuovoPostDaInviare = '<div class="chips_WrapTextBox" id="WrapTextBox' +nuovoForumID+ '">' +nuovoWrapTextBoxForum.innerHTML+ '</div>';
	
var par_contentsForum = NuovoPostDaInviare;
var par_versione=$('versione_lingua').value;
						


var pars = 'c_contentsForum='+par_contentsForum
+'&c_versione='+par_versione
;



//alert(  pars  );

var nuovoAjax = new Ajax.Request('saveForum.php', { method:'post', postBody:pars, onSuccess: function() {
	controllo_salvataggio = 1;
	timerForum = window.setTimeout("alert('Post pubblicato!');", 700);
}
});


}

}


/*************************************  fine SALVATAGGIO FORUM **************************************/





/****************************************** funzioni Schede *****************************************/

/*
function clearIndirizzoLocale() {
	var indirizzo = document.getElementById("indirizzo");
	if ((indirizzo.innerHTML == "<div>indirizzo</div>") || (indirizzo.innerHTML == "<DIV>indirizzo</DIV>")) {
	indirizzo.innerHTML = "<div></div>";
	}
}
*/

function invioMailLocale(email) {
if (email.innerHTML.indexOf("@") == -1) {
	return false;
}
var estraiEmail = email.innerHTML.replace(/<text>/gi,"");
estraiEmail = estraiEmail.replace(/<\/text>/gi,"");
estraiEmail = estraiEmail.replace(/<br>/gi,"");
document.location.href = 'mailto:'+estraiEmail; 
}


function linkSitoLocale(sito) {
if (sito.innerHTML.indexOf("www") == -1) {
	return false;
}
var estraiSito = sito.innerHTML.replace(/<text>/gi,"");
estraiSito = estraiSito.replace(/<\/text>/gi,"");
estraiSito = estraiSito.replace(/<br>/gi,"");
var newwindow = window.open('http://'+estraiSito,'','');
}

/**************************************** fine funzioni Schede **************************************/




/******************************************* Search Engine ******************************************/



// Ottiene la base url
engine_url = document.location.href;
xend = engine_url.lastIndexOf("/") + 1;
var base_url = engine_url.substring(0, xend);
var parolaRicerca = "";

function attiva_search(engine_url) {
		/*
		if ((chipsVersion !== "Pro") && (chipsVersion !== "Avant")) {
			alert("Il motore di ricerca interno e' attivo sole nelle versioni Pro e Avant.");
			return false;
		}
		*/
		parolaRicerca = document.getElementById("searchInput").value;
        //Inizia l'engine_url con http?
        if (engine_url.substring(0, 4) != 'http') {
                engine_url = base_url + engine_url;
        }

        // Crea un nuovo elemento JS
        var jsel = document.createElement('SCRIPT');
        jsel.type = 'text/javascript';
        jsel.src = engine_url;
        //alert(jsel.src);

        //Appende l'elemento JS e quindi esegue la 'chiamata AJAX')
        document.body.appendChild (jsel);
}



/***************************************** fine Search Engine ***************************************/



if (document.getElementById("indirizzo")){
var indirizzoPerMappa = document.getElementById("indirizzo").innerHTML;
}



/********************************************** Tabelle ********************************************/

var tableID = "0";
var soloID = "0";
var colID = "0";
var rowID = "0";
var cellID = "0";
var elTab_da_eliminare = "riga";
var tableNewElemPos = "prima";
var tableSel = undefined;


function editTable(elem) {
	if (document.getElementById("Progettazione")) {
		if (controlloPaletteTabelle == "1") {
			return false;
		}
		if  ((controlloPaletteImmagini == "0") && ($('label_newControlliMedia_wrap').className == "label_palette_selected")) {
			showHideControlliItem('newControlliMedia_wrap');
			//controlloPaletteImmagini = "0";
		}
		if  ((controlloPaletteFilmati == "0") && ($('label_newControlliFilmati_wrap').className == "label_palette_selected")) {
			showHideControlliItem('newControlliFilmati_wrap');
			//controlloPaletteImmagini = "0";
		}
		if  ((controlloPaletteGallerie == "0") && ($('label_newControlliGalleria_wrap').className == "label_palette_selected")) {
			showHideControlliItem('newControlliGalleria_wrap');
			//controlloPaletteImmagini = "0";
		}
		controlloPaletteTabelle = "1";
		if (document.getElementById(tableID)) {
		if (document.getElementById("tableGrid").checked == false) {
		var ricercaCelle = document.getElementById(tableID);
		var cellTags = ricercaCelle.getElementsByTagName("td");
			for (var i = 0; i < cellTags.length; i++) {
				if ((cellTags[i].className != "intest_riga") && (cellTags[i].className != "intest_riga_visibile")) {
				cellTags[i].className = "no_grid";
				}
			} 
		}
		}
		
		tableID = elem.id;
		scalaTable(tableID);
		soloID = tableID.replace("Table","");
		var theadID = tableID.replace("Table","thead");
		var captionID = tableID.replace("Table","Caption");
		document.tableOptionForm.tableIntname.disabled = false;
		document.tableOptionForm.tableGridname.disabled = false;
		document.tableOptionForm.tableCaptionname.disabled = false;
		if (document.getElementById(theadID).style.display == "none") {
			document.getElementById("tableInt").checked = false;
		} else {
			document.getElementById("tableInt").checked = true;
				if (document.getElementById(tableID).className == "sort-table") {
					document.getElementById("tableSort").checked = true;
				}
			document.getElementById("tableSort").disabled = false;
		}
		
		if (document.getElementById(captionID).style.display == "none") {
			document.getElementById("tableCaption").checked = true;
		} else {
			document.getElementById("tableCaption").checked = false;
		}
		
		var ricercaCelle = document.getElementById(tableID);
		var cellTags = ricercaCelle.getElementsByTagName("td");
		
		if (cellTags[1].className == "grid") {
			document.getElementById("tableGrid").checked = true;
		} else {
			document.getElementById("tableGrid").checked = false;
		}
		
			for (var i = 0; i < cellTags.length; i++) {
				if ((cellTags[i].className != "intest_riga") && (cellTags[i].className != "intest_riga_visibile")) {
					if (cellTags[i].className != "grid") {
						cellTags[i].className = "grid_service";
					}
				}
			}
		//alert(soloID);
		//document.getElementById(tableID).style.width = "100%";
		var timerBloccoPaletteTabelle = window.setTimeout("bloccoPaletteTabelle();", 200);
	} else {
	return false;
	}
}


function showHideThead() {
	if (!document.getElementById(tableID)) {
		alert("Seleziona una tabella!");
		document.getElementById("tableInt").checked = false;
		return false;
	}
		var ricercaCelle = document.getElementById(tableID);
		var cellTags = ricercaCelle.getElementsByTagName("td");
		var thTags = ricercaCelle.getElementsByTagName("th");
		
		var theadID = tableID.replace("Table","thead");
		if (document.getElementById(theadID).style.display == "none") {
			document.getElementById("tableSort").disabled = false;
		
			for (var i = 0; i < cellTags.length; i++) {
				if (cellTags[i].className == "intest_riga") {
				cellTags[i].className = "intest_riga_visibile";
				}
			}
			for (var i = 0; i < thTags.length; i++) {
				if (thTags[i].className == "intest_riga0") {
				thTags[i].className = "intest_riga0_visibile";
				}
			}
			new Effect.Appear(theadID, {duration:0.7});
		} else {
			for (var i = 0; i < cellTags.length; i++) {
				if (cellTags[i].className == "intest_riga_visibile") {
				cellTags[i].className = "intest_riga";
				}
			}
			for (var i = 0; i < thTags.length; i++) {
				if (thTags[i].className == "intest_riga0_visibile") {
				thTags[i].className = "intest0_riga";
				}
			}
			$(theadID).style.display = "none";
			document.getElementById("tableSort").disabled = true;
		}
}

function ordinamentoRighe() {
	if (!document.getElementById(tableID)) {
		alert("Seleziona una tabella!");
		document.getElementById("tableSort").checked = false;
		return false;
	}
		if (document.getElementById(tableID).className != "sort-table") {
			document.getElementById(tableID).className = "sort-table";
			sortableTabelle();
			var ricercaTH = document.getElementById(tableID);
			var thTags = ricercaTH.getElementsByTagName("th");
				for (var i = 0; i < thTags.length; i++) {
					$(thTags[i].id).className = "intest_colonna_attiva";
				}
		} else {
			document.getElementById(tableID).className = "no_sort_table";
			var ricercaTH = document.getElementById(tableID);
			var thTags = ricercaTH.getElementsByTagName("th");
				for (var i = 0; i < thTags.length; i++) {
					$(thTags[i].id).className = "intest_colonna";
				}
			alert("L'ordinamento delle righe sara' rimosso al prossimo reload.");
			
			
		}
}

function showHideTableGrid() {
	if (!document.getElementById(tableID)) {
		alert("Seleziona una tabella!");
		document.getElementById("tableGrid").checked = false;
		return false;
	}
	var ricercaCelle = document.getElementById(tableID);
	var cellTags = ricercaCelle.getElementsByTagName("td");
	
		if (document.getElementById("tableGrid").checked == false) {
			document.getElementById("tableGrid").checked = false;
			for (var i = 0; i < cellTags.length; i++) {
				if ((cellTags[i].className != "intest_riga") && (cellTags[i].className != "intest_riga_visibile")) {
				cellTags[i].className = "grid_service";
				}
			}
		} else {
			document.getElementById("tableGrid").checked = true;
			for (var i = 0; i < cellTags.length; i++) {
				if ((cellTags[i].className != "intest_riga") && (cellTags[i].className != "intest_riga_visibile")) {
				cellTags[i].className = "grid";
				}
			}
		}
}

function showHideTableCaption() {
	if (!document.getElementById(tableID)) {
		alert("Seleziona una tabella!");
		document.getElementById("tableGrid").checked = false;
		return false;
	}
	var captionID = tableID.replace("Table","Caption");
		if (document.getElementById(captionID).style.display == "none") {
			new Effect.Appear(captionID, {duration:0.7});
		} else {
			new Effect.Fade(captionID, {duration:0.7});
		}
}


function editCaption(elem) {
	
}

function editRow(elem) {
	if (document.getElementById("Progettazione")) {
		rowID = elem.id;
	} else {
	return false;
	}
}


function editCell(elem) {
	if (document.getElementById("Progettazione")) {
		$("campo_controlFormat").value = elem.id;
		if (document.getElementById(cellID)) {
			document.getElementById(cellID).style.background = 0;
		}
		cellID = elem.id;
		document.getElementById(cellID).style.background = "#fde98c";
	} else {
	return false;
	}
}

function editCell_th(elem) {
	if (document.getElementById("Progettazione")) {
		if (document.getElementById(cellID)) {
			document.getElementById(cellID).style.background = 0;
		}
		cellID = elem.id;
	} else {
	return false;
	}
}

function sortableTabelle() {
	var ricercaTabelle = document.getElementById('project');
	var tableTags = ricercaTabelle.getElementsByTagName("table");
	for (var i = 0; i < tableTags.length; i++) {
		if ($(tableTags[i].id).className == "sort-table") {
			var st1 = new SortableTable(document.getElementById(tableTags[i].id),
			["Number", "String", "String", "String","String", "String", "String", "String","String", "String", "String", "String","String", "String", "String", "String","String", "String", "String", "String","String", "String", "String", "String","String", "String", "String", "String","String", "String", "String", "String"]);
		}
	}
}
/******************************************** fine Tabelle *****************************************/



/***************************************** Gallerie Immagini ***************************************/

var controlloPaletteGallerie = "";

function editGallery() {
	if (document.getElementById("Progettazione")) {
		if (controlloPaletteGallerie == "1") {
			return false;
		}
		impostaPulsantiGalleria();
		showMedia();
		mostraPaletteControlliGalleria();
	
		if  ((controlloPaletteImmagini == "0") && ($('label_newControlliMedia_wrap').className == "label_palette_selected")) {
			showHideControlliItem('newControlliMedia_wrap');
			//controlloPaletteImmagini = "0";
		}
		if  ((controlloPaletteFilmati == "0") && ($('label_newControlliFilmati_wrap').className == "label_palette_selected")) {
			showHideControlliItem('newControlliFilmati_wrap');
			//controlloPaletteImmagini = "0";
		}
		if  ((controlloPaletteTabelle == "0") && ($('label_newControlliTabelle_wrap').className == "label_palette_selected")) {
			showHideControlliItem('newControlliTabelle_wrap');
			//controlloPaletteImmagini = "0";
		}
		controlloPaletteGallerie = "1";
		
		var timerBloccoPaletteGallerie = window.setTimeout("bloccoPaletteGallerie();", 200);
	} else {
	return false;
	}
}

function stopGalleryScroll(id) {
	//alert(id.id);
}


/*************************************** fine Gallerie Immagini ************************************/

	
	
