// Rollover Image Preloader
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// Rollover Image Swapper
function SwapImage() {
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.SwapImgData;
  for (i=0; i < (SwapImage.arguments.length-2); i+=3) {
    objStr = SwapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = SwapImage.arguments[i+2];
  } }
  document.SwapImgData = swapArray; //used for restore
}

// Rollover Image Swap Restorer
function SwapImgRestore() { //v2.0
  if (document.SwapImgData != null)
    for (var i=0; i<(document.SwapImgData.length-1); i+=2)
      document.SwapImgData[i].src = document.SwapImgData[i+1];
}

// Pops-up real media video windows
function realPlayer(file,title,width,height) {
  if (document.all) { // IE4+ browsers screen width
    var xMax = screen.width, yMax = screen.height;
  } else {
    if (document.layers) { // NN4 browsers screen width
      var xMax = window.outerWidth, yMax = window.outerHeight;
    } else { // All other browsers default width
      var xMax = 640, yMax=480;
    }
  }
  // Position the window top-left of center
  var xOffset = (xMax - width)/3, yOffset = (yMax - height)/3;
  var URL = 'http://www.unhcr.org/cgi-bin/texis/vtx/realplayer?file='+file+'&title='+title+'&width='+width+'&height='+height;
  var Params = 
	'width='	+ width +
	',height='	+ (height + 30) +
	',screenX='	+ xOffset +
	',screenY='	+ yOffset +
	',top='		+ yOffset +
	',left='	+ xOffset +
        ',directories=no' +
        ',location=no'    +
        ',menubar=no'     +
        ',scrollbars=no'  +
        ',status=no'      +
        ',toolbar=no'     +
        ',resizable=no';
  window.open(URL,'video',Params);
  //window.alert(height);
}

// Pops-up flash video console
function flashVideo(file) {
  if (document.all) { // IE4+ browsers screen width
    var xMax = screen.width, yMax = screen.height;
  } else {
    if (document.layers) { // NN4 browsers screen width
      var xMax = window.outerWidth, yMax = window.outerHeight;
    } else { // All other browsers default width
      var xMax = 640, yMax=480;
    }
  }
  // Position the window top-left of center
  var xOffset = (xMax - 500)/3, yOffset = (yMax - 296)/3;
  var URL = 'http://www.unhcr.org/cgi-bin/texis/vtx/videoConsole?file='+file;
  var Params = 
	'width='	+ 500 +
	',height='	+ 296 +
	',screenX='	+ xOffset +
	',screenY='	+ yOffset +
	',top='		+ yOffset +
	',left='	+ xOffset +
        ',directories=no' +
        ',location=no'    +
        ',menubar=no'     +
        ',scrollbars=no'  +
        ',status=no'      +
        ',toolbar=no'     +
        ',resizable=no';
  window.open(URL,'flashvideo',Params);
}

// Pops-up an Image in a windows
function popImage(file,title,width,height) {
  if (document.all) { // IE4+ browsers screen width
    var xMax = screen.width, yMax = screen.height;
  } else {
    if (document.layers) { // NN4 browsers screen width
      var xMax = window.outerWidth, yMax = window.outerHeight;
    } else { // All other browsers default width
      var xMax = 800, yMax=600;
    }
  }
  // Position the window top-left of center
  var xOffset = (xMax - width)/3, yOffset = (yMax - height)/3;
  var URL = 'http://www.unhcr.org/cgi-bin/texis/vtx/popImage?file='+file+'&title='+title+'&width='+width+'&height='+height;
  var Params = 
	'width='	+ width +
	',height='	+ height +
	',screenX='	+ xOffset +
	',screenY='	+ yOffset +
	',top='		+ yOffset +
	',left='	+ xOffset +
        ',directories=no' +
        ',location=no'    +
        ',menubar=no'     +
        ',scrollbars=no'  +
        ',status=no'      +
        ',toolbar=no'     +
        ',resizable=no';
  window.open(URL,'video',Params);
}

// Anti-Spam Email function
function email(user, domain, ext, subject) {
  location.href = 'mailto:' + user + '@' + domain + '.' + ext + '?subject=' + subject;
}
