//SCROLL Popup Offerte
window.onscroll = function()
{
	//Scroll su boxPop Offerte
	if ($('boxPop')){
		if ($('boxPop').style.display == 'block'){
			$('boxPop').style.top = (((tellMeTheHeight() - $('boxPop').getDimensions().height)/ 2) + document.documentElement.scrollTop) + 'px';
		}
	}
	
	//Scroll su boxPop Prenota
	if($('boxPopPrenota')){
		if ($('boxPopPrenota').style.display == 'block'){
			$('boxPopPrenota').style.top = (((tellMeTheHeight() - $('boxPopPrenota').getDimensions().height)/ 2) + document.documentElement.scrollTop) + 'px';
		}
	}
	
	//Scroll su wait
	if ($('Wait')){
		if ($('Wait').style.display == ''){
			$('Wait').style.top = (((tellMeTheHeight() - $('Wait').getDimensions().height)/ 2) + document.documentElement.scrollTop) + 'px';
		}
	}

	//Scroll su richiesta Info in scheda Soggetto
	if($('PopRichiestaInfo')){
		if ($('PopRichiestaInfo').style.display == 'block'){
			$('PopRichiestaInfo').style.top = (((tellMeTheHeight() - $('PopRichiestaInfo').getDimensions().height)/ 2) + document.documentElement.scrollTop) + 'px';	
		}
	}

	//Scroll su richiesta Preventivo in scheda Soggetto
	if($('PopRichiestaPreventivo')){
		if ($('PopRichiestaPreventivo').style.display == 'block'){
			$('PopRichiestaPreventivo').style.top = (((tellMeTheHeight() - $('PopRichiestaPreventivo').getDimensions().height)/ 2) + document.documentElement.scrollTop) + 'px';
		}
	}

	//Scroll su pupup Periodo (Gestione FE)
	if($('PopPeriodo')){
		if ($('PopPeriodo').style.display == 'block'){
			$('PopPeriodo').style.top = (((tellMeTheHeight() - $('PopPeriodo').getDimensions().height)/ 2) + document.documentElement.scrollTop) + 'px';
		}
	}

}

//Posiziona DIV
function setMyDivPosition(myDiv)
{
	if ($(myDiv)){
		$(myDiv).style.top = (((tellMeTheHeight() - $(myDiv).getDimensions().height)/ 2) + document.documentElement.scrollTop) + 'px';
		$(myDiv).style.left = (((tellMeTheWidth() - $(myDiv).getDimensions().width)/ 4)) + 'px';
	}
}

//CLOSE Starting Wait
function closeStartingWait()
{
	if ($('Loading')){
		$('Loading').style.display = 'none';
	}
	showTheSelect();
}

//CLOSE Popup Offerte
function closeThePopup()
{
	$('boxPop').style.display = 'none';
	$('TotalFade').style.display = 'none';
	showTheSelect();
}

//CLOSE Popup Prenota
function closeThePopupPrenota()
{
	$('boxPopPrenota').style.display = 'none';
	$('TotalFade').style.display = 'none';
	showTheSelect();
}

//CLOSE Popup Richiesta Info
function closeTheInfoPopup()
{
	$('PopRichiestaInfo').style.display = 'none';
	$('TotalFade').style.display = 'none';
	showTheSelect();
}

//CLOSE Popup Richiesta Preventivo
function closeThePreventivoPopup()
{
	$('PopRichiestaPreventivo').style.display = 'none';
	$('TotalFade').style.display = 'none';
	showTheSelect();
}

//CLOSE Popup Periodo (Gestione FE)
function closeThePeriodoPopup()
{
	$('PopPeriodo').style.display = 'none';
	$('TotalFade').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 ($('page') != null) {
			var mySelect = $('page').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 ($('page') != null) {
			var mySelect = $('page').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();
}