function getEle(aID){ 
  return document.getElementById(aID) || document.all[aID];
  
}



// LOGIN
function LogIn() {
	var data = new Date();
	var ora = data.getTime();
	var rnd = Math.round((Math.random()*100000000));
	
	var codiceutente = document.LogForm.user.value + '|' + ora + '|' + rnd;
	
	
	document.LogForm.passy.value = codiceutente;
	
	SaveCookie ('LogIn', codiceutente);
	var dest = document.URL;
	var ult = dest.slice(dest.length-1,dest.length)
	if (ult=='/') {dest = dest + 'index.asp';}
	document.LogForm.action = dest;

}




// LOGOUT
function LogOut() {
	//var ExpireDate = new Date();
	//ExpireDate.setTime (ExpireDate.getTime() + (24 * 60 * 60 * 1000 * 31));
	
	document.cookie = 'pass=; path=/; domain=.roba.coop; expires=Thu, 01-Jan-1970 00:00:01 GMT';
	document.cookie = 'user=; path=/; domain=.roba.coop; expires=Thu, 01-Jan-1970 00:00:01 GMT';
	document.cookie = 'passy=; path=/; domain=.roba.coop; expires=Thu, 01-Jan-1970 00:00:01 GMT';
	document.cookie = 'RobaOrder=; path=/; domain=.roba.coop; expires=Thu, 01-Jan-1970 00:00:01 GMT';
	document.cookie = 'Mittente=; path=/; domain=.roba.coop; expires=Thu, 01-Jan-1970 00:00:01 GMT';
	document.cookie = 'Destinazione=; path=/; domain=.roba.coop; expires=Thu, 01-Jan-1970 00:00:01 GMT';
	document.cookie = 'Mail=; path=/; domain=.roba.coop; expires=Thu, 01-Jan-1970 00:00:01 GMT';
	document.cookie = 'Note=; path=/; domain=.roba.coop; expires=Thu, 01-Jan-1970 00:00:01 GMT';
	//var sURL = unescape(window.location.pathname);
	//window.location.href = sURL;

}




// SAVE COOKIE
function SaveCookie (Nome, Valore) {
         var argv = SaveCookie.arguments;
         var argc = SaveCookie.arguments.length;
         var Scadenza = (argc > 2) ? argv[2] : null;

         document.cookie = Nome + '=' + escape(Valore) + '; path=/; domain=.roba.coop' +
         ((Scadenza == null) ? '' : ('; expires=' + Scadenza.toGMTString()))

}




// OPEN WINDOW
function OpenWindow(sFile, iWidth, iHeight) {
	var sSize = 'width=' + iWidth + ',height=' + iHeight + ',resizable' + ',scrollbars';
	var newWindow = window.open(sFile,'',sSize);

}




// OPEN TOOL
function OpenTool(sFile, iWidth, iHeight) {
	var sSize = 'width=' + iWidth + ',height=' + iHeight + ',location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=0, toolbar=0 ';
	var newWindow = window.open(sFile,'',sSize);

}



