/****************************************************************
*   Funzioni utente modificabili                                *
****************************************************************/
//
// funzioni per l'apertura di popUp
function popUp(){
	w = 580;
	h = screen.height;
	LeftPosition = 0;//(screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = 0;//(screen.height) ? (screen.height-h)/2 : 0;
	settings = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+w+',height='+h+',left='+LeftPosition+', top='+TopPosition+',screenX='+LeftPosition+',screenY='+TopPosition+'';
	win = window.open('normativa.html','normativa',settings)
}

//apertura PopUp a tutto schermo
function openFullWindow(lang) {
	var w = screen.width;
	var h = screen.height;

	LeftPosition = 0;
	TopPosition = 0;
	
	if (h<800)
	{
		var windowprops = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+w+',height='+h+',left='+LeftPosition+', top='+TopPosition+',screenX='+LeftPosition+',screenY='+TopPosition+'';
	} else
	{
		var windowprops = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+w+',height='+h+',left='+LeftPosition+', top='+TopPosition+',screenX='+LeftPosition+',screenY='+TopPosition+'';
	}
	
	var $ApplicationName$ = window.open('default.aspx?lang='+lang,'$ApplicationName$',windowprops);
	$ApplicationName$.moveTo(LeftPosition,TopPosition)
	$ApplicationName$.resizeTo(w,h);
	$ApplicationName$.focus();
}
/****************************************************************
*   Funzioni non modificabili                                *
****************************************************************/
function swapImage(obj,image) {
	$(obj).attr("src", "Images/menu_superiore/"+image);
}

function payOff(text) {
	return $("#payOff").html(text);
}
function hidePopUp(controlId) {
    $('#popUpBackGround').remove();
    var popup = $(controlId);
    popup.removeClass("popUpBody");
    popup.hide();
}
function showEditPanel(controlId, title, page, w, h) {
    var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
    var scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);

    var clientWidth = $(window).width();
    var clientHeight = $(window).height();
    
    var sfondo = $('<div id="popUpBackGround" />');
    sfondo.height((document.documentElement.scrollHeight ? document.documentElement.scrollHeight : document.body.scrollHeight) + 'px');
    sfondo.width((document.documentElement.scrollWidth ? document.documentElement.scrollWidth : document.body.scrollWidth) + 'px');
    sfondo.appendTo(document.body);

    var caption = $('#editCaption');
    caption.html(title);

    var pagina = $('#editPage');
    pagina.attr('src', page);
    pagina.width((w - 49) + 'px')
    pagina.height((h - 69) + 'px')

    var popup = $(controlId);
    popup.addClass("popUpBody");
    popup.width(w + 'px');
    popup.height(h + 'px');
    popup.css("left", ((clientWidth / 2) - (popup.width() / 2) + 'px'));
    popup.css("top", ((clientHeight / 2) - (popup.height() / 2) + 'px'));
    popup.show();

    window.onresize = function() {
        sfondo.height((document.documentElement.scrollHeight ? document.documentElement.scrollHeight : document.body.scrollHeight) + 'px');
        sfondo.width((document.documentElement.scrollWidth ? document.documentElement.scrollWidth : document.body.scrollWidth) + 'px');
        //var clientBounds = $common.getClientBounds();
        var clientWidth = $(window).width();
        var clientHeight = $(window).height();
        var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
        var scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
        popup.css("left", ((clientWidth / 2) - (popup.width() / 2) + 'px'));
        popup.css("top", ((clientHeight / 2) - (popup.height() / 2) + 'px'));
    }
}