/*

'* version	:	1.02.04 	
'* last update	:	09.09.2004
*/
var bDEBUG = false;
var bEVALUATION=false;
var bW;

var szHTTP=window.location.protocol + "//" + window.location.hostname;

/* BEGIN section to modify following web server configuration */

if (bEVALUATION) {
   szHTTP='http://151.38.39.236:8080/projects/geoweb';
}
var szHOME = 'fgp/';
var szSCRIPTPATH = szHOME + 'bin/';
var szIMAGE= szHOME +'images/';

/* MAPPE configuration 

szHOME = 'geoweb2004/';
szSCRIPTPATH = 'cgi-win/geoweb/';
szIMAGE= szHOME +'images/'; 

*/
/* END section to modify following web server configuration */

bW=checkBrowser();



function checkBrowser()
{
   this.ver = navigator.appVersion;
   this.dom = document.getElementById ? 1 : 0;
   this.ie6= (this.ver.indexOf("MSIE 6") > -1 && this.dom) ? 1 : 0;
   this.ie6= (this.ver.indexOf("MSIE 7") > -1 && this.dom) ? 1 : this.ie6;
   this.ie5= (this.ver.indexOf("MSIE 5") > -1 && this.dom) ? 1 : 0;
   this.ie4=(document.all && !this.dom) ? 1 : 0;
   this.ns5=(this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
   this.ns4=(document.layers && ! this.dom) ? 1 : 0;
   this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns5);
   this.cookie=navigator.cookieEnabled;
   return this;
}

function setProperty(object, property,value)
{
  var obj;
  if (bW.dom)
    {
      obj=document.getElementById(object);
      if(eval("obj."+ property +"=\""+ value+"\"") == null)
	{
	 alert("error evaluating " + object + "." + property + "=\""+ value+"\"");
	}
    } 
 else if (bW.ver.indexOf("MSIE") > -1)
    {
      if(eval("document.all.obj."+ property +"=\""+ value+"\"") == null)
	{
	 alert("error evaluating " + object + "." + property + "=\""+ value+"\"");
	}
    }
 else 
    {
      alert("Il tuo browser non sopporta il Document Object Model. Aggiornalo o non sarà possibile proseguire");
    }
    
}

function getProperty(object, property)
{
  var obj;

  property = (property == null) ? "value" : property;

  if ( bW.dom) 
         { 
           obj=document.getElementById(object);
         }
     else if (bW.ver.indexOf("MSIE") > -1)
        {
         obj = document.all(object);
	}
     else 
      {
        alert("Il tuo browser non sopporta il Document Object Model. Aggiornalo o non sarà possibile proseguire");
        return null;
      }
    if (obj == null)
	{
          return null;
	}
     return eval("obj." + property);
}
function showHelp(helpPage, helpPageName, width, height)
    {
    var sz;
    sz = szHTTP + helpPage;
    window.open(sz,helpPageName,"toolbar=no,status=no,scrollbars=yes,directories=no,resizable=yes,resize=yes,menubar=no,height="+height+",width="+width);
    }

