//javascript for the CVS website
//Michael Lee 22-May-2008


// *********************************************   OBSOLETE ***********************************************
// *********************************************   OBSOLETE ***********************************************

  // USE utils.js in INCLUDES folder instead!!

// *********************************************   OBSOLETE ***********************************************
// *********************************************   OBSOLETE ***********************************************
function hideExpiredElements() {
  //this function should be called on the onload event of the <body> tag
  //any element that should be hidden as of a certain date should have the CLASS displayUntil_yyyy_m_d where d is the day (1-31), m is month (1-12) and yyyy is year (4-digit)
  var today=new Date();
  var alltags = document.getElementsByTagName("*");
  for (i=0; i<alltags.length; i++){
    var displayUntilChar = alltags[i].className.indexOf('displayUntil_');

    if (displayUntilChar !=-1) {
      //alert('found ' + alltags[i].className + 'which has displayUntil_ at char: ' + displayUntilChar);
      //see when this is:

      var displayClassName = alltags[i].className.substr(displayUntilChar);
      if (displayClassName.indexOf(" ")!=-1) {
        //remove after first space:
        displayClassName = displayClassName.substr(0,displayClassName.indexOf(" "));
      } //has space in className
      //see if it is here yet or not:
      var displayClassNameSplit = displayClassName.split("_");
      if (displayClassNameSplit.length == 4) {
        try {
			var dteToRemove=new Date();
			dteToRemove.setFullYear(displayClassNameSplit[1]);
			dteToRemove.setMonth(displayClassNameSplit[2] - 1); //decrease month by 1, because setMonth works from 0 to 11
			dteToRemove.setDate(displayClassNameSplit[3]);
			if (today>=dteToRemove) {
			  alltags[i].className = alltags[i].className + " notshown"; //hides this element by css
			}
		} catch (e) {
		  // do nothing if error!
		} //end try to hide if date is today is on or after hide date
      } //there are 3 parts to the date

   } //display until is in the class
  } //loop across all elements
} //end function
// *********************************************   OBSOLETE ***********************************************
// *********************************************   OBSOLETE ***********************************************

  // USE utils.js in INCLUDES folder instead!!

// *********************************************   OBSOLETE ***********************************************
// *********************************************   OBSOLETE ***********************************************

// FUNCTIONS FOR RESIZING SCREENSHOTS (ri_)------------------------------------
    function ri_calculateNewScale(theImg) {
      //checks to see if an image is resized already.  Assumes not if error
      var dblNewScale = 1; //default
      try {
        //remove height attribute.  If that changed height, then image was already shrunk, so restore image (done here), otherwise shrink it
        var initHt =theImg.height ;
        theImg.removeAttribute("height");
        theImg.removeAttribute("width");
        if (theImg.height == initHt) { //no change to height when removing height attribute.  Image was full size, so shrink it:
          //but how small... depends on image height:
          if (initHt > 600 ) {
            dblNewScale = 0.1; //really tall
          } else if (initHt > 300) {
            dblNewScale = 0.2;  //sort of tall
          } else {
            dblNewScale = 0.4; //not so tall
          }
        }
      } catch (e) {
        // do nothing
      }
      return dblNewScale;
    }
// *********************************************   OBSOLETE ***********************************************
// *********************************************   OBSOLETE ***********************************************

  // USE utils.js in INCLUDES folder instead!!

// *********************************************   OBSOLETE ***********************************************
// *********************************************   OBSOLETE ***********************************************
    function ri_resizeOneImage(theImg, dblScale) {
         //resize a single image, passed as theImg, to dblScale (0-1):
         //dblScale=-1 means to try to figure out what to do based on the image itself.  If it is already resized, restore it, else shrink
          if (dblScale == -1) {
            //figure out if this is already resized, if so restore it, otherwise reduce by .4
            dblScale = ri_calculateNewScale(theImg) ;
          }
          if (dblScale == 1) {
            //size to original:
            theImg.removeAttribute("height");
            theImg.removeAttribute("width");
          } else {
            //calculate new dimensions
            var dblNewHt = theImg.height * dblScale;
            var dblNewWd = theImg.width * dblScale;
            //set new dimensions:
            theImg.setAttribute("height",dblNewHt);
            theImg.setAttribute("width",dblNewWd);
          }
    }
// *********************************************   OBSOLETE ***********************************************
// *********************************************   OBSOLETE ***********************************************

  // USE utils.js in INCLUDES folder instead!!

// *********************************************   OBSOLETE ***********************************************
// *********************************************   OBSOLETE ***********************************************
    function ri_changeAllImagesSize(dblScale, strIDOnly) {
       // changes all "resizable" class images on the document to the dblScale (0-1) listed.
       var alltags ;
			alltags = document.getElementsByTagName("IMG"); //get all images
			for (i=0; i<alltags.length; i++){
				var resizableChar = alltags[i].className.indexOf('resizable');
				if (resizableChar != -1) { //is resizable image
				 ri_resizeOneImage(alltags[i],dblScale);
				} //is resizable image
			} //loop through all images
    } //end function

    // *********************************************   OBSOLETE ***********************************************
	// *********************************************   OBSOLETE ***********************************************

	  // USE utils.js in INCLUDES folder instead!!

	// *********************************************   OBSOLETE ***********************************************
// *********************************************   OBSOLETE ***********************************************

// *********************************************   OBSOLETE ***********************************************
// *********************************************   OBSOLETE ***********************************************

  // USE utils.js in INCLUDES folder instead!!

// *********************************************   OBSOLETE ***********************************************
// *********************************************   OBSOLETE ***********************************************

// *********************************************   OBSOLETE ***********************************************
// *********************************************   OBSOLETE ***********************************************

  // USE utils.js in INCLUDES folder instead!!

// *********************************************   OBSOLETE ***********************************************
// *********************************************   OBSOLETE ***********************************************