window.onscroll = function()
{
	//Scroll su boxPop Offerte
	if($('boxPop')){
		$('boxPop').style.top = (((tellMeTheHeight() - $('boxPop').getDimensions().height)/ 2) + document.documentElement.scrollTop) + 'px';
		if ((((tellMeTheHeight() - $('boxPop').getDimensions().height)/ 2) + document.documentElement.scrollTop) <= 95){
			$('boxPop').style.top = '150px';
		}

	}
	if ($('boxPopInfoEvento')){
		$('boxPopInfoEvento').style.top = (((tellMeTheHeight() - $('boxPopInfoEvento').getDimensions().height)/ 2) + document.documentElement.scrollTop) + 'px';
		if ((((tellMeTheHeight() - $('boxPopInfoEvento').getDimensions().height)/ 2) + document.documentElement.scrollTop) <= 95){
			$('boxPopInfoEvento').style.top = '150px';
		}
	}
	
	if($('boxPopInfoMusei')){
		$('boxPopInfoMusei').style.top = (((tellMeTheHeight() - $('boxPopInfoMusei').getDimensions().height)/ 2) + document.documentElement.scrollTop) + 'px';
		if ((((tellMeTheHeight() - $('boxPopInfoMusei').getDimensions().height)/ 2) + document.documentElement.scrollTop) <= 95){
			$('boxPopInfoMusei').style.top = '150px';
		}
	}
	if ($('boxPopInfoAPT')){
		$('boxPopInfoAPT').style.top = (((tellMeTheHeight() - $('boxPopInfoAPT').getDimensions().height)/ 2) + document.documentElement.scrollTop) + 'px';
		if ((((tellMeTheHeight() - $('boxPopInfoAPT').getDimensions().height)/ 2) + document.documentElement.scrollTop) <= 95){
			$('boxPopInfoAPT').style.top = '150px';
		}
		
	}
}

//Posiziona DIV
function setMyDivPosition(myDiv)
{
	if ($(myDiv)){
		$(myDiv).style.top = (((tellMeTheHeight() - $(myDiv).getDimensions().height)/ 2) + document.documentElement.scrollTop) + 'px';
		if ((((tellMeTheHeight() - $(myDiv).getDimensions().height)/ 2) + document.documentElement.scrollTop) <= 95){
			$(myDiv).style.top = '150px';
		}
	}
}


function writeTopApt(){
	$('APT_DivRicInfo').innerHTML = $('APT_DivOfferta').innerHTML;
}

//CLOSE Popup Offerte
function closeThePopup()
{
	$('boxPop').style.display = 'none';
	$('boxPopInfoEvento').style.display = 'none';
	$('boxPopInfoMusei').style.display = 'none';
	$('boxPopInfoAPT').style.display = 'none';
	showTheSelect();
}

//HEIGHT WINDOW
function tellMeTheHeight() {
        w = window;
        var height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);
        return height
}

//WIDTH WINDOW
function tellMeTheWidth() {
        w = window;
        var width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
        return width
}


//NASCONDI SELECT SU POPUP O LOADING
function hideTheSelect(){
		if ($('frame') != null) {
			var mySelect = $('frame').getElementsByTagName("select");

			if (mySelect){
				for (var i=0; i<mySelect.length; i++)
				  {
				    mySelect[i].style.display='none';
				  }
			}
		}
}

//MOSTRA SELECT SU END POPUP O LOADING
function showTheSelect(){
		if ($('frame') != null) {
			var mySelect = $('frame').getElementsByTagName("select");

			if (mySelect){
				for (var i=0; i<mySelect.length; i++)
				  {
				    mySelect[i].style.display='block';
				  }
			}
		}
}

//SHOW WAIT
function showWait()
{
	$('Wait').style.display = 'block';
	hideTheSelect();
}

//HIDE WAIT
function hideWait()
{
	$('Wait').style.display = 'none';
	showTheSelect();
}

function replaceCampo(valore){
	var testo = valore

	testo = testo.replace(/à/g,'chr(224)');
	testo = testo.replace(/à/g,'chr(224)');
	testo = testo.replace(/á/g,'chr(225)');
	testo = testo.replace(/é/g,'chr(233)');
	testo = testo.replace(/è/g,'chr(232)');
	testo = testo.replace(/ò/g,'chr(242)');
	testo = testo.replace(/ì/g,'chr(236)');
	testo = testo.replace(/ì/g,'chr(236)');
	testo = testo.replace(/ù/g,'chr(249)');
	testo = testo.replace(/’/g,'chr(146)');
	testo = testo.replace(/‘/g,'chr(145)');
	testo = testo.replace(/’/g,'chr(145)');

	return testo;
}