function toggle(e)
{   
   var obj;	// pointer to object
   var sz;	// text string
   var ex;	// pointer to "expand" image
   var red;	// pointer to "reduce" image
   var ex_alt;	// alternative text for "expand" image
   var red_alt;	// alternative text for "reduce" image
   if ( bW.dom) 
      {
        sz= e + "_uniform";
        obj=document.getElementById(sz);
	if (obj)
	  {
	    obj.style.display = obj.style.display == "none" ? "" : "none";         
	  }
        sz= e + "_note";
        obj=document.getElementById(sz);
	if (obj)
	  {
	   obj.style.display = obj.style.display == "none" ? "" : "none";         
          }
        sz= e + "_queue";
        obj=document.getElementById(sz);
	if (obj)
	  {
	   obj.style.display = obj.style.display == "none" ? "" : "none";         
          }
        sz= e + "_fmt";
        obj=document.getElementById(sz);
        ex = szIMAGE + "icon_expand.gif"
        red = szIMAGE + "icon_reduce.gif";
        ex_alt="Display in complete format";
        red_alt="Display in condensed format";     
        if (obj.alt == ex_alt) {
   	   obj.src= red;
	   obj.alt= red_alt;
        } else {
	   obj.src= ex;
	   obj.alt= ex_alt;
        } 	

   } else {
     sz= e + "_uniform";
     if (document.all[sz]) {
       obj=document.all[sz].style 
       obj.display = obj.display == "none" ? "" : "none";
     }
     sz= e + "_note";
     if (document.all[sz]) {
       obj=document.all[sz].style 
       obj.display = obj.display == "none" ? "" : "none";
     }
     sz= e + "_queue";
     if (document.all[sz]) {
       obj=document.all[sz].style
       obj.display = obj.display == "none" ? "" : "none";
     }
     sz= e + "_fmt";
     obj=document.all[sz];
     ex = szIMAGE + "icon_expand.gif"
     red = szIMAGE + "icon_reduce.gif";
     ex_alt="Display in complete format";
     red_alt="Display in condensed format";     
     if (bDEBUG) {alert(obj.src)};
     if (obj.alt == ex_alt) {
	obj.src= red;
	obj.alt= red_alt;
     } else {
	obj.src= ex;
	obj.alt= ex_alt;
     } 	
   }
}


function toggleSubMenus(objectID,bReverse)
{
  if (bReverse==1) 
     {
     setProperty(objectID,"style.background","#466f82")
     }
  else
    {
    setProperty(objectID,"style.background","#ffffff")
    } 
}

function getIndexService()
{
  var eI;	// element index
  var eV;	// element value

  var szV; // search value
  var szP; // search field
  var szS; // location to index service
  if (bW.dom) 
   {
     eV=document.getElementById('sv_1');
     eI=document.getElementById('sf_1');
   }
  else
   {
     eV = document.all.sv_1.value;
     eI = document.all.sf_1.value;
   }

  szV = eV.value;
  szF = eI.value;
  switch (szF) {
    case "005-AUTHOR":
	szF="V";
	break;
    case "055-DATE_P":
	szF="D";
	break;
    case "010-OBJECT":
	szF="T";
	break;
    case "010-TITLE":
    case "010-ALLTITLE":
	szF="B";
	break;
    default:
	szF="";
  }
  if (szF != "") {
     szS = szHTTP;
     szS += "/"+arguments[0];
     szS += szF;
     szS += (szV !="") ? "" + szV : "FIRST";
     window.location=szS;
   } else {
     if (bDEBUG) {alert("For this field there is no index service available")};
   }
}

/*
this function add an item to the basket
history: 2.001	NNSMRT 19.09.2006
                Customized for Fiesole musei project; now accept also records without multimedia attachment
*/

