

/************ FLYOUT SECTION *****************/
// Constants
var openDelay = 100;
var closeDelay = 200;

// Variables
var ignoreCloseFlyout = false;
var flyoutElement;
var flyoutElementToOpen;
var delayedOpen;
var delayedClose;

/**
 * Called on <span> onmouseover.  Starts setTimeout call to setFlyoutElementCssClass which will
 * then close old flyoutElement and open new one.
 */
function openFlyout(elem) {
  if ( !ignoreCloseFlyout ) {
    clearTimeout(delayedClose);
    delayedClose = null;

    clearTimeout(delayedOpen);
    flyoutElementToOpen = elem;
    delayedOpen = setTimeout(setFlyoutElementCssClass, openDelay);
  }
}

/** Called by openFlyout after a delay.  Does immediate close of old flyoutElement and
 * open of new flyoutElement.
 */
function setFlyoutElementCssClass() {
  closeFlyout();
  // Let's not even open if we're just about to close . . .
  if ( ! delayedClose ) {
    flyoutElementToOpen.className = "current";
    flyoutElement = flyoutElementToOpen;
    delayedOpen = null;
  }
}

/** Called on top-level <li> onmouseover.  Makes sure flyout is left open as long
 * as mouse is over it.
 */
function leaveOpen(elem) {
  if ( delayedClose && elem == flyoutElement ) {
    clearTimeout(delayedClose);
    delayedClose = null;
    clearTimeout(delayedOpen);
    delayedOpen = null;
  }
}

/** Called on top-level <li> onmouseout.  Starts setTimeout call to closeFlyout
 * which will colapse the currently open flyout.
 */
function delayedCloseFlyout() {
  delayedClose = setTimeout( closeFlyout, closeDelay );
}

/** Called by delayedCloseFlyout after a delay, or by setFlyoutElementCssClass
 * immediately.  Sets the flyoutElement's class to blank so the current flyout hides again.
 */
function closeFlyout() {
  if ( !ignoreCloseFlyout ) {
    clearSearch();
    if (flyoutElement) flyoutElement.className = "";
    flyoutElement = null;
  }
}

/**
 * Called by search <li> onmouseout.  Starts setTimeout call to closeFlyout
 * which will close the search flyout.
 */
function delayedSearchCloseFlyout() {
  ignoreCloseFlyout = false;
  delayedClose = setTimeout( closeFlyout, closeDelay );
}

/** Called on search flyout elements to keep flyout from closing while user is typing.
 */
function doNotCloseFlyout() {
  ignoreCloseFlyout = true;
}

/**
 * Clears search query box and removes the focus
 */
function clearSearch() {
/*  document.forms[0].query.value='';
  document.forms[0].query.disabled=true;
  document.forms[0].query.disabled=false;
	document.forms[0].exactPhrase.checked=false;*/
	document.forms[0].reset();
	
}
/************ END FLYOUT SECTION *****************/

// Browser Detect  v2.1.6
// documentation: http://www.dithered.com/javascript/browser_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)
function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIcab        = (ua.indexOf('icab') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetect();

function findBrowserType() {
	//var isSafari = (navigator.userAgent.indexOf("Safari") != -1) ? true : false;
	//alert(document.getElementById('features').class);

	/*if (browser.isMac) {

		document.getElementById('searchFlyoutText').size = 16;
		if(document.getElementById('searchPortletTextbox')!=null) { 
			document.getElementById('searchPortletTextbox').size = 14; // adjusts search portlet text box size in Safari
		}
		if(document.getElementById('username')!=null) {
			document.getElementById('username').size = 14; // adjusts stake & ward websites portlet username text box size in Safari
		}
		if(document.getElementById('password')!=null) {
			document.getElementById('password').size = 14; // adjusts stake & ward websites portlet password text box size in Safari
		}		
		//document.getElementById('featuresText').className="hiddenElem";
	}	else {
		 if (document.getElementById('searchPortletTextbox')!=null) {
			 document.getElementById('searchPortletTextbox').className = "full";
			 //document.getElementById('password').className = "full";
			 //document.getElementById('username').className = "full";
		 }
	}*/
}

/* JUMP MENU */
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);
}
/* END JUMP MENU */

