/*********************************************
 FUNZIONI PER GESTIONE EVENTI PROTOTYPE WINDOW
 *********************************************/	

/***********************
 Funzioni gestione popup
 ***********************/
var prototype_popupWindow = null;
var prototype_popupName = '?';
var prototype_popupExitCode = '-1';
var prototype_popupExitMeta = '';

function prototype_openPopup(popup) {
	prototype_popupName = popup;
	prototype_popupExitCode = '-1';
	prototype_popupExitMeta = '';
	prototype_popupWindow = new Window(
		{
			className: "mac_os_x", 
			title: "Errore", 
			width: 300, 
			height: 50, 
			showEffect: Effect.SlideDown, 
			hideEffect: Effect.SlideUp
		});
	prototype_popupWindow.setHTMLContent(
        '<div style="width: 100%; text-align: center; margin: 10px 0 0 0;">' + 
            '<table style="width: auto; border: 0; margin: 2px auto; padding: 0;">' +
                '<tr>' +
                    '<td valign=middle style="text-align: right; white-space: nowrap; ">' +
	                    '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="20" height="20">' +
		                    '<param name="movie" value="' + prototype_applicationRootUrl + 'Risorse/Flash/Loading.swf" />' +
		                    '<param name="bgcolor" value="#222222" />' +
		                    '<param name="wmode" value="transparent" />' +
		                    '<embed src="' + prototype_applicationRootUrl + 'Risorse/Flash/Loading.swf" wmode="transparent" quality="high" loop="true" width="20" height="20" type="application/x-shockwave-flash" inspage="http://www.macromedia.com/go/getflashplayer"/>' +
	                    '</object>' +
                    '</td>' +
                    '<td valign=middle style="padding-left: 5px; font-size: 11px; font-weight: normal; color:#202020; text-align: left; white-space: nowrap; ">' +
	                    'Prototype Handler <strong>openPopup</strong><br/>' +
	                    'Popup "' + popup + '" non valido!' +
                    '</td>' +
                '</tr>' +
            '</table>' +
        '</div>');
	switch (prototype_popupName) {
		case '---??---':
			prototype_popupWindow = new Window(
				{
					className: "mac_os_x", 
					title: "---??---", 
					width: 800, 
					height: 550, 
					url: prototype_applicationRootUrl + "SezioneGestione/Popup/SelezioneViolazioni.aspx?load=SchedaPratica", 
					showEffect: Effect.SlideDown, 
					hideEffect: Effect.SlideUp
				});
			break;
	}
	prototype_popupWindow.showCenter(true);							
	return false;
}

function prototype_openPopupWithParam(popup, param) {
	prototype_popupName = popup;
	prototype_popupParam = param;
	prototype_popupExitCode = '-1';
	prototype_popupExitMeta = '';
	prototype_popupWindow = new Window(
		{
			className: "mac_os_x", 
			title: "Errore", 
			width: 300, 
			height: 50, 
			showEffect: Effect.SlideDown, 
			hideEffect: Effect.SlideUp
		});
	prototype_popupWindow.setHTMLContent(
        '<div style="width: 100%; text-align: center; margin: 10px 0 0 0;">' + 
            '<table style="width: auto; border: 0; margin: 2px auto; padding: 0;">' +
                '<tr>' +
                    '<td valign=middle style="text-align: right; white-space: nowrap; ">' +
	                    '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="20" height="20">' +
		                    '<param name="movie" value="' + prototype_applicationRootUrl + 'Risorse/Flash/Loading.swf" />' +
		                    '<param name="bgcolor" value="#222222" />' +
		                    '<param name="wmode" value="transparent" />' +
		                    '<embed src="' + prototype_applicationRootUrl + 'Risorse/Flash/Loading.swf" wmode="transparent" quality="high" loop="true" width="20" height="20" type="application/x-shockwave-flash" inspage="http://www.macromedia.com/go/getflashplayer"/>' +
	                    '</object>' +
                    '</td>' +
                    '<td valign=middle style="padding-left: 5px; font-size: 11px; font-weight: normal; color:#202020; text-align: left; white-space: nowrap; ">' +
	                    'Prototype Handler <strong>openPopupWithParam</strong><br/>' +
	                    'Popup "' + popup + '" non valido!' +
                    '</td>' +
                '</tr>' +
            '</table>' +
        '</div>');
	switch (prototype_popupName) {
		case '---??---':
			prototype_popupWindow = new Window(
				{
					className: "mac_os_x", 
					title: "---??---", 
					width: 800, 
					height: 300, 
					url: prototype_applicationRootUrl + "SezionePratiche/Popup/SchedaScadenza.aspx?guid=" + param, 
					showEffect: Effect.SlideDown, 
					hideEffect: Effect.SlideUp
				});
			break;
	}
	prototype_popupWindow.showCenter(true);							
	return false;
}

function prototype_closePopup() {
	prototype_popupWindow.close();
	switch (prototype_popupExitCode) {
		case '-1':
			/* Chiusura della finestra senza selezione, niente da fare */
			break;
		case '0':
			switch (prototype_popupName) {
				default:
					Dialog.alert(
						"Callback non definito: '" + prototype_popupName + "'.", 
						{
							width: 300, 
							height: 100, 
							okLabel: "Chiudi", 
							ok: function(win) { return true; }
						});
				    break;
			}
			break;
	}
}

/***********************
 Funzioni gestione varie
 ***********************/
function prototype_delaySubmitForm(objForm, nomeAzione) {
    Dialog.info(
        '<strong>Processo in corso</strong><br/>' +
        'attendere prego<br/>' +
        '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="20" height="20">' +
            '<param name="movie" value="' + prototype_applicationRootUrl + 'Risorse/Flash/Loading.swf" />' +
            '<param name="bgcolor" value="#222222" />' +
            '<param name="wmode" value="transparent" />' +
            '<embed src="' + prototype_applicationRootUrl + 'Risorse/Flash/Loading.swf" wmode="transparent" quality="high" loop="true" width="20" height="20" type="application/x-shockwave-flash" inspage="http://www.macromedia.com/go/getflashplayer"/>' +
        '</object>', 
        {
            width: 250, 
            height: 50, 
		    showProgress: false
        }
    );
    setTimeout(function() {
        var _objInputAzione = document.createElement("input");
        _objInputAzione.setAttribute("name", nomeAzione);
        _objInputAzione.setAttribute("type", "hidden");
        _objInputAzione.setAttribute("value", "1");  
        objForm.appendChild(_objInputAzione);
        objForm.submit();
    }, 600);
}