function addToBasket(b)
{
  var bid; // string containing bid
  var bL =new Array; // list of BID
  var f = null;
  var i; // counter for cycle
  var mmL = new Array;
  var p = null;
  var s = null;
  var t = null;
  var v = null;
  var today = new Date();   
  var expires = new Date();
  expires.setTime(today.getTime() + 1000*60*60*24*1);  // set expire time to one day
  expires=null;

  if (!bW.cookie)
    {
       alert("E' necessario accettare i cookies per poter utilizzare questa funzione");
    }
 // retrieve multimedia file list from page in the form "<mmid>=ok"

  for (i = 1 ; ; i++) 
    {
      f=getProperty(b + "_" + i,null);
      if (f != null) 
      { 
	/* check following */
       s = (s == null) ? f : s + "&" + f;
       mid=f.substring(0,6); // keep only mmid and store description for each one
       mid +="_d";
       if (bDEBUG) {alert("addToBasket: adding description for mid [" + mid + "] " + unescape(getProperty(mid,null)))};
       p= getProperty(mid,null) ;
       p= ( p == null || p == "") ? "documento completo" : "testo e immagini (" + p + ")";
       setMMID(mid, unescape(p),expires);
      }
     else 
      {
       /* this is the customized condition for record without multimedia attachments
          check need to be just on first (i=1) item equals to null
        */
       if (i==1) 
	{
          setMMID(b.substring(4)+"_d", unescape("solo testo"),expires);
          s = b.substring(4)+"=ok"; 
        }
       break;
      }
   }
  // read stored cookie, if any
  v = getMMIDS("mmids");
  // initialize cookie string for key "mmid" (should be in the form "[bid]:"
  s = b + ":" + s;
  if (bDEBUG) {alert("addToBasket: initialize cookie mmid current string '" + s + "'")};
  setMMID(b + "_t", unescape(getProperty(b + "_t",null)),expires); // store title for bid
  if (bDEBUG) {alert("addToBasket: adding description for bid '" + b + "' " +  unescape(getProperty(b + "_t",null)))};
  if (bDEBUG) {alert("addToBasket: compairing v value (ODlist) againts null '" + v + "'")};
  v = (v != null) ? v.substring(1,v.length) : s ;
  if (bDEBUG) {alert("addToBasket: s="+s)};
  if (bDEBUG) {alert("addToBasket: complete cookie mmid string '" + v + "'")};
  // compare stored cookie with multimedia file list
  if (v != s) { // there is something registered
     if (bDEBUG) {alert("addToBasket: trying to add '" + s + "'")};
     bL = v.split("|"); // get BID list
     if (bDEBUG) {alert("addToBasket: this should be the registered value '" + v + "'")};
     if (bDEBUG) {alert("addToBasket: number of registered BID '" + bL.length + "'")};
     if (bL.length) {
        v=null; // rebuild cookie string
        for (i = 0 ; i < bL.length ; i++) {  
           if (bDEBUG) {alert("addToBasket: parsing contents for registered bid '" + bL[i].substring(0,10) + "'")};
           if (bL[i].substring(0,10) == b) { // compare with the new one
               if (bDEBUG) {alert("addToBasket: this registered value '" + bL[i] + "' should contain the new one '" + b + "'")};
               mmL= bL[i].split("&");
               if (bDEBUG) {alert("addToBasket: number of registered mmid for bid '" + mmL.length + "'")};
               v= (v != null) ? v + "|" +  s : s;
            } else {
              v = (v != null) ? v + "|" + bL[i] : bL[i] ;
	      if (bDEBUG) {alert("addToBasket: rebuilding cookie string '" + v + "'")};
            }
        }
         // if s is not contained in the rebuiled cookie string then add s
        v = (v.indexOf(b) == -1) ? v + "|" + s : v;
     } else {
       if (bDEBUG) {alert("addToBasket: error '" + v + "'")};
     }
  }
  if (bDEBUG) {alert("addToBasket: adding '" + v + "'")};
  setMMID("mmids", v,expires);
  if (bDEBUG) {alert("I materiali documentali della scheda " + b + " sono stati aggiunti alla lista")}; 
  checkExport();
}

function setMMID(name, value, expire) 
  {
   document.cookie = name + "=" + 
		escape(value)   + 
		((expire == null) ? "" : ("; expires=" + expire.toGMTString())) +
		"; path=/";
}

function getMMIDS(cookiesName) 
{
 var end;
 var search = cookiesName;
 if (document.cookie.length > 0) { // if there are any cookies      
   offset = document.cookie.indexOf(search);       
   if (offset != -1) { // if cookie cookieName exists          
      offset += search.length; // set index of beginning of value      
      end = document.cookie.indexOf(";", offset); // set index of end of cookie value 
      if (end == -1) {
	 end = document.cookie.length;
      }
      return unescape(document.cookie.substring(offset, end));    
   }
 } 
 return null;
}

