// AMPsoft General Script
// Created by Alberto Martinez Perez (http://www.ampsoft.net/)

// WINDOW & PARAMETERS
var WINDOW_TOP=15, WINDOW_LEFT=15, SYSTRAY_HEIGHT=56, WINDOW_TITLEBAR=24;

var lastPopup=null;

function OpenPopup(Page,Window,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+
  ",screenY="+WINDOW_TOP+",top="+WINDOW_TOP+",screenX="+WINDOW_LEFT+",left="+WINDOW_LEFT+
  ",status=no,location=no,toolbar=no,menubar=no,hotkeys=no"+
  ",resizable="+Resize+",scrollbars="+Scroll;
 lastPopup=window.open(Page,Window,Options,true);
 lastPopup.window.focus();
 return lastPopup;
}


function ExtractParameters(Str) {
 var SubStrings;
 Str=Str.substring(1,Str.length);// to eliminate the '?'
 SubStrings=Str.split("&");
 return SubStrings;
}


function CheckParameter(Index,Parameters) {
// if (Index>Parameters.length-1) return "(Error)" // don't work well
 if (Parameters[Index]=='') return "(Error)"
  else return Parameters[Index];
}



// 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>');
}

//AMPSOFT SPECIFIC
var ButtonSize=50,BannerSize=0+0;// 15 pixels of margin and separation from banner

function ShowImage(Src,Width,Height){
  var Popup,TotalWidth,TotalHeight;

  TotalWidth=Width+75;
  if (TotalWidth>screen.width-WINDOW_LEFT-8)
    TotalWidth=screen.width-WINDOW_LEFT-8;
  TotalHeight=Height+BannerSize+ButtonSize+60;
  if (TotalHeight>screen.height-WINDOW_TOP-SYSTRAY_HEIGHT-WINDOW_TITLEBAR)
    TotalHeight=screen.height-WINDOW_TOP-SYSTRAY_HEIGHT-WINDOW_TITLEBAR;
  Popup=OpenPopup("../Image.html?"+Src,"ImageWindow",TotalWidth,TotalHeight,true,true);
  return false;
}


function CheckFrames() {
 lastSlash=location.href.lastIndexOf("/");
 redirect=location.href.substr(location.href.lastIndexOf("/",lastSlash-1)+1);
 if (redirect.indexOf("ampsoft.net")>=0) redirect=location.href.substr(location.href.lastIndexOf("/")+1);
 if (window==top) top.location.href="/index.php?section="+redirect;
}


// AMPsoft General Script
// Created by Alberto Martinez Perez (http://www.ampsoft.net/)
