
// *******************
// Display email address
// *******************
function ShowEmail (name,server,suffix,subject,text)
{ var atsign = unescape('%' + (39 + 1)); // This generates the string "%40", which unescapes to the @ sign
  var mto = 'mai' + 'lto:';
  if (text == "")
    text = name + atsign + server + "." + suffix;
  if (subject != "")
	  subject = '?subject=' + subject;
  document.write('<a href="' + mto + name + atsign + server + '.' + suffix + subject + '">' + text + '</a>');
}


// *******************
// Open new minimal window to display a URL
// *******************
var winInfo=null;


function OpenWindow(URL,Left,Top,Width,Height)
{ // Is a winInfo opened already? If so, close it first!
  if ( winInfo && winInfo.open && !winInfo.closed ) // Explanation: http://www.webreference.com/js/tutorial1/exist.html
  {
  winInfo.close();
  }
  // Then open the new window
  winInfo = window.open(URL,'','left=' + Left + ',top=' + Top + ',screenX=' + Left + ',width=' + Width + ',height=' + Height);
}


// *******************
// Retrieves and displays the specified image
// *******************
function ShowImage(ImageName)
{ document.write('<div align="center"><img src="' + ImageName + '"></div>');
}


// *******************
// Returns to the previous page if it belongs to the www.oldwings.nl domain. If
// not, it goes to the page indicated by the Override variable.
// *******************
function GoBack(Override)
{  if ((document.referrer.indexOf("oldwings.nl") != -1) || (document.referrer.indexOf("localhost") != -1))
      history.back();
	else
      window.location=Override;
}


// *******************
// Only allows access to the page if called from the site itself or from the localhost. If not, 
// it redirects to any other page (the home page for example)
// *******************
function NoDirectAccess(Override)
{  if ((document.referrer.indexOf("www.oldwings.nl") == -1) && (document.referrer.indexOf("localhost") == -1))
	 window.location=Override;  
}


// *******************
// Open a screen window to display a large image from the XS4All archive
// *******************
function ShowImageFS(Header,Directory,Image,Language,VertSpace,ShowEnlarge,ShowDetails,ShowBorder)
{ var URL = Directory + "image_fullscreen.htm?" + Image + "," + Header + "," + Language + "," +
            VertSpace + "," + ShowEnlarge + "," + ShowDetails + "," + ShowBorder;
  window.open(URL,'','fullscreen=yes,scrollbars=yes');
}


// *******************
// Generates a random number in the range Min <= Number <= Max
// *******************
function RandomNumber(Min,Max)
{ return Math.floor(Math.random()*(Max + 1 - Min)) + Min;
}


// *******************
// Randomly selects a filename from the supplies array, and displays this as a background image
// *******************
function ShowRandomImage(First,Last)
{ var ImageSrc;
  ImageSrc = RandomNumber(First,Last) + '.jpg';
  document.write('<div align="center"><img src="front/' + ImageSrc + '"></div>');
}


// *******************
// Retrieves a specified parameter from the referrer URL. Format of the URL should be:
// .....?<parameter name 1>=<parameter value 1>,<parameter name 2>=<parameter value 2>&............
// Example: ../misc/show_image_frame.htm?image=for_sale/camera_adapter.jpg,referrer=/content/c47/c47.htm
// *******************
function getQueryString(ParamName)
{ var Query = window.location.search.substring(1);
  var Params = Query.split(",");
  for (var i=0; i<Params.length; i++) {
    var Parameter = Params[i].split("=");
    if (Parameter[0] == ParamName) {
      return Parameter[1];
    }
  }
  alert('Query string "' + ParamName + '" not found!');
}

  
