
<!-- hide scripts from crusty old browsers
//cme_site.js 2/2002
// Jon Bertsch - IR&C - IM
	
//Check that there's radio button checked before going to the edit page		
	function checkeditbox(edit_record){
	
	//There's a bug in the original script I used editOption = -1;
	//When there's only one record the script fails. WHY?
	//Either var editOption; or editOption = ""; seem to work. WRONG
	//Same for the next script below, which does the same check.
		//var editOption;
		editOption = "-1";
		for (i=0; i<edit_record.edit_id.length; i++){
		   if (edit_record.edit_id[i].checked) {
			editOption = i;
		}	
		}	if (editOption == -1){
			alert ("You must choose an event to edit");
			return false;
			}
			return true;
	}
//Check that there's a radio button checked before going to the delete page
	function checkdeletebox(delete_record){
	
		var deleteOption = "-1";
		for (i=0; i<delete_record.delete_id.length; i++){
		   if (delete_record.delete_id[i].checked) {
			deleteOption = i;
		}	
		}	if (deleteOption == -1){
		
			alert ("You must choose an event to delete");
			return false;
			}
			return true;
	}
	
// Check there's a title for the add record on view.php
	function checkTitleValue(addRecord) {
		
		if(document.addRecord.title.value == "") {
			alert("You must enter a Title");
			return false;
		} 
		return true;
	}
	
//check email for the user registration form
//javascript for form verification

	function emailValidate(registration) {
		evilChars = " /:,;$^*%"
		
			// make sure they enter a name
			if (document.registration.name.value == "") {
				alert("You must enter a name")
				return false
				}

			if (document.registration.email.value == "") {		
				alert ("You must enter a valid email address") 
				 return false
		 }

			for (i=0; i<evilChars.length; i++) { // does it contain any invalid characters?
				badChar = evilChars.charAt(i)
			if (document.registration.email.value.indexOf(badChar,0) > -1){
			alert ("You must enter a valid email address")
					return false
				}
			}
		 atPos = document.registration.email.value.indexOf("@",1)			// there must be one "@" symbol
			if (atPos == -1) {
			alert ("You must enter a valid email address")
				return false
			}
			
			if (document.registration.email.value.indexOf("@",atPos+1) != -1) {
				// and only one "@" symbol
				alert ("You must enter a valid email address")
				return false
			}
			
			periodPos = document.registration.email.value.indexOf(".",atPos) // and at least one "." after the "@"
			if (periodPos == -1) {		
			alert ("You must enter a valid email address")
				return false
			}
			
			if (periodPos+3 > document.registration.email.value.length){// must be at least 2 characters after the "."
alert ("You must enter a valid email address")
				return false
		 } 
		 
		return true
	}
	
	
//Javascript redirect for campus calendar selections

function formPointer(form){
var URL = document.moveit.place.options[document.moveit.place.selectedIndex].value;

window.location.href = URL;
}


//image rotate script for med school pix
var imagesRotate = new Array("pix/ucsf.jpg", "pix/davis.jpg", "pix/irvine.jpg", "pix/ucla.jpg", "pix/sandiego.jpg");

nextImage=0

function rotImages() {
if(document.images) {
	nextImage++
	if (nextImage == imagesRotate.length) {
	nextImage = 0}
	}
	document.imageSolutions.src=imagesRotate[nextImage]
	setTimeout('rotImages()',5*1000)
}



var interval = 5; // delay between rotating images (in seconds)

var random_display = 0; // 0 = no, 1 = yes
interval *= 1000;
var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem("pix/ucsf.jpg");
image_list[image_index++] = new imageItem("pix/davis.jpg");
image_list[image_index++] = new imageItem("pix/irvine.jpg");
image_list[image_index++] = new imageItem("pix/ucla.jpg");
image_list[image_index++] = new imageItem("pix/sandiego.jpg");

var number_of_image = image_list.length;

function imageItem(image_location) {
this.image_item = new Image();
this.image_item.src = image_location;

}
function get_ImageItemLocation(imageObj) {

return(imageObj.image_item.src)

}

function generate(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}

function getNextImage() {
if (random_display) {
image_index = generate(0, number_of_image-1);
}

else {
image_index = (image_index+1) % number_of_image;
}
var new_image = get_ImageItemLocation(image_list[image_index]);
return(new_image);
}

function rotateImage(place) {
var new_image = getNextImage();
document[place].src = new_image;
var recur_call = "rotateImage('"+place+"')";
setTimeout(recur_call, interval);
}
//function rotateImage(rImage) {
//var new_image = getNextImage();
//document[rImage].src = new_image;
//var recur_call = "rotateImage('"+rImage+"')";
//setTimeout(recur_call, interval);
//}

var rand1 = 0;
var useRand = 0;
images = new Array;
images[1] = new Image();
images[1].src = "pix/ucsf.jpg";
images[2] = new Image();
images[2].src = "pix/davis.jpg";
images[3] = new Image();
images[3].src = "pix/irvine.jpg";
images[4] = new Image();
images[4].src = "pix/sandiego.jpg";
images[4] = new Image();
images[4].src = "pix/sandiego.jpg";

function swapPic() {
var imgnum = images.length - 1;
do {

var randnum = Math.random();

rand1 = Math.round((imgnum - 1) * randnum) + 1;

} while (rand1 == useRand);

useRand = rand1;

//document.randimg.src = images[useRand].src;
document.rImage.src = images[useRand].src;
}


//Useful pieces for the pop_up
//<a href="javascript:openWin('link.html', 'name');">here </a>
//<BODY onLoad="setTimeout(window.close, 5000)">
//<a href="javascript:window.close();">Close This Window</a>

var windowIsOpen = "false";

function openWin(url, name) {
  popupWin = window.open(url, name, "menubar,resizable,scrollbars,width=450,height=300");
  windowIsOpen = "true";
  //window.focus();
}



	// done hiding -->