function editShoppingBag()
{
  var b; // bid
  var bL=new Array(); // list of bid selected
  var j; // counter for sub loop
  var i; // counter for loop
  var m="";
  var mmL=new Array(); // list of multimedia file(s)
  var o;  // temporary object
  var s; //  text string
  var t; //  text string
  v = getMMIDS("mmids");
  if (v==null) {return;}
  v = v.substring(1,v.length);
  if (bDEBUG) {
	alert("registered cookie " + v)
  };
  bL = v.split("|");
  if (bL.length) {
     v=null;
     for (i = 0 ; i < bL.length ; i++) {  
	 b = bL[i].substring(0,10);
         if (bDEBUG) {alert("parsing contents for bid " + b)};
	 s = getMMIDS(b + "_t");
	 if (bDEBUG) {
	    alert(s)
	 };
         s = (s != null) ? s.substring(1) : b;

         m +="<li>" + s; 

         bL[i]=bL[i].substring(11);
         mmL= bL[i].split("&");        
         for (j = 0 ; j < mmL.length ; j++) {
             s= '<input class="order_input" ' +
		 'name="' + b + '_' + j + '" ' +
		 'id="' + b + '_' + j + '" ' +
	         'size="1" ' +
		 'type="checkbox" value="1" ';
	     s += (mmL[j].indexOf("ok") != -1) ? 'checked="checked"/>' : '>';
	     if (bDEBUG) {alert("request description for mid " + mmL[j].substring(0,6))} ;
	     t = getMMIDS(mmL[j].substring(0,6) + "_d");
             t = (t != null) ? t.substring(1) : mmL[j].substring(0,6);		
	     if (bDEBUG) {alert(t)};
	     s += t;
             /*s +=( document.all(mmL[j].substring(0,6)) != null ) ? 
                  "&nbsp;[" + unescape(document.all(mmL[j].substring(0,6)).value) +"&nbsp;" 
	          : mmL[j].substring(0,6);*/

             m +="<ol>" + s +"</ol>"
            }
         m += '</li>';
         }
   }
   if (bDEBUG) {alert(m)};
   mW=window.open('','FIEEditing','height=500, width=600, scrollbars');
   mW.document.writeln(getHeader('Geoweb :: Percorsi :: Documentazione assistita'));
   if (m != "") {
       s = "Sono stati richiesti i materiali documentali delle seguenti schede<p/>" + m +"</ul><p/>";
   } else {
     s = "Nessun materiale documentale selezionato!<p/>";
   }
   mW.document.writeln(s);
   s = '<input class="standard_button" type="button" onclick="modifyExport(-1);window.close();" ' +
       'value="chiudi"/>&nbsp;';
   s += '<input class="standard_button" type="button" onclick="submitExport();" ' +
        'value="anteprima"/>&nbsp;';
   s += "</body></html>";
   mW.document.writeln(s);
   if (this.ie6)
    {
	 mW.location.reload(); // need for IE (hangup else); avoid with Firefox (stop else)
    }
   mW.document.close();
}

function zoomImage(imageName)
{
   popImage(szHTTP + "/"  + imageName,"TheAxe");

}

function getButtonClose()
{
   var s;
   s = '<div style="margin-left:auto; margin-right:auto;width:6em;">' +
       '<input class="standard_button" type="button" ' +       'onclick="modifyExport(-1);window.close();" ' +
       'value="chiudi"/></div>';
   return s;
}
function modifyExport(bClose)
{
  var bL=new Array(); // list ov bid selected
  var expires = new Date();
  var j; // counter for sub loop
  var i; // counter for loop
  var m="";
  var mmL=new Array(); // list of multimedia file(s)
  var r;	// registered order
  var s=null;
  var today = new Date();   
  expires.setTime(today.getTime() + 1000*60*60*24*1);  // set expire time to one day
  expires=null;
  r = getMMIDS("mmids");
  if (r == null) {return;}
  r = r.substring(1);
  if (bDEBUG) {alert("modifyExport.r=" + r)};
  bL = r.split("|")
  if (bL.length) {
     for (i = 0 ; i < bL.length ; i++) {  
 	 b = bL[i].substring(0,10);
         s = ( s == null) ? b : s + "|" + b;
         s += ":";
         bL[i]=bL[i].substring(11);
         mmL= bL[i].split("&");
         for (j = 0 ; j < mmL.length ; j++) {
   	    s += mmL[j].substring(0,6) + "=";
   	    s += getProperty(b + "_" + j,"checked") ? "ok" : "no";
            if (bDEBUG) {alert("modifyExport.b+_+j=" + b + "_" + j)};	  
	    s += (j < (mmL.length-1)) ? "&" : "";
            if (bDEBUG) {alert("modifyExport.s=" + s)};	  
	    }
      }
 }

 setMMID("mmids", s,expires);
 if (! bClose) {
    return getMMIDS("mmids");
  }
}