/** 
 * Hides or Shows all 
 */

function hideShowAllNarrowBy(caller,action){
	//alert('hideshow');
	nbLinkArray = new Array();
	nbListArray = new Array();
	
	linkArray = document.getElementsByTagName('A');
	//alert("linkArray.length:" + linkArray.length);
	for (j=0,k=0;j < linkArray.length;j++){
		//alert(linkArray[j].name);
		if (linkArray[j].name =="narrowByLink"){
			nbLinkArray[k] = linkArray[j]; k++;
			}
		}
		
	listArray = document.getElementsByTagName('DIV');
	//alert("listArray.length" + listArray.length);
		for (l=0,m=0;l < listArray.length;l++){
			//alert("listArray[l].className: " + listArray[l].className);
		if (listArray[l].id.substring(0,11) =="narrowByDiv"){
			
			nbListArray[m] = listArray[l]; 
			//alert("nbListArray[" + m +"]" + nbListArray[m].id);
			//alert("nbListarray[m]:  " + nbListArray[m].id);
			m++;
			}
		}
		//alert("this.id = " + caller.id);
//alert("nbListArray.length" + nbListArray.length);
		if (action == "Collapse"){
			<!-- CollapseAll -->	
			for(n=0;n < nbLinkArray.length;n++){
						currentLinkImage = nbLinkArray[n].firstChild;
						currentList = nbListArray[n];
						//alert("currentList.id: " +currentList.id);
						if (currentLinkImage.id.substring(0,10)=="closeImage"){
							//alert("Collapsing");
							currentList.className = "hiddenElem clearFloat";
							currentLinkImage.alt = "Open group";
							currentLinkImage.src="/josephsmith/images/accordianClosed.gif";
							}//end if
				}//end for
				document.getElementById("Collapso").className = "hiddenElem";
				document.getElementById("Expando").className = "";
				return true;
		}//end if
		if (action == "Expand"){
				<!-- ExpandAll -->	
			for(p=0;p < nbLinkArray.length;p++){
						currentLinkImage = nbLinkArray[p].firstChild;
						currentList = nbListArray[p];
						//alert("nbListArray.length: " + nbListArray.length);
						if (currentLinkImage.id.substring(0,10,"closeImage")){
							currentList.className = "clearFloat";
							currentLinkImage.alt = "Close group";
							currentLinkImage.src="/josephsmith/images/accordianOpen.gif";
						}//end if
				}//end for
				document.getElementById("Expando").className = "hiddenElem";
				document.getElementById("Collapso").className = "";
			}//end if
	//alert("caller.id: " + caller.id);
	return true;
}//end Function

/** 
 * Hides content area with image
 */
function hideShowImage(image,div){
    var className = "hiddenElem clearFloat print";
    if (document.getElementById(div).className == className){
      document.getElementById(div).className = "";
      document.getElementById(image).src="/josephsmith/images/accordianOpen.gif";
      document.getElementById(image).alt="Close group";
	
    } else {
      document.getElementById(div).className = className;
      document.getElementById(image).src="/josephsmith/images/accordianClosed.gif";
      document.getElementById(image).alt="Open group";
	
    }
 }

/** 
 * Hides content area
 */
function hideShow(list){

    if (document.getElementById(list).className == "hiddenElem"){
      document.getElementById(list).className = "";
    }else{
      document.getElementById(list).className = "hiddenElem";
    }

 }

function hideContent(name){
   document.getElementById(name).className = "hiddenElem";
}

function showContent(name){
    document.getElementById(name).className = "";
}
/******************************
 * FIND BY SCRIPT
**/
function enableAll(box, group, num){
	if (box.checked) {
		for(i=1; i<=num; i++){
			groupId = group + i;
			document.getElementById(groupId).disabled = true;
			document.getElementById(groupId).checked = false;
			groupId = groupId + "txt";
			document.getElementById(groupId).className = "grayText";
		}
	} else {
		for(i=1; i<=num; i++){
			groupId = group + i;
			document.getElementById(groupId).disabled = false;
			groupId = groupId + "txt";
			document.getElementById(groupId).className = "darkGrayText";
		}
	}
}
/**
 * END FIND BY SCRIPT
*******************************/

