function goToMainPage( appl, form, page, params ) 
{		
	//alert('GoToMainPage - START');
			
	var url;
	//url = '/' + page;
	url = page;
	if ( appl != '' ) { url += '?IDAppl=' + appl; }
	if ( form != '' ) { url += '&IDForm=' + form; }
	if ( typeof(params) != 'undefined' ) { 
	  if ( params != '' ) { 
	    url += '&Params=' + params; 
	  }
	}

	var win;
	
	//alert(window.name);
	
  if(( window.name.search('SIPALWEB') >= 0 && window.name.length == 8 ) || ( window.name.search('SIPALWEB') < 0 ))
	{
		if ( window.name.search('SIPALWEB') < 0 )
		{
			window.name = 'SIPALWEB';												
		}
		window.location.href = url;
		//alert(window.name);
	}
	else
	{
		win = window.open( '', 'SIPALWEB' ); 
		win.location.href = url;
		closeWin(window); 
		win.focus();
	}				    
}	


function goToSubPage( appl, form, user, session, params ) 
{	
	if ( appl == '' ) { return false; }
	
	var url;			
	url = appl + '/Index.aspx?SessionID=' + session;
	if ( form != '' ) { url += '&IDForm=' + form; }
	if ( typeof(params) != 'undefined' ) { 
		if ( params != '' ) { 
			url += '&Params=' + params; 
		}
	}
	
	var win;
	
  if( window.name.search('SIPALWEB_') >= 0 )
	{
		window.location.href = url;
	}
	else
	{
		var targ3t=user;
		targ3t = targ3t.replace(" ", "_");
		targ3t = targ3t.replace(".", "_");
		targ3t = targ3t.replace("-", "_");

		openApplWin(url, 'SIPALWEB_' + targ3t+ '_' + appl); 
		closeWin(window); 
		//win.focus();
	}				    
}	

function closeWin( win ) {
		
	//alert('closewin');
	//alert(win.opener);							
	
  if( win.opener )		// if( win.opener && !win.opener.closed )
	{ 
		win.close(); 
	}
	else				
	{
		if( win.history.length > 0) win.history.back();
		else win.location.href = 'about:blank';
	}			
}	

function openApplWin(url, target)
{

	var wide = window.screen.availWidth;
	var high = window.screen.availHeight;
	//var prop = "toolbar=no,location=no,menubar=no,status=no,resizable=yes,scrollbars=yes";		
	var prop = "toolbar=no,location=no,menubar=no,status=yes,resizable=yes,scrollbars=yes";		

	

	//Apro una nuova window, la massimizzo e imposto l'url
	target = target.replace(" ", "_");
	target = target.replace(".", "_");
	target = target.replace("-", "_");
	var win = window.open( "", target, prop );
	win.moveTo( 0, 0 );
	win.resizeTo( wide, high );
	win.location = url;
	
	//return win;
}

function menuGotoAppl( appl, form, params )
{
	var id = document.all['__SessionID'];

	var sep = '?';
	var url = 'Index.aspx';
	if( appl != '' ) url = '../' + appl + '/' + url;
	if( id ) { url += sep + 'SessionID=' + id.value; sep = '&'; }
	if( form != '' ) url += sep + 'IDForm=' + form; 
	if( typeof(params) != 'undefined' ) {
		if ( params != '' ) { 
			url += sep + 'Params=' + params; 
		}
	}
	
	window.location.href = url;
}

function checkLoginEnter( event )
		{
            var tasto = window.event.keyCode;
            if (tasto == 13)
            {
                Form1.txtHide.value='Qualcosa';
						}
  	}

//