function submitExport()
{
   var a= new Array;
   var i; // counter for loop
   var lang; // language
   var r;
   var s; // text string
   var session; // session id
   var uid; //	user id
   var url;   //
   s=window.location.search.substring(1);
   a=s.split('&');
   if (a.length>1) {
      for (i=0; i< a.length ; i++) {
           s=a[i];
	   p=s.indexOf("=");
           switch (s.substring(0,p) ){
              case "lang":
                lang=s.substring(5);
	        break;
	      case "uid":
                uid=s.substring(4);
		break;
	      case "session":
                session=s.substring(8);
		break;
	   }
        }
   }
   r = modifyExport(0);
   r = r.substring(1);
   url= szHTTP;
   url += "/" + szSCRIPTPATH + "archiweb.dll?";
   url += "service=export";
   url +="&lang=" + lang;
   url +="&uid=" + uid;
   url += "&session=" + session;
   url += "&inner=1";
   if (bDEBUG) {alert("url=" + url)};
   if (bDEBUG) {alert("r=" + r)};
   bL = r.split("|");
   if (bL.length) {
     r="";
     for (i = 0 ; i < bL.length ; i++) {  
	 if (bDEBUG) {alert("complete string " + bL[i])};
         bL[i]=bL[i].substring(11);
	 if (bDEBUG) {alert("string without bid " + bL[i])};
         mmL= bL[i].split("&");        
         for (j = 0 ; j < mmL.length ; j++) {
	     if (bDEBUG) {alert("mmid string " + mmL[j])};
	     s = (mmL[j].indexOf("ok") != -1) ? mmL[j].substring(0,6) : "";
	     if (bDEBUG) {alert("s = ["+s+"]")};
  	     r = (r == "") ? 
		 s : 
		 (s == "") ? r : r + ";" + s;		       		
	     if (bDEBUG) {alert("r = ["+r+"]")};
            }
         }
   }
   if (bDEBUG) {alert(r)};
   url += "&mid=" +r;
   if (bDEBUG) {alert(url)}; 
   window.location=url; 
}

function getHeader(title)
{
 var szHTML;

   szHTML= '<?xml version="1.0" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
           '<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">' + 
           '  <head>' +
           '    <title>' + title + '</title>' +     
    	   '    <base href="' + szHTTP + '"/>' +
           '    <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"/>' +
  	   '    <link href="' +szHOME + 'fie____1.css"'+
           '           rel="stylesheet" type="text/css"/>' +
	   '    <script type="text/javascript" src="' + szHOME + 'arw.js"></script>' + 
           '   </head>' + 
           '   <body onload="self.focus();">' +
           '<!--Begin Area "Banner of "' + title + '"-->' +
           '      <img alt="The ARCHIweb Logo" '+
	   '         src="' + szIMAGE + 'arw_cban.gif"/>' +
           '   <!--End Area "Banner of "'  + title + '"-->' +
	   '<p/>'; 
   return szHTML;
}