/**
 * Hides navigation menu
 */
function hideNavigation() {
  // hide menu
  document.getElementById("menuNav").className = "hiddenElem";

  // set content area's className
  document.getElementById("bodyCopy").className = "expandedBodyCopy";
  document.getElementById("bodyCopy").style.width = "100%";

  // close footer
  document.getElementById("footer").className = "footerClosed";

  // swap navigation buttons
  document.getElementById("open_navigation").className = "hiddenElem";
  document.getElementById("closed_navigation").className = "";
	if (page =='introductionTab') {
    resizeImageProportionally(theRatio, theInverseRatio);
    //resizeIt()
  }

  // Will set a cookie to remember hidden state of the nav
  //setHideNavCookie('hide'); 
}

/**
 * Shows Navigation menu
 */
function showNavigation() {
  // swap navigation buttons
  document.getElementById("open_navigation").className = "";
  document.getElementById("closed_navigation").className = "hiddenElem";

  // open footer
  document.getElementById("footer").className = "footerOpen";

  // unset content area's className
  document.getElementById("bodyCopy").className = "restrictedBodyCopy";
  document.getElementById("bodyCopy").style.width = "74%";

  // unhide menu
  document.getElementById("menuNav").className = "";

  //resizeFlashProportionally();
  if (page == 'multimediaTab') {
    document.getElementById("flashdiv").style.width=400;
  }
  if (page =='introductionTab') {
    resizeImageProportionally(theRatio, theInverseRatio);
    //resizeIt()
  }
  // Will set the cookie to remember the shown state of the nav
  //setHideNavCookie('show')
}

/**
 * Submits the specified form 
 */
function submitForm( formId ) {
  document.getElementById(formId).submit();
}

/**
 * Changes the current lements class
 */
function changeClass( elem, classname ) {
  elem.className = classname;
  //window.event.cancelBubble = true;
}

/**
 * turns on print view
 */
function setPrintPreview() {
  document.getElementById("bodytag").className = "printPreview";  
  if (page =='introductionTab') { // If  the current page is the Introduction Tab, the footnotes will become visible for the print page
    document.getElementById("footnotes").className="nonHiddenElem";
  } 
}

function disableDailyEvents() {
  if (page == 'dailyEventsWeek') {
    document.getElementById("changeDaySelect").disabled=true;
    document.getElementById("changeMonthSelect").disabled=true;
  } else  if (page == 'dailyEventsDay') {
    document.getElementById("changeDaySelect").disabled=true;
    document.getElementById("changeMonthSelect").disabled=true;
  } else  if (page == 'dailyEventsMonth') {
    document.getElementById("changeMonthSelect").disabled=true;
  }
}
/**
 * determines if this is a print view
 */
function isPrintPreview () {
  if ( location.href.indexOf("printPreview")>-1 ) {
    return true;
  }  
  return false;  
}

/**
 * Opens new window for print preview
 */
function openPrintPreview() {
  var newWin = window.open(location.href+"&printPreview=true", "PrintPreview","menubar=no,scrollbars=yes,buttonbar=no,toolbar=no,height=550,width=705,resizable=yes");
}

/**
 * Opens new window for footnonte
 */
function openFootnote( footnoteId, title) {
  var htmlOpen = '<html><head><title>'+title+'</title><link href="/ldsCss/footnote.css" rel="stylesheet" type="text/css"/></head><body onblur="javascript:window.close()">';
  var header = '<div id="header"><div>'+title+'</div><div id="close"><a href="javascript:window.close()">Close</a></div></div>';
  var theContent = document.getElementById(footnoteId).innerHTML;

  var  content = '<div id="content">'+theContent+'</div>';
  var htmlClose = "</body></html>";
  var lengthOfContent = theContent.length/40; // used to determine length of popup content

  height = 100;
  if (lengthOfContent>3) {
    height = height+(lengthOfContent-3)*15;  // adds height to adjust for length of popup content
  }

  width = 300;
  // centers popup on the page
  topOffset = ( screen.availHeight - height ) / 2;
  leftOffset = ( screen.availWidth - width ) / 2 ;

  // opens popup window for glossary and footnote items
  var footnoteWin = window.open('', "footnoteWindow","menubar=no,scrollbars=yes,buttonbar=no,toolbar=no,height="+height+",width="+width+",top="+topOffset+",left="+leftOffset+",resizable=yes");
  footnoteWin.document.write(htmlOpen + header + content + htmlClose);
  footnoteWin.document.close();
}

