function showWaitGif(form){	
	/*if (document.getElementById(form+'_toolbar')!=null)
		document.getElementById(form+'_toolbar').setAttribute('style','display:none;');
	if (document.getElementById(form+'_toolbar_wait')!=null)
		document.getElementById(form+'_toolbar_wait').setAttribute('style','');
	if (document.getElementById(form+'_logo')!=null)
		document.getElementById(form+'_logo').setAttribute('style','display:none;');
	if (document.getElementById(form+'_logo_wait')!=null)
		document.getElementById(form+'_logo_wait').setAttribute('style','');*/
}

function showWait(){
	setStyleDisplay(getPageName()+':wait', ''); 
	setStyleDisplay(getPageName()+':nowait', 'none');
}

function setInitialFocus(ricKey){	
	var pagename=getPageName();	
	
	var object = document.getElementById("" +pagename+":initialFocus");
	
	if (pagename=="wso0204"){
		// ECCEZIONI
		if (ricKey=="k1" || ricKey=="k3"){
			document.getElementById("wso0204_ricDes:initialFocus").focus();
			document.getElementById("wso0204_ricDes:initialFocus").select();
		}
		else{
			document.getElementById("wso0204_ricCod:initialFocus").focus();
			document.getElementById("wso0204_ricCod:initialFocus").select();
		}
		// ECCEZIONI
	}
	else{
		if (pagename=="wso0205"){
			// ECCEZIONI
			if (document.getElementById("ageprz:initialFocus")!=null){
				document.getElementById("ageprz:initialFocus").focus();
				document.getElementById("ageprz:initialFocus").select();
			}
			else{
				document.getElementById("wso0205:initialFocus").focus();
				document.getElementById("wso0205:initialFocus").select();
			}
			// ECCEZIONI
		}
		else{
			if (object!=null){
				object.focus();
				object.select();
			}
		}
	}
}

function getPageName(){
	var pagename = "";
	pagename = document.URL.split("/")[document.URL.split("/").length-1];
	pagename = pagename.split(".")[0];
	return pagename;
}

function cleanJavascriptObject(){
	// Wso0510
	if (document.getElementById("wso0510:wait")!=null){
		setStyleDisplay('wso0510:wait', '');
	}
}

function popup(url,params){	
	if (params!='')
		params = '?' + params;
	window.open(url+params,'_blank','width='+((screen.width*2)/3)+'px ,height='+((screen.height*2)/3)+'px,top='+((screen.height - ((screen.height*2)/3)) / 2)+',left='+((screen.width - ((screen.width*2)/3)) / 2)+',scrollbars=yes, dependent=yes,resizable=yes,modal=yes,border=no');
}	

function popupDim(url,width,height,params){	
	if (params!='')
		params = '?' + params;
	window.open(url+params,'_blank','width='+width+'px ,height='+height+'px,top='+((screen.height - height) / 2)+',left='+((screen.width - width) / 2)+',scrollbars=yes, dependent=yes,resizable=yes,modal=yes,border=no');
	//var x = findPosition(document.getElementById('bodyPosition'))[0];
	//var y = findPosition(document.getElementById('bodyPosition'))[0];
	//window.open(url+params,'_blank','width='+width+'px ,height='+height+'px,top='+x+',left='+y+',scrollbars=yes, dependent=yes,resizable=yes,modal=yes,border=no');
}

function keyCheck(event){
   //alert(event.which);
   switch(event.keyCode)
   {
      case 16:
		document.Form1.KeyName.value = "Shift";
		break; 

      case 17:
		document.Form1.KeyName.value = "Ctrl";
		break;

      case 18:
		document.Form1.KeyName.value = "Alt";
		break;

      case 19:
		document.Form1.KeyName.value = "Pause";
		break;

      case 27:
      	// ESC
      	if (getPageName()=='wso0203'
      		|| getPageName()=='wso0206'
      		|| getPageName()=='wso0207'
      		|| getPageName()=='wso0208'
      		|| getPageName()=='wso0502'
      		|| getPageName()=='wso0505'
      		|| getPageName()=='wso0509'
      		|| getPageName()=='help'){
      		self.close();
      		}
   		else{   		
   			//window.location.href=document.location.href.replace(document.location.pathname, '/store');
   		}
      	if (getPageName()=='wso0510'){
      		// ECCEZIONI
      		setStyleDisplay('wso0510:wait', 'none'); 
      		setStyleDisplay('wso0510:nowait', ''); 
      		setStyleDisplay('wso0510:excel', '');
      		}     
   		else{
   			setStyleDisplay(getPageName()+':wait', 'none'); 
      		setStyleDisplay(getPageName()+':nowait', ''); 
   		} 	
		break;

      case 37:
		document.Form1.KeyName.value = "Arrow Left";
		break;

      case 38:
		document.Form1.KeyName.value = "Arrow Up";
		break;

      case 39:
		document.Form1.KeyName.value = "Arrow Right";
		break;

      case 40:
		document.Form1.KeyName.value = "Arrow Down";
        break;
   }
}

