//---------------------
//FUNZIONE FOCUS ATTIVO
//---------------------

function txt_focus(){
	document.form_login.MLLema.focus();
}



//-----------------------
//APERTURA NUOVA FINESTRA
//-----------------------

function APRfin( winURL , winTIT , winWID , winHEI )
{
	initwin=window.open( winURL , winTIT , 'status=no , menubar=no , toolbar=no , scrollbars=yes , resizable=no , copyhistory=0 , width=' + winWID + ' , height=' + winHEI + ' , top=' + ((screen.availheight-winHEI)/2) + ' , left=' + ((screen.availwidth-winWID)/2) );
}

function showTreeItem(objID){
		
	var objItm=document.getElementById(objID);
	var ulItem=objItm.childNodes[1];
	
	alert(ulItem.tagName);
	
	//ulItem.style.display=='';
	
	ulItem.className='showTree'
	
	/*
	if(ulItem.style.display==''){
		ulItem.style.display='none';
	}else{
		ulItem.style.display='';
	}
	*/
}

function APRwin( winURL , winTIT , winWID , winHEI )
{
	initwin=window.open( winURL , winTIT , 'status=no , menubar=no , toolbar=no , scrollbars=yes , resizable=no , copyhistory=0 , width=' + winWID + ' , height=' + winHEI + ' , top=' + ((screen.availheight-winHEI)/2) + ' , left=' + ((screen.availwidth-winWID)/2) );
}

function showTreeItem(objID){
		
	var objItm=document.getElementById(objID);
	var ulItem=objItm.childNodes[1];
	
	alert(ulItem.tagName);
	
	//ulItem.style.display=='';
	
	ulItem.className='showTree'
	
	/*
	if(ulItem.style.display==''){
		ulItem.style.display='none';
	}else{
		ulItem.style.display='';
	}
	*/
}
//------------------
//FUNZIONI GENERICHE
//------------------



function InitPopup(winURL,winTIT)
{
 initwin=window.open(winURL,winTIT,'status, menubar,toolbar, scrollbars, resizable, location , top=0 left=0');
 initwin.focus();
}

function MM_swapImgRestore()
{
 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
	
function MM_findObj(n, d)
{
	var p,i,x;
	if(!d) d=document; 
	if((p=n.indexOf('?'))>0&&parent.frames.length)
	{
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n]; 
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); 
	return x;
}
	
function MM_swapImage()
{
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null)
	{
		document.MM_sr[j++]=x;
		if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	}
}
	
function MM_preloadImages()
{
	var d=document;
	if(d.images)
	{
		if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++)
		if (a[i].indexOf('#')!=0)
		{
			d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
		}
	}
}
	
function MM_openBrWindow(theURL,winName,features)
{
	window.open(theURL,winName,features);
}
	
function MM_displayStatusMsg(msgStr)
{
	status=msgStr;
	document.MM_returnValue = true;
}
 
function IMPval(LSTfie , LSTval , CHRsep )
{
	//IMPOSTA IL VALORE DI UN CAMPO
	//LSTfie = STRINGA CONTENENTE I NOMI DEI CAMPI DA RIEMPIRE
	//LSTval = STRINGA CONTENENTE I VALORI DEI CAMPI DA RIEMPIRE
	//CHRsep = CARATTERE DI SEPARAZIONE DEI VALORI
	VETfie=LSTfie.split(CHRsep);
	VETval=LSTval.split(CHRsep);
	for(i=0;i<VETfie.length;i++)
	{
	 var strCMD='this.opener.document.FRM.'+VETfie[i]+'.value=\''+VETval[i]+'\'';
	 eval(strCMD);
	}
	window.close();
}

function AGGval(LSTfie , LSTval , CHRsep )
{
	//AGGIUNGE AD UN CAMPO UN VALORE
	//LSTfie = STRINGA CONTENENTE I NOMI DEI CAMPI DA RIEMPIRE
	//LSTval = STRINGA CONTENENTE I VALORI DEI CAMPI DA RIEMPIRE
	//CHRsep = CARATTERE DI SEPARAZIONE DEI VALORI
	
	VETfie=LSTfie.split(CHRsep);
	VETval=LSTval.split(CHRsep);
	
	for(i=0;i<VETfie.length;i++)
	{
	 var strCMD='this.opener.document.FRM.'+VETfie[i]+'.value=this.opener.document.FRM.'+VETfie[i]+'.value+\'' + VETval[i]+ '\\n' + '\'';
	 
	 eval(strCMD);
	}
	
	window.close();
}