/**
 * Opens new window for image
 */
function openImage( path, altText, height, width, printText, closeText ) {
  var title = altText;
  var htmlOpen = '<html><head><title>'+title+'</title><link href="/css/footnote.css" rel="stylesheet" type="text/css"/></head><body>';
  var header = '<div id="header"><div id="close"><a href="javascript:window.print()">'+printText+'</a>&nbsp;|&nbsp;<a href="javascript:window.close()">'+closeText+'</a></div></div>';
  
  var image = '<img src="'+path+'" alt="'+altText+'" align="center">';
  var htmlClose = "</body></html>";
  
  height = height + 15;

  // centers popup on the page
  topOffset = ( screen.availHeight - height ) / 2;
  leftOffset = ( screen.availWidth - width ) / 2 ;

  // opens popup window for image
  var footnoteWin = window.open('', "footnoteWindow","menubar=no,scrollbars=no,buttonbar=no,toolbar=no,height="+height+",width="+width+",top="+topOffset+",left="+leftOffset+",resizable=yes");
  footnoteWin.document.write(htmlOpen + header +  image + htmlClose);
  footnoteWin.document.close();
}

/**
 * Opens new window for links
 */
function openLink( url ) {
 
  height = 600;
  width = 800;

  // centers popup on the page
  topOffset = ( screen.availHeight - height ) / 2 -100;
  leftOffset = ( screen.availWidth - width ) / 2 ;

  // opens popup window for newLink
  var newWin = window.open(url, "newWindow","menubar=yes,scrollbars=yes,buttonbar=yes,status=yes,toolbar=yes,height="+height+",width="+width+",top="+topOffset+",left="+leftOffset+",resizable=yes");
  //newWin.document.focus();
}



/**
 * Finds the X position of the obj
 */
function findPosX(obj)
{
  var curleft = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curleft += obj.offsetLeft
        obj = obj.offsetParent;
    }
  }
  else if (obj.x)
    curleft += obj.x;
  return curleft;
}

/**
 * Finds the Y position of the obj
 */
function findPosY(obj)
{
  var curtop = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curtop += obj.offsetTop
        obj = obj.offsetParent;
    }
  }
  else if (obj.y)
    curtop += obj.y;
  return curtop;
}

/**
 * closes the nav
 */
var hideNav = false;
function displayTheNav() {
  //  Cookies can be turned on to remember the state of the nav
  /*  var nav = GetCookie('nav');
      alert(nav);
      if (nav=='hide'){
      hideNavigation();
      }
      else {
      showNavigation();
      }*/
  if (hideNav) {
    hideNavigation();
  }

  // Code to fix bug JSWS-147
  if (page == 'multimediaTab') {    
    if(navigator.appName == "Microsoft Internet Explorer") {
      document.getElementById("exhibit2").focus();  // Sets focus to flash object to force it to play
      document.getElementById("topmenu").focus(); // Sets focus back to the top of the page
    }
  }
}

var resize = true;
function resizeFlashProportionally() {
  if (page =='introductionTab') {
    resizeImageProportionally(theRatio, theInverseRatio);
    //resizeIt()
  }
  if (page == 'multimediaTab') {
    document.getElementById("print").className = "hiddenElem";
    document.getElementById("printDisabled").className = "nonHiddenElem";


    document.getElementById("flashdiv").style.width='400px';
    //CONSTANTS
    MIN_WIDTH = 300;
    MAX_WIDTH = 1000;

    var sizerWidth =  document.getElementById("sizer").width; // finds width of the proxy spacer.gif
    var constrained = document.getElementById("flashdiv");

    // sets min width
    if ( sizerWidth < MIN_WIDTH ){
      sizerWidth = MIN_WIDTH;
    }
    //sets max width
    if ( sizerWidth > MAX_WIDTH ) {
      sizerWidth = MAX_WIDTH;
    }
    //resize
    document.getElementById("flashdiv").style.width ='' +sizerWidth +'px';  // sets multimedia exhibit to the size of the proxy image
    constrained.style.height = '' +( 3 * sizerWidth ) / 4 + 'px';  // adjusts the height of exhibit to maintain the ratio
  }
}

