/* ---------------------------------------------------------------- */
/* Global variables                                                 */
/* ---------------------------------------------------------------- */
var mybasehref = ""; 
var mycss = mybasehref.concat("meta/mkcss.css"); 
var nav = navigator.appName;
( nav.match(/microsoft/i) ) ? ie=0 : ie=1 ; 

/* ---------------------------------------------------------------- */
/* Localization of JS strings                                       */
/* ---------------------------------------------------------------- */
var l10n = new Array(); 

l10n["Close_this_window"] = new Array(); 
l10n["Close_this_window"]["en"] = "Close this window";
l10n["Close_this_window"]["fr"] = "Fermer la fen&ecirc;tre";

l10n["no_title"] = new Array(); 
l10n["no_title"]["en"] = "No Title";
l10n["no_title"]["fr"] = "Sans titre";

l10n["Paintings"] = new Array(); 
l10n["Paintings"]["en"] = "Paintings";
l10n["Paintings"]["fr"] = "Peintures";

l10n["ref"] = new Array(); 
l10n["ref"]["en"] = "ref.";
l10n["ref"]["fr"] = "r&eacute;f.";

/* ---------------------------------------------------------------- */
/* mkill - Popup for illustrations                                  */
/* ---------------------------------------------------------------- */
mkillon=false;
function mkill(fn,wi,he,ti,le,rf,zo) { // filename, width, height, title, legend, reference, zoom
 imgfile=false;
 if (fn.match(/\.(bmp|gif|jpg|jpeg|png)$/i)) { // image file 
  imgfile=true;
 }
 wprm = "scrollbars=yes,resizable=yes,dependent";
 if (fn.indexOf("http://") != 0) { fn = mybasehref.concat(fn); } 
 // alert('wi:'+wi+' - he:'+he);
 if (!wi) wi="600";
 if (!he) he="450";
 if (!ti) ti="";
 if (!le) le="";
 if (!rf) rf="";
 if (imgfile) {
  iprm = "src=\"" + fn + "\" border=2";
  tprm = "\"100%\""
  if (!ti) { ti = "&#8212; " + l10n["no_title"][lg] + " &#8212;"; }
 }
 if (wi > 0) {
  winw = Math.round(wi*1.2);
  if (winw < 900) wprm += ",width=" + winw ;
   else wprm += ",width=900" ; 
  //if (imgfile) iprm += " width=" + wi ;
  tprm = eval(wi) + 8;
 }
 if ( he > 0 ) {
  winh = Math.round(he*1.2)
  if (imgfile && (le.length > 0)) winh += 40;
  if (winh < 700) wprm += ",height=" + winh ; 
   else wprm += ",height=700" ; 
  //if (imgfile) iprm += " height=" + he ;
 }
 if (mkillon) {
  ill.close(); mkillon=false; 
 }
 // alert('wprm:'+wprm);
 if (imgfile) { // image file
  ill = window.open("","mkill",wprm); 
  ill.document.open();
  ill.document.write('<html><head><title>Mirna Kre&#x0161;i&#x0107; -- ' + l10n["Paintings"][lg] + '</title>');
  ill.document.write('<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">');
  ill.document.write('<link type="text/css" rel="stylesheet" href="'+mycss+'">\n'); 
  ill.document.write('</head>\n');
  (zo) ? colspanvar=1 : colspanvar=0 ;
  ill.document.write('<body><div id="mkill"><center><table border="0" width='+tprm+'>');
  ill.document.write('<tr><td colspan="'+eval(1+colspanvar)+'" class="mkillti">'+ti+'</td>');
  ill.document.write('<td align="right" class="mkilllk">[&nbsp;<a href="javascript:self.close();">' + l10n["Close_this_window"][lg] + '</a>&nbsp;]</td></tr>\n');
  ill.document.write('<tr><td align="center" colspan="'+eval(2+colspanvar)+'"><img id="mk_img" name="mk_img" ' + iprm + '></td></tr>\n');
  ill.document.write('<tr><td class="mkillle">'+le+'</td>\n'); 
  if (zo) {
   (ie==0) ? cursor_name = "hand" : cursor_name = "pointer" ; 
   ill.document.write('<td width="40%" align="center" class="mkillle">');
   ill.document.write('<span style="font-weight:700" onMouseOver="this.style.color=\'maroon\';this.style.cursor=\''+cursor_name+'\'" onMouseOut="this.style.color=\'#333\'" onClick="document.mk_img.src=\''+fn+'\'">Original</span>'); 
   for (zo_item=0; zo_item<zo.length; zo_item++) {
    ill.document.write(' - <span style="font-weight:700" onMouseOver="this.style.color=\'maroon\';this.style.cursor=\''+cursor_name+'\'" onMouseOut="this.style.color=\'#333\'" onClick="document.mk_img.src=\''+zo[zo_item]+'\'">Zoom&nbsp;'+(zo_item+1)+'</span>');
   }
   ill.document.write('</td>\n');
  }
  ill.document.write('<td align="right" class="mkillle">[&nbsp;'+l10n["ref"][lg]+' '+rf+'&nbsp;]</td></tr>\n');
  ill.document.write('</table></center></div></body></html>\n');
  ill.document.close();
 } else { // text file
  ill = window.open(fn,"mkill",wprm); 
 }
 mkillon=true; ill.focus();
}

/* ---------------------------------------------------------------- 
   showid - unfold/fold content of element eid
   ---------------------------------------------------------------- */
function showid(eid) {
 var whichid = document.getElementById(eid).style.display;
 if ( whichid == 'none' ) {
  document.getElementById(eid).style.display = 'block';
 } else {
  document.getElementById(eid).style.display = 'none';
 }
}

/* ---------------------------------------------------------------- 
   errmsgwin - popup for error messages
   ---------------------------------------------------------------- */
function errMsg(url, name) {
 var errMsgWin = window.open(url, name, "resizeable=no,scrollbars=yes,width=500,height=150"); 
 return errMsgWin; 
}

