
<!-- 

// function to check if an email entered is an email address
function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}


// Used only by Plant Results page.  Submits all reults values in form to plant profile page
function loadPlant(ID) {
	document.movementForm.action = "scene1d2f.html" + ID;
	document.movementForm.submit();
}


function dummyImg(origImg,imgURL) {
	origImg.src = "img/loader_anim.gif";
	origImg.src = imgURL;
}

// In GUIDED SEARCH, This controls the navigation through steps and results
function guidedNavSubmit(step,results) {
	thisForm = document.forms["navForm"];
	thisForm.step.value = step;
	thisForm.showResults.value = results;
	thisForm.submit();
}

// IN PLANT PROFILE, Toggle between two images
function switchImg(img1,img2) {
	thisImg = document.images["plantImg"];
	if (thisImg.src == img1) {
		dummyImg(thisImg,img2);
		//thisImg.src = img2;
	} else {
		thisImg.src = img1;
	}
}



// TOGGLE FORM in PLANT SEARCH from GUIDED to ADVANCED
 // main form name (with all variables must be called
function toggleForm(thisForm) {
	if (thisForm.view.value.toLowerCase() == "hg - find a flower results") {
		thisForm.searchType.value="guided";
		thisForm.view.value="hg - find a flower guided";
	} else {
		thisForm.view.value="hg - find a flower";
	}
	thisForm.submit();
}

// MOUSEOVERS
// define image arrays
mOutArray = new Array('img/arrow_left.gif', 'img/arrow_right.gif', 'img/contents_hot.gif', 'img/browse_left.gif', 'img/browse_right.gif', 'img/map_button.gif');
mOverArrayTemp = new Array('img/arrow_left_hover.gif', 'img/arrow_right_hover.gif', 'img/contents_hover.gif', 'img/browse_left_hover.gif', 'img/browse_right_hover.gif', 'img/map_button_hover.gif');

	
// load images into cache by transferring to new array and declaring src for each element.
mOverArray = new Array(mOverArrayTemp.length)
for (i = 0; i < mOverArrayTemp.length; i++) {
   mOverArray[i] = new Image
   mOverArray[i].src = mOverArrayTemp[i]
}		
		
// functions: loc points to an <img> tag; img points to an element in the array.
// note: full syntax for loc.src would be document.loc.src, but frames confuse the browser. with simply loc.src, 
// the browser defaults to the proper frame.
function mOver(loc, img) { 
loc.src = mOverArray[img].src;
}


function mOut(loc, img) {
loc.src = mOutArray[img];		// don't need .src here since these images are cached via body <img> tags.
}




// HURL not used
// populate array with URL's.
var urlBank = new Array ("http://explore.cornell.edu/beebe/36_overlook.html", "http://explore.cornell.edu/beebe/beebe_beach.html","http://explore.cornell.edu/beebe/before_falls.html","http://explore.cornell.edu/beebe/cave.html","http://explore.cornell.edu/beebe/footbridge.html","http://explore.cornell.edu/beebe/lovers_falls.html","http://explore.cornell.edu/beebe/lovers_leap.html","http://explore.cornell.edu/beebe/pumphouse.html","http://explore.cornell.edu/beebe/stone_bridge.html",
							"http://explore.cornell.edu/cascadilla/lower_falls.html","http://explore.cornell.edu/cascadilla/park.html","http://explore.cornell.edu/cascadilla/stewart_falls.html","http://explore.cornell.edu/cascadilla/stone_bridge.html","http://explore.cornell.edu/cascadilla/upper_entrance.html","http://explore.cornell.edu/cascadilla/upper_falls.html",
							"http://explore.cornell.edu/gardens/ad_white.html","http://explore.cornell.edu/gardens/conservatory.html","http://explore.cornell.edu/gardens/deans.html","http://explore.cornell.edu/gardens/minns.html","http://explore.cornell.edu/gardens/rockwell.html","http://explore.cornell.edu/gardens/ws_rock.html",
							"http://explore.cornell.edu/landmarks/bailey.html","http://explore.cornell.edu/landmarks/gw_smith.html","http://explore.cornell.edu/landmarks/herekles.html","http://explore.cornell.edu/landmarks/johnson_atrium.html","http://explore.cornell.edu/landmarks/sage.html","http://explore.cornell.edu/landmarks/uris.html","http://explore.cornell.edu/landmarks/uris_2.html","http://explore.cornell.edu/landmarks/wsh.html");


function gURL() {
	// get a random number. floor rounds down to nearest integer, thereby offsetting 0-codebase.
	randomNum = Math.floor(Math.random() * urlBank.length);

	// load URL.
	document.location.href = "http://www.wpg.cornell.edu/scene_" + urlBank[randomNum];
}


	

//POP-UPS