function fillSubjectList()
{
  var eK;	// element keyfield
  var eL	// element subject list
  var s;	// subject label
  var v;	// subject value
  var w;	// typed word  

  if (bW.dom)
    {
      eK=document.getElementById("fldKeyField");
      eL=document.getElementById("sv_subjectList");
    }
   else
    {
      eK=document.all.fldKeyField;
      eL=document.all.sv_subjectList;
    }

  w = new String(eK.value);
  alert(w);
  for (i = 0 ; i < eL.length ; i++) {
     s= new String(eL.options[i].text);
     s= s.toLowerCase();
     w= w.toLowerCase();
     if (s.indexOf(w)>=0) {	
	v=eL.options[i].value;
	addToList(v,s,w);
     }
   }
}
function synchronize()
{
  var i=0;
  var eS;	// element subject	
  var eSS;	// element selected subject	

  if (bW.dom)
    {
      eS=document.getElementById("sv_subjects");
      eSS=document.getElementById("fldSubjectselected");
    }
   else
    {
      eS=document.all.sv_subjects;
      eSS=document.all.fldSubjectselected;
    }

   
   if (eS.length > 0)
    {
     for (var j = 0 ; j < eS.length ; j++) 
	{
          if (eS.options[j].selected==true &
	      eS.options[j].text != "") 
           {
            i++;
           } 
         }
     eSS.value=i;
    }
}

function resetSubjectList()
{
  var i=0;
  var eS;	// element subject	
  var eSS;	// element selected subject	

  if (bW.dom)
    {
      eS=document.getElementById("sv_subjects");
      eSS=document.getElementById("fldSubjectselected");
    }
   else
    {
      eS=document.all.sv_subjects;
      eSS=document.all.fldSubjectselected;
    }

      do
       {
        eS.options[0].selected=false;
        eS.options[0]=null;
        eSS.value=0;
       } while (eS.length > 0)
}

function addToList()
{
   var oCount;	// counter of Options
   var option;	// multiple list option
   var text;	// subject text
   var value;	// subject value
   value = arguments[0];
   text = arguments[1];

  if (bW.dom)
    {
      eS=document.getElementById("sv_subjects");
      eSS=document.getElementById("fldSubjectselected");
    }
   else
    {
      eS=document.all.sv_subjects;
      eSS=document.all.fldSubjectselected;
    }


   oCount=eS.options.length;

   option = new Option(text, value);
   eS.options[oCount]=option;      
   if (arguments[2] != "") {
      eS.options[oCount].selected=true;
      eSS.value=oCount+1;
   }
 }
function querySubject()
{
  var s;
  var m="";
  var mW;
  for (var j = 0 ; j < document.all.sv_subjects.length ; j++) {
       s= new String(document.all.sv_subjects.options[j].text);
       if (document.all.sv_subjects.options[j].selected==true &
	   s != "") {
	   m += "<li>"+ s + "</li>";
       } 
   }
   mW=window.open("","FIESMessage",'dependent=yes, height=200, width=300, scrollbars');
   mW.document.write("<head><title>FIE server message</title></head>");
   if (m != "") {
       s = "Hai selezionato i seguenti soggetti<p>" +"<ol>"+m+"</li><p>";
   } else {
     s = "Nessun soggetto è stato selezionato!<p>";
   }
     mW.document.write(s);
   mW.document.write('<input align="center" type="button" onclick="window.close()" value="close this window"/>');
}

