function julDate(y, m, d)
{
   var uh = 12
   var um = 0
   var us = 0

   var extra = 100.0*y + m - 190002.5
   var rjd = 367.0*y

   rjd -= Math.floor(7.0*(y+Math.floor((m+9.0)/12.0))/4.0)
   rjd += Math.floor(275.0*m/9.0) 
   rjd += d
   rjd += (uh + (um + us/60.0)/60.)/24.0
   rjd += 1721013.5
   rjd -= 0.5*extra/Math.abs(extra)
   rjd += 0.5

   return rjd
}

function parseDateRange(formName)
{
    var dateMin, dateMax, n
    formName.q.value = "";
    
    if(formName.as_qdr[formName.as_qdr.selectedIndex].value.charAt(0) == "d" || formName.as_qdr[formName.as_qdr.selectedIndex].value.charAt(0) == "w")
    {
        n = parseInt(formName.as_qdr[formName.as_qdr.selectedIndex].value.substring(1));
        
        // If we are calculating weeks, multiply by 7
        if(formName.as_qdr[formName.as_qdr.selectedIndex].value.charAt(0) == "w")
        {
            n *= 7;
        }

        // Get today's date
        var date1 = new Date();
        
        // Get the date n days before
        var date2 = offsetDays(date1, (n * -1));
        dateMax = julDate(date1.getFullYear(), date1.getMonth()+1, date1.getDate());
        dateMin = julDate(date2.getFullYear(), date2.getMonth()+1, date2.getDate());
        formName.q.value = "daterange:" + dateMin + "-" + dateMax;
		
    }
}
// Adds/Subtracts a given number of days (numDays) from myDate (date type: Date)
// and returns a Date.  If you want to subtracts days, specify numDays as a negative
// value
function offsetDays(myDate, numDays)
{
	return new Date(myDate.getTime() + numDays*24*60*60*1000);
}

// Preload all active and inactive images.
function init() {
  if (!document.getElementById) return
  var imgOriginSrc;
  var imgTemp = new Array();
  var imgarr = document.getElementsByTagName('img');
  for (var i = 0; i < imgarr.length; i++) {
    if (imgarr[i].getAttribute('hsrc')) {
        imgTemp[i] = new Image();
        imgTemp[i].src = imgarr[i].getAttribute('hsrc');
        imgarr[i].onmouseover = function() {
            imgOriginSrc = this.getAttribute('src');
            this.setAttribute('src',this.getAttribute('hsrc'))
			
        }
        imgarr[i].onmouseout = function() {
            this.setAttribute('src',imgOriginSrc)
        }
    }
  }
}
onload=init;