/*
 * Image scaling
 */
var theRatio = '';
var theInverseRatio ='';
var count =2;
function resizeIt() {
  //GET ASPECT RATIO FOR USE IN IMAGE SCALER FUNCTION THEN INIT
  pictureWidth = document.getElementById("constrainedImage").offsetWidth;
  pictureHeight = document.getElementById("constrainedImage").offsetHeight;

  if ((pictureHeight !=0) && (pictureWidth!=0)) {
    theRatio = pictureHeight/pictureWidth; // maintains original ratio of image height/width
    theInverseRatio = pictureWidth/pictureHeight; // used for landscape
    resizeImageProportionally(theRatio, theInverseRatio);
  }
}

function resizeImageProportionally(theRatio, theInverseRatio) {
  //CONFIGURABLE CONSTRAINTS
  MAX_WIDTH = 350;
  COLUMN_DIVISIONS = 3;
  EXAGGERATE_LANDSCAPE_WIDTH = 1; //1 is no change, 1.5 would enlarge 150%, .5 would be 50% size, etc.

  //DETERMINE MAX HEIGHT BY THE HEIGHT OF THE BROWSER WINDOW
  // MAX_HEIGHT = (screen.availHeight/2)-50;
  MAX_HEIGHT = 400;
  COLUMN_WIDTH = (document.getElementById("content").offsetWidth/COLUMN_DIVISIONS)-50;

  if (COLUMN_WIDTH  <= 0) {
    COLUMN_WIDTH =100;
  }

  if(theRatio>=1){
    //PORTRAIT (OR SQUARE)
    var constrained = document.getElementById("constrainedImage");
    //resize
    constrained.width = COLUMN_WIDTH;
    constrained.height = COLUMN_WIDTH*theRatio;
    //apply constraints if size is too large
    if (constrained.height>MAX_HEIGHT){
      constrained.height=MAX_HEIGHT;
      constrained.width=MAX_HEIGHT*theInverseRatio;
    }
  }else{
    //LANDSCAPE
    var constrained = document.getElementById("constrainedImage");
    //resize
    COLUMN_WIDTH*=EXAGGERATE_LANDSCAPE_WIDTH;
    constrained.width = COLUMN_WIDTH;
    constrained.height = COLUMN_WIDTH*theRatio;
    //apply constraints if size is too large
    if (constrained.width>MAX_WIDTH){
      constrained.width=MAX_WIDTH;
      constrained.height=MAX_WIDTH*theRatio;
    }
  }
}
function doSaveAs(filename) {
  if (document.execCommand){
    document.execCommand("SaveAs",null,filename);
  }else{
    alert('Feature available only in Internet Exlorer 4.0 and later.');
  }
}

/** FLASH SCRIPT **/
<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 7;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// the version of javascript supported
var jsVersion = 1.0;
// -----------------------------------------------------------------------------
// -->
<!-- // Detect Client Browser type
var isMSIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
var isMozilla = (navigator.userAgent.indexOf("Mozilla") != -1) ? true : false;
jsVersion = 1.1;
// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			descArray = flashDescription.split(" ");
			tempArrayMajor = descArray[2].split(".");
			versionMajor = tempArrayMajor[0];
			versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
      	} else {
			flashVer = -1;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	// Can't detect in all other cases
	else {
		
		flashVer = -1;
	}
	return flashVer;
} 
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 
{
 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
   	// loop backwards through the versions until we find the newest version	
	for (i=25;i>0;i--) {	
		if (isMSIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer(i);
		} else {
			versionStr = JSGetSwfVer(i);		
		}
		if (versionStr == -1 ) { 
			return false;
		} else if (versionStr != 0) {
			if(isMSIE && isWin && !isOpera) {
				tempArray         = versionStr.split(" ");
				tempString        = tempArray[1];
				versionArray      = tempString .split(",");				
			} else {
				versionArray      = versionStr.split(".");
			}
			versionMajor      = versionArray[0];
			versionMinor      = versionArray[1];
			versionRevision   = versionArray[2];
			
			versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
			versionNum        = parseFloat(versionString);
        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
				return true;
			} else {
				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
			}
		}
	}	
}
/****** /flash intro script  ***/