function openLoginWindow()
{

   mW=window.open("","ARCHIweb_Login",'dependent=yes, height=200, width=600, scrollbars');
   mW.document.write(getHeader('ARCHIweb - login'));

  // *** login

   s ='<form action="' + szSCRIPTPATH + 'archiweb.dll?service=login&amp;lang=1&amp;calling=welcome&amp;uid=000000&amp;session=000000" method="post">' + 
      '<!-- Begin Area " User Validation" -->' +
      '<table class="login_table" border="0" width="100%"  cellpadding="0" cellspacing="0" ' +
      'bgcolor="#c8c8c8">' +
      '<tr>' +
	'<td class="login_label" ' +
	'align="left" width="15%">' +
	'<img src="' +szIMAGE + 'login.gif" ' +
	'alt="Register if you\'re not" ' +
	' border="0"/></td>' +
	'<td class="login_label" ' +
	'align="left" width="15%">' +
	'<label for="username" ' +
	'accesskey="U">' +
	'<i>Username</i></label></td>' +
	'<td class="login_input" ' +
	'align="left" width="10%">' +
	'<input alt="Username" ' +
	'name="USER_NAME"' +
	'value="" ' +
	'id="username" ' +
	'size="12" ' +
	'maxlength="6"/></td>' +
	'<td class="login_label" ' +
	'align="left" width="15%">' +
	'<label for="password" ' +
	'accesskey="P"><i>' +
	'Password</i></label></td>' +
	'<td class="login_input" ' +
	'align="left" width="10%">' +
	'<input alt="password" ' +
	'type="password" ' +
	'name="USER_PASS1" ' +
	'id="password" ' +
	'size="12" ' +
	'maxlength="8"/></td>' +
	'<td class="form_button" ' +
	'width="15%">' +
	'<input alt= "Login" ' +
	'accesskey="S" type="submit" ' +
	'value="Login"/></td>' +
	'</tr>' +
	'</table>' +
	'<input name="service" size="0" type="hidden" value="login"/>' +
'<!-- End Area " User Validation" -->' +
'</form>';
   mW.document.write(s);
   s = '<p align="center"><a href="javascript:startSession();">Begin an  anonymous session</a></p></body></html>';
   mW.document.write(s);
   mW.location.reload();

}

function startSession()
{
  var uid;	// user id
  var session;	// session id
  if (document.all.uid) {
     uid = document.all.uid.value;
     session = document.all.session.value
  } else {
    uid = "000000";
    session="000000";
  }
  window.opener.document.all.uid.value=uid;
  window.opener.document.all.session.value=session;
  window.close();
}

function designQueryForm()
{
   var l;	// user select language   
   var q;	// query string
   var l;	// location
   var uid;	// userid
   var session;	// session id
   uid= document.all.uid.value;
   session= document.all.session.value;
   q= "?service=query&amp;lang=" + arguments[0] + "&amp;uid=" + uid + "&amp;session=" + session + "&amp;inner=1";
   l = szHTTP;
   l += "/" + szSCRIPTPATH + 'archiweb.dll'; 
   l += q;
   window.location=l;
 }

function checkExport()
{
  var s;
  r = getMMIDS("mmids");
  if (r==null) {return;}
  r = r.substring(1);
  if (bDEBUG) {alert(r)};
  bL = r.split("|")
  if (bL.length) 
   {
    
     s="Schede documentali pronte per l'" +
			     "<a href='javascript:editShoppingBag();'> esportazione</a>: " + bL.length ;

     setProperty("exportLabel","innerHTML",s)
   }
}


function winpop(resource)
  {
   top.consoleRef=window.open(resource, null,'toolbar=yes,status=yes,scrollbars=yes,width=800,height=600px,resizable=yes,left=200px')
   top.consoleRef.focus();
  }

function toggleView(id)
{
  view=document.getElementById(id);
  view.style.display = (view.style.display == "none") ? "block" : "none";

  /* workaround for toggle curriculum icon in DBV */

  var iid= (id=='curriculum') ? "toggleIcon" : id + "_img";
  icon=document.getElementById(iid);
  if (icon.src.indexOf("icon_expand.gif") > 0)
    {
      icon.src= icon.src.replace("icon_expand.gif","icon_reduce.gif");
    }
  else
   {
      icon.src= icon.src.replace("icon_reduce.gif","icon_expand.gif");
   }
}

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
var xcoord = (isNN) ? window.innerWidth :  document.body.clientWidth;
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
writeln('width=300-(document.body.clientWidth-document.images[0].width);');
writeln('height=300-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["EvaViewer"].width;');writeln('window.innerHeight=document.images["EvaViewer"].height;}}');
writeln('function moveWindow(){');writeln('window.moveTo(' + (xcoord-300) + ',100)}');

writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();moveWindow();self.focus()" onblur="self.close()">');
writeln('<img name="EvaViewer" src='+imageURL+' style="display:block"></body></html>');
close();		
}}




