// athanatoi.es General Script
// Created by Alberto Martinez Perez (http://www.ampsoft.net/web-works/)

// ***** Popup windows *****

var WINDOW_TOP=10, WINDOW_LEFT=10, SYSTRAY_HEIGHT=64, WINDOW_TITLEBAR=24;

var lastPopup=null;

function openPopup(page,targetWindow,width,height,scrollBars,resizable){
  var options=new String(), scroll=new String("no"), resize=new String("no");

  if (scrollBars) scroll="yes";
  if (resizable) resize="yes";
  options="width="+width+",height="+height+",top="+WINDOW_TOP+",left="+WINDOW_LEFT+
    ",status=no,location=no,toolbar=no,menubar=no"+",resizable="+resize+",scrollbars="+scroll;
  lastPopup=window.open(page,targetWindow,options,true);
  lastPopup.window.focus();
  return lastPopup;
}


function showImage(path) {
 totalWidth=600+100;
 if (totalWidth>screen.width-WINDOW_LEFT-8)
   totalWidth=screen.width-WINDOW_LEFT-8;
 totalHeight=600+50;
 if (totalHeight>screen.height-WINDOW_TOP-SYSTRAY_HEIGHT-WINDOW_TITLEBAR)
   totalHeight=screen.height-WINDOW_TOP-SYSTRAY_HEIGHT-WINDOW_TITLEBAR;
 openPopup(path,"Images",totalWidth,totalHeight,true,true);
 return false;
}


// ***** Display adjustments *****
// Script by Alberto Martinez Perez (http://www.ampsoft.net/)

var targetElementID="main", targetElementStyleOffset=35;

function adjustHeight() {
  if (document.getElementById) {
    var targetElement=document.getElementById(targetElementID),
        documentHeight, totalOffset;

    if (targetElement) {
      documentHeight=document.documentElement.offsetHeight;
      if (targetElement.offsetHeight<documentHeight-targetElement.offsetTop) {
        totalOffset=targetElement.offsetTop+targetElementStyleOffset;
        targetElement.style.height=String(documentHeight-totalOffset)+'px';
      }
    }
  }
}

window.onresize=adjustHeight;
window.onload=adjustHeight;



// ***** Misc *****

function maskedEmail(domain,text,name,suffix) {
 var address=name+'@'+domain+'.'+suffix;
 if (text=="") text=address;
 document.write('<a hr'+'ef="ma'+'i'+'lto:'+address+'">'+text+'</a>');
}


// athanatoi.es General Script
// Created by Alberto Martinez Perez (http://www.ampsoft.net/web-works/)