/***Search Widget Controls ***********/

function increaseValue(dest){
	
	if (document.getElementById(dest).value == "NaN")
	document.getElementById(dest).value = 0;
	theValue = parseInt(document.getElementById(dest).value);
	theValue = theValue + 1;
document.getElementById(dest).value = theValue;
}

function decreaseValue(dest){
		if (document.getElementById(dest).value == "NaN")
	document.getElementById(dest).value = 0;
	theValue = parseInt(document.getElementById(dest).value);
	if(theValue >0){
	theValue = theValue - 1;
document.getElementById(dest).value = theValue;
	}
}

function getSelectedValue(input) {
  if ( input.type == 'select' ) {
    return input.options[input.selectedIndex].value;
  } else if ( input.length ) {
    for (var i=0; i < input.length; i++ ) {
      if ( input[i].checked == true ) return input[i].value;
    }
  }
}
//Popup Window functions
function setWindowValues(){
 
	windowWidth = getWindowWidth(self); // or you could just apply some value here
  windowHeight = getWindowHeight(self); // or you could just apply some value here
	screenWidth = screen.availWidth ? screen.availWidth : screen.width;
	screenHeight = screen.availHeight ? screen.availHeight : screen.height;
	
	calcTop = window.screenY ? window.screenY : self.screenTop;
	calcLeft = window.screenX ? window.screenX : self.screenLeft;
	
	return (windowCoord = new Array(windowWidth,windowHeight,screenWidth,screenHeight,calcTop,calcLeft));
}


function newWindow(theURL) {
var portionFloat = .6;
var features='menubar=yes,scrollbars=yes,buttonbar=yes,status=yes,toolbar=yes,';

winName = 'contentWindow';
windowCoord = setWindowValues();

var windowWidth = windowCoord.shift();
var windowHeight = windowCoord.shift();
var screenWidth = windowCoord.shift();
var screenHeight = windowCoord.shift();
var calcTop = windowCoord.shift();
var calcLeft = windowCoord.shift();

newWidth = parseInt(windowWidth * portionFloat);
newHeight = parseInt(windowHeight * portionFloat);

newXOffset = parseInt((windowWidth - newWidth) * .5) + calcLeft;
newYOffset = parseInt((windowHeight - newHeight) * .5) + calcTop;

if (navigator.appName == 'Microsoft Internet Explorer'){
	offsetString = ',top=' + newYOffset + ', left=' + newXOffset;
	}
	else {
	offsetString = ',screenX=' + newYOffset + ', screenY=' + newXOffset;
	}

features = features + 'width=' + newWidth + ',height=' + newHeight + offsetString;

windowName = self.open(theURL,winName,features);
}

function getWindowWidth (windowObject) {
		var windowWidth = 0

		if (windowObject.innerWidth)
		{
			windowWidth = windowObject.innerWidth;
		}
		else if (windowObject.document.documentElement && windowObject.document.documentElement.clientWidth)
		{
			windowWidth = windowObject.document.documentElement.clientWidth;
		}
		else if (windowObject.document.body)
		{
			windowWidth = windowObject.document.body.clientWidth;
		}
		if (windowWidth < 500){
			windowWidth = 500;
			}
		return windowWidth;
	}

	function getWindowHeight (windowObject) {
		
		if (windowObject.innerHeight)
		{
			windowHeight = windowObject.innerHeight;
		}
		else if (windowObject.document.documentElement && windowObject.document.documentElement.clientHeight)
		{
			windowHeight = windowObject.document.documentElement.clientHeight;
		}
		else if (windowObject.document.body)
		{
			windowHeight = windowObject.document.body.clientHeight;
		}
		if (windowHeight < 325){
			windowHeight = 325;
			}
		return windowHeight;
	}
	//END Popup Window Functions