// ---------------------------------------------------------------
// COMPILAZIONE RIGA INSERIMENTO ORDINE IN BASE AL CODICE ARTICOLO
// ---------------------------------------------------------------
function ORDriccod( STRrig , CMPnu1 , CMPnu2 , CMPnu3 , CMPnu4 , CMPfoc , URLtxt )
{
	//STRrif
	//DIVIDE LA STRINGA STR IN VETTORI CMPx
	//CMPfoc E' IL CAMPO CHE AVRÀ IL FOCUS
	//URLtxt E' LA PAGINA APERTA SE NON TROVO DATI
	
	// NESSUN CODICE INSERITO
	if ( CMPnu1.value == '' )
	{
		return;
 	}			
	
	STRrig = unescape( STRrig );
	
	CMPnu1.value = CMPnu1.value.toUpperCase();
	CMPval = CMPnu1.value;
	
	var TMPvet = STRrig.split("#");
	
	for (i = 0;i < TMPvet.length-1; i++)
	{
		VETval = 	TMPvet[i].split("|");
		
		if (VETval[0] == CMPnu1.value)
		{
			CMPnu2.value =           VETval[1]   ;
			CMPnu3.value = unescape( VETval[2] ) ;
			CMPnu4.value = unescape( VETval[3] ) ;
			
			CMPfoc.focus();
			
			return;
		}
	}
	
	CMPnu1.value = '' ;
	CMPnu2.value = '' ;
	CMPnu3.value = '' ;
	CMPnu4.value = '' ;
	
	CMPnom = CMPnu1.name + '|' + CMPnu2.name + '|' + CMPnu3.name + '|' + CMPnu4.name + '&RIGcod=' + CMPval + '&BTNcer=1' ;
	
	CMPfoc.focus();
	
	var zz = window.open( URLtxt + '?CMPnom=' + CMPnom , 'riccod' , 'status=yes , menubar=no , toolbar=no , scrollbars=no , resizable=no , copyhistory=0 , width=1014 , height=690 , top=1 , left=1' ) ;
}

function ORDricart( CMPnu1 , CMPnu2 , CMPnu3 , CMPnu4 , CMPfoc , URLtxt )
{
	CMPnu1.value = '' ;
	CMPnu2.value = '' ;
	CMPnu3.value = '' ;
	CMPnu4.value = '' ;
	
	CMPnom = CMPnu1.name + '|' + CMPnu2.name + '|' + CMPnu3.name + '|' + CMPnu4.name ;
	
	CMPfoc.focus();
	
	var zz = window.open( URLtxt + '?CMPnom=' + CMPnom , 'ricart' , 'status=yes , menubar=no , toolbar=no , scrollbars=no , resizable=no , copyhistory=0 , width=1014 , height=690 , top=1 , left=1' ) ;
	
	return;
}

function CRMriccli( CMPnu1 , CMPnu2 , CMPnu3 , CMPnu4 , CMPnu5 , URLtxt )
{
	CMPnu1.value = '' ;
	CMPnu2.value = '' ;
	CMPnu3.value = '' ;
	CMPnu4.value = '' ;
	CMPnu5.value = '' ;
	
	CMPnom = CMPnu1.name + '|' + CMPnu2.name + '|' + CMPnu3.name + '|' + CMPnu4.name + '|' + CMPnu5.name ;
	
	var zz = window.open( URLtxt + '?CMPnom=' + CMPnom , 'riccli' , 'status=yes , menubar=no , toolbar=no , scrollbars=no , resizable=no , copyhistory=0 , width=1014 , height=690 , top=1 , left=1' );
	
	return;
}


/*----------------------------------------------
  APRE UN POPUP CENTRATO NELLO SCHERMO
 -----------------------------------------------*/
function OpenPopup(winWID,winHEI,winURL){
  var winLeft=(screen.availWidth-winWID)/2; 
  var winTop=(screen.availHeight-winHEI)/2; 
  
  window.open(winURL,'zzz','status=no, menubar=no, toolbar=no, scrollbars=no, resizable=no,copyhistory=0,width=' + winWID + ',height=' + winHEI + ',top='+winTop+',left='+winLeft);
    
}

/*--------------------------------------------------
  APRE UN POPUP CENTRATO NELLO SCHERMO CON SCROLLBAR
 ---------------------------------------------------*/
function OpenPopupScroll(winWID,winHEI,winLeft,winTop,winURL){
	
	if(winLeft==-1 && winTop==-1){
		winLeft=(screen.availWidth-winWID)/2; 
  	winTop=(screen.availHeight-winHEI)/2; 
	}
  
  window.open(winURL,'zzz','status=no, menubar=no, toolbar=no, scrollbars=yes, resizable=no,copyhistory=0,width=' + winWID + ',height=' + winHEI + ',top='+winTop+',left='+winLeft);
    
}


function ShowItems(){
	var idLIF = document.getElementById('idLIF').value;
	var idVIE = document.getElementById('idVIE').value;
	var idVER = document.getElementById('idVER').value;
	var idMON = document.getElementById('idMON').value;
	var idPAS = document.getElementById('idPAS').value;
	var idCUS = document.getElementById('idCUS').value;
	
	var parQRY = 'LIF='+idLIF+'&VIE='+idVIE+'&VER='+idVER+'&MON='+idMON+'&PAS='+idPAS+'&CUS='+idCUS;
	
	OpenPopupScroll(500,500,0,0,'/asp/sez/src/lis.asp?'+parQRY);
	
}


function pulClick(OBJhid){
	OBJhid.value=1
	
}

function lnkURL(obj){
	var posQUE=location.href.indexOf('?');
	var urlLNK=location.href.substring(0,posQUE);
	
	location.href=urlLNK+obj.options[obj.selectedIndex].value;
}

function AUTtab(OBJtxt,NUMcar,NEXfie){
	if(OBJtxt.value.length==NUMcar){
		NEXfie.focus();
		}
	
}


function getURL(){
	
	var lnk = location.href;
	
	var qry = location.search;

	lnk = lnk.replace(qry,"");
	qry = qry.replace("?VDMidr=6&Nome=Cerca","");
	
	location.href = lnk+"?VDMidr=6&Nome=Cerca";
	
}


function ControllaForm () {
//Messaggio di errore se il form è vuoto
if (document.FormMotoreDiRicerca.CosaCerco.value=="")
{
alert("Inserire almeno una parola da cercare");
document.FormMotoreDiRicerca.CosaCerco.focus();
return false;
}
return true
}