function setCurrentFocusId(id){
currentFocusId=id;
}


/****************** RILEVAMENTO POSIZIONE MOUSE *******************/
/*var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  document.Show.MouseX.value = tempX
  document.Show.MouseY.value = tempY
  return true
}*/
/****************** RILEVAMENTO POSIZIONE MOUSE (fine) *******************/



/*********************************************/
/*
function popup(url,width,height,name,value){	
	window.open(url+'?'+name+'='+value,'_blank','width='+width+'px ,height='+height+'px,top='+((screen.height - height) / 2)+',left='+((screen.width - width) / 2)+',scrollbars=yes, dependent=yes,resizable=yes,modal=yes,border=no');
}	

function popupOld(url,width,height,name,value){	
	window.open(url+'?'+name+'='+value,'_blank','width='+width+',height='+height+',top='+((screen.height - height) / 2)+',left='+((screen.width - width) / 2)+',scrollbars=yes, dependent=yes,resizable=yes,modal=yes,border=no');
}	

function popupDialog(url,width,height,name,value){
	window.showModalDialog(url+'?'+name+'='+value,'','dialogHeight:'+((screen.height*2)/3)+'px; dialogWidth:'+((screen.width*2)/3)+'px; resizable:yes; center:yes; dialogLeft:'+((screen.width - ((screen.width*2)/3)) / 2)+';dialogTop:'+((screen.height - ((screen.height*2)/3)) / 2)+';')
}	
	
function popup2Old(url,width,height,params){	
	window.open(url+'?'+params,'_blank','width='+width+',height='+height+',top='+((screen.height - height) / 2)+',left='+((screen.width - width) / 2)+',scrollbars=yes, dependent=yes,resizable=yes,modal=yes,border=no');
	}	

function popup2Dialog(url,width,height,params){
	if (window.showModalDialog)
		window.showModalDialog(url+'?'+params,null,'dialogHeight:'+((screen.height*2)/3)+'px; dialogWidth:'+((screen.width*2)/3)+'px; resizable:yes; center:yes; dialogLeft:'+((screen.width - ((screen.width*2)/3)) / 2)+';dialogTop:'+((screen.height - ((screen.height*2)/3)) / 2)+';')
	else
		window.open(url+'?'+params,'_blank','width='+width+',height='+height+',top='+((screen.height - height) / 2)+',left='+((screen.width - width) / 2)+',scrollbars=yes, dependent=yes,resizable=yes,modal=yes,border=no')
}	

function popup3(url){	
	window.open(url,'_blank','width='+((screen.width*2)/3)+'px ,height='+((screen.height*2)/3)+'px,top='+((screen.height - ((screen.height*2)/3)) / 2)+',left='+((screen.width - ((screen.width*2)/3)) / 2)+',scrollbars=yes, dependent=yes,resizable=yes,modal=yes,border=no');
	}
	*/
/*********************************************/
function transferFocus_cercaDes(){
	document.getElementById('wso0204_ricDes:cercaDes').focus();
}

function showSelectionDescription(section, page, value){
	//document.getElementById('pageDescrContainer').style.top=''+tempY+'px';
	//document.getElementById('pageDescrContainer').style.left=''+tempX+'px';
	setSpanValue(page, value); 
	if (value!=''){
		setStyleDisplay(section, 'none');
		document.getElementById(section).parentNode.className='TRLtoolbarSectionTitleSelected';
		//setStyleDisplay('pagetitle', '');
		}
	else{
		setStyleDisplay(section, '');
		document.getElementById(section).parentNode.className='TRLtoolbarSectionTitle';
		//setStyleDisplay('pagetitle', 'none');
		}
}