// OPEN IMG
function OpenIMG(sFile, iWidth, iHeight) {
	iiWidth = iWidth + 30;
	iiHeight = iHeight + 70;
	var sSize = 'width=' + iiWidth + ',height=' + iiHeight + ',location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=0, toolbar=0 ';
	var newWindow = window.open('','',sSize);
	var sPath = sFile.split('IMG/');
	newWindow.document.writeln('<html>');
	newWindow.document.writeln('<head>');
	newWindow.document.writeln('<META content=\"ROBA\" name=\"description\">');
	newWindow.document.writeln('<META http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">');
	newWindow.document.writeln('<META http-equiv=\"Content-Script-Type\" content=\"text/javascript\">');
	newWindow.document.writeln('<META http-equiv=\"Content-Style-Type\" content=\"text/css\">');
	newWindow.document.writeln('<link rel=\"stylesheet\" type=\"text/css\" href=\"st/stROBA.css\">');
	newWindow.document.writeln('<SCRIPT language=\"JavaScript\" src=\"/js/base.js\"></SCRIPT>');
	newWindow.document.writeln('<title>ROBA</title>');
	newWindow.document.writeln('</head>');
	newWindow.document.writeln('<body bgcolor=\"#FFFFFF\">');
	newWindow.document.writeln('    <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber2\">');
	newWindow.document.writeln('      <tr>');
	newWindow.document.writeln('        <td align=\"center\" width=\"100%\">');
	newWindow.document.writeln('        <img border=\"0\" src=\"" + sFile + "\" width=\"" + iWidth + "\" height=\"" + iHeight + "\" >');
	newWindow.document.writeln('        </td>');
	newWindow.document.writeln('      </tr>');
	newWindow.document.writeln('      <tr>');
	newWindow.document.writeln('        <td align=\"center\" valign=\"top\" width=\"100%\" height=\"50\">');
	newWindow.document.writeln('        <img border=\"0\" src=\"' + sPath[0] + 'IMG/ICO/IcoChiudi48x48.gif\" onmouseout=\"this.src=\'' + sPath[0] + 'IMG/ICO/IcoChiudi48x48.gif\';\" onmouseover=\"this.src=\'' + sPath[0] + 'IMG/ICO/IcoChiudi48x48_.gif\'; this.style.cursor=\'hand\';\" width=\"48\" height=\"48\" onclick=\"window.close();\"></td>');
	newWindow.document.writeln('      </tr>');
	newWindow.document.writeln('    </table>');
	newWindow.document.writeln('</body>');
	newWindow.document.writeln('</html>');
}





// SWITCH BLOCK
function SWBK(bkName) {

		 if (document.all[bkName].style.display == 'none')
			{
		 	document.all[bkName].style.display = 'inline';
			}
		 	else
			{
			document.all[bkName].style.display = 'none';
			}

var PercorsoFile = document.URL;
var NomeFile = PercorsoFile.split('/');
var Nome = NomeFile[NomeFile.length-1].split('.asp');
var NomeCookie = Nome[0]+'_'+bkName
SaveCookie (NomeCookie, document.all[bkName].style.display)

}






// SAVE ELEMENT
function SaveElement(ElName, ElValue) {

var PercorsoFile = document.URL;
var NomeFile = PercorsoFile.split('/');
var Nome = NomeFile[NomeFile.length-1].split('.asp');
var NomeCookie = Nome[0]+'_'+ElName
SaveCookie (NomeCookie, ElValue)

}



// MODIFY CMD STRING
function ModRegString(Stringa, Chiave, Valore) {
var ckModify = false;
var NewStringa = '';
var aCookie = Stringa.split('_');
for (var i=0; i < aCookie.length; i++)
  {var aCrumb = aCookie[i].split(':');
	    if (Chiave == aCrumb[0]) {
	    	ckModify = true;
	    	NewStringa = NewStringa + Chiave + ':' + Valore;
	    	if (i+1 < aCookie.length) {NewStringa = NewStringa + '_'};
	    	}
	    	else {
	    	NewStringa = NewStringa + aCookie[i];
	    	if (i+1 < aCookie.length) {NewStringa = NewStringa + '_'};
	    	}
   }
   if (aCookie.length <= 1) {NewStringa = aCookie[0]};
   if (ckModify  == false) {NewStringa = NewStringa + '_'+Chiave+':'+Valore};
   return NewStringa;
}



function toggle(box_name) {

obj=document.getElementById(box_name);
obj.style.display = (obj.style.display=='none') ? '' : 'none';


}




function calcHeight(nome_frame,h_min)
{
	if (top.document.getElementById(nome_frame)) {
	var i_height = top.document.getElementById(nome_frame).contentWindow.document.body.scrollHeight;
	if (i_height < h_min) [i_height = h_min]
	top.document.getElementById(nome_frame).height = (i_height);
	}
}