// enforce that the current window is in a popup -- call in body onLoad
//      newLoc is the location to redirect the parent window to
function enforcePopup(newLoc,type) {

	/*alert(typeof(window.opener.location.href));
	alert(isPossibleLocalURL(window.opener.location.href));
	alert(window.opener.location.href); */
/*
	if (typeof(window.opener) == "undefined" || typeof(window.opener.location.href) == "unknown" || !isPossibleLocalURL(window.opener.location.href)) { 
		openInPopup(window.location, type, type);
		location.replace(newLoc);
	} 
*/
/*	if (!window.opener && window.name == "") { 
		openInPopup(window.location, type, type);
		location.replace(newLoc);
	}*/
}





function isPossibleLocalURL(tLoc) {

// list all possible URL prefixes here
var localURLs = new Array("http://exploredev/", "http://explore/", "http://www.explore/", "http://beta1/", "http://beta7/");


	// loop through possible urls and check loc against it
  	for (var i=0; i<localURLs.length; i++) {
		if (tLoc.substring(0,localURLs[i].length) == localURLs[i]) {
			return true;
		}
	}
	return false;
}



function enforceFrames(mainPg,amendVars) {
	if (top.location.href.indexOf(mainPg) == -1){ 
		top.location.replace(mainPg+"?"+amendVars); 
	} 
}

function enforceFramesInPopup(newLoc,type,mainPg,amendVars) {

	if (typeof(top.window.opener) == "undefined" || typeof(top.window.opener.location.href) == "unknown" || !isPossibleLocalURL(top.window.opener.location.href)) { 
		openInPopup(mainPg+"?"+amendVars, type, type);
		top.location.replace(newLoc);
	}

	
	/*if (!top.window.opener && top.window.name == "") {
		openInPopup(mainPg+"?"+amendVars, type, type);
		top.location.replace(newLoc);
	}*/
}


function openInPopup(thisH, type, windowname) {
	filename = thisH;
	switch (type) {
		case 'gallery': 		openGallery(filename, windowname);		break
		case 'slideshow':  		openSlideShow(filename, windowname);	break
		case 'audio':  			openAudio(filename, windowname);		break
		case 'video':  			openVideo(filename, windowname);		break
		case 'help':  			openHelp(filename, windowname);			break
		case 'about':  			openAbout(filename, windowname);		break
		case 'speciesscape':	openSpeciesScape(filename, windowname);	break
		case 'websites':  		openWebsites(filename, windowname);		break
	}
}

// pop-up windows: gallery
function openGallery(filename, windowname) {
  		slideShowWin = window.open(filename,windowname,'scrollbars=1,resizable=1,width=765,height=550,toolbar=0,status=0,menubar=0');
  		slideShowWin.focus();
}

// pop-up windows: slide show
function openSlideShow(filename, windowname) {
  		slideShowWin = window.open(filename,windowname,'scrollbars=1,resizable=1,width=600,height=500');
  		slideShowWin.focus();
}


// pop-up window: audio
function openAudio(filename, windowname) {
  		slideShowWin = window.open(filename,windowname,'scrollbars=1,resizable=1,width=600,height=450');
  		slideShowWin.focus();
  		
}


// pop-up windows: video 
function openVideo(filename, windowname) {
  		slideShowWin = window.open(filename,windowname,'scrollbars=1,resizable=1,width=600,height=450');
  		slideShowWin.focus();
}


// pop-up windows: help window 
function openHelp(filename, windowname) {
  		slideShowWin = window.open(filename,windowname,'scrollbars=1,resizable=1,width=500,height=400');
  		slideShowWin.focus();
}



// pop-up windows: about window 
function openAbout(filename, windowname) {
  		slideShowWin = window.open(filename,windowname,'scrollbars=1,resizable=1,width=400,height=360');
  		slideShowWin.focus();
}


// pop-up windows: species scape flash feature 
function openSpeciesScape(filename, windowname) {
  		slideShowWin = window.open(filename,windowname,'scrollbars=auto,resizable=1,width=700,height=550');
  		slideShowWin.focus();
}

// pop-up windows: websites
function openWebsites(filename, windowname) {
  		slideShowWin = window.open(filename,windowname,'scrollbars=1,resizable=1,width=400,height=500');
  		slideShowWin.focus();
}


function openPage(filename, windowname) {
  		slideShowWin = window.open(filename,windowname);
  		slideShowWin.focus();
		return slideShowWin;
}



// move me
function moveMe(newLoc,originNum) {
	
		if (newLoc.options[newLoc.selectedIndex].value != "") {
			document.location = newLoc.options[newLoc.selectedIndex].value;
		} else  {
			if (newLoc.selectedIndex != originNum) newLoc.selectedIndex= originNum;
		}
	
	}

// disable form submits on submit
function disableForm(thisform) {
	if (document.all || document.getElementById) {
		for (i = 0; i < thisform.length; i++) {
			var tempobj = thisform.elements[i];
			if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
				tempobj.disabled = true;
			}
			return true;
		}
	else {
		return false;
   	}
}
	

// -->


