// AMPSoft Downloads General Script
// Made by Alberto Martinez Perez (http://www.ampsoft.net)

// WINDOW & PARAMETERS
var WindowTop=15, WindowLeft=15;

var LastPopup=null;

function OpenPopup(Page,Window,Width,Height,ScrollBars){
 var Options=new String(), Scroll=new String("no");
 if (ScrollBars) Scroll="yes";
 Options="width="+Width+",height="+Height+
  ",screenY="+WindowTop+",top="+WindowTop+",screenX="+WindowLeft+",left="+WindowLeft+","+
  "status=no,location=no,toolbar=no,menubar=no,resizable=no,hotkeys=no,scrollbars="
  +Scroll;
 LastPopup=window.open(Page,Window,Options,true); // if last (optional) parameter is true the page is not added to the page history
 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 false
  else return Parameters[Index];
}




// MISC
function MaskedEmail(Domain,Text,Name) {
 document.write('<a href="'+'ma'+'ilto:'+Name+'@'+Domain+'">'+Text+'</a>');
}




//AMPSOFT SPECIFIC
var Border=50,ButtonSize=35,BannerSize=65+15;// 15 pixels of margin and separation from banner

function ShowImage(Src,Width,Height) {
  var Popup,TotalWidth,TotalHeight;

  TotalWidth=Width+Border;
  if (TotalWidth>screen.width-WindowLeft-8)
    TotalWidth=screen.width-WindowLeft-8;
  TotalHeight=Height+Border+BannerSize+ButtonSize;
  if (TotalHeight>screen.height-WindowTop-32-24) // 32 of systray and 24 of window title
    TotalHeight=screen.height-WindowTop-32-24;
  Popup=OpenPopup("Image.html?"+Src,"ImageWindow",
                  TotalWidth,TotalHeight,true);
}
