// JS General Utilities
// CCH/ICAR
// resp.: paul.vetch@kcl.ac.uk
// last rev. 030612 10:44
// Updated to icar.org.uk domain

// POPUP IMAGES IN APPROPRIATELY SIZED WINDOW

// POPUP IMAGES IN APPROPRIATELY SIZED WINDOW

function PopupPic(sPicURL) { 
  //       window.open("http://maple.cc.kcl.ac.uk/ps/pase/web/script/popup.htm?"+sPicURL, "", "resizable=1,HEIGHT=200,WIDTH=200");
//        window.open("http://www.kcl.ac.uk/humanities/cch/pase/script/popup.htm?"+sPicURL, "", "resizable=1,HEIGHT=200,WIDTH=200");
       window.open("http://www.pase.ac.uk/script/popup.htm?"+sPicURL, "", "resizable=1,HEIGHT=200,WIDTH=200");
      }

var temp=self.location.href.split("?");
var picUrl = (temp.length>1)?temp[1]:"";
var NS = (navigator.appName=="Netscape")?true:false;

      function fitPic() {
        iWidth = (NS)?window.innerWidth:document.body.clientWidth;
        iHeight = (NS)?window.innerHeight:document.body.clientHeight;
        iWidth = document.images[0].width - iWidth;
        iHeight = document.images[0].height - iHeight;
        window.resizeBy(iWidth, iHeight-1);
        self.focus();
      };
//  SIZED POPUP
 

function popUp(URL) {
var windowName = 'bob'
winContent = window.open(URL, windowName, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=520,height=520');
winContent.focus()
}

// NS4 RESIZE FIX

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

// UPGRADED compliant multi-rollover (no preloader)

function initRollovers() {
  if (!document.getElementById) return
  
  var aPreLoad = new Array();
  var sTempSrc;
  var aImages = document.getElementsByTagName('img');

  for (var i = 0; i < aImages.length; i++) {    
    if (aImages[i].className == 'imgover') {
      var src = aImages[i].getAttribute('src');
      var ftype = src.substring(src.lastIndexOf('.'), src.length);
      var hsrc = src.replace(ftype, '_on'+ftype);

      aImages[i].setAttribute('hsrc', hsrc);
      
      aPreLoad[i] = new Image();
      aPreLoad[i].src = hsrc;
      
      aImages[i].onmouseover = function() {
        sTempSrc = this.getAttribute('src');
        this.setAttribute('src', this.getAttribute('hsrc'));
      } 
      
      aImages[i].onmouseout = function() {
        if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
        this.setAttribute('src', sTempSrc);
      }
    }
  }
}




// Jump Navigation menu from dropdown box


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}


// LAST UPDATED SCRIPT (VERBOSE)


var days = new Array(8);
days[1] = "Sunday";
days[2] = "Monday";
days[3] = "Tuesday";
days[4] = "Wednesday";
days[5] = "Thursday";
days[6] = "Friday";
days[7] = "Saturday";
var months = new Array(13);
months[1] = "January";
months[2] = "February";
months[3] = "March";
months[4] = "April";
months[5] = "May";
months[6] = "June";
months[7] = "July";
months[8] = "August";
months[9] = "September";
months[10] = "October";
months[11] = "November";
months[12] = "December";
var dateObj = new Date(document.lastModified)
var wday = days[dateObj.getDay() + 1]
var lmonth = months[dateObj.getMonth() + 1]
var date = dateObj.getDate()
var fyear = dateObj.getYear()
if (fyear < 2000) 
fyear = fyear + 1900
