function openWin(url, name) {
  popupWin = window.open(url, name, "resizable,width=500,height=350,left=0,top=0");
  windowIsOpen = "true";
  popupWin.focus()
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function modifyDate() {
	
var months = new Array();
months[1] = "January";
months[2] = "February";
months[3] = "March";
months[4] = "April";
months[5] = "May";
months[6] = "June";
months[7] = "July";
months[8] = "August";
months[9] = "September";
months[10] = "October";
months[11] = "November";
months[12] = "December";

dateObj = new Date(document.lastModified);
lmonth = months[dateObj.getMonth() + 1];
date = dateObj.getDate();
year = dateObj.getYear();
if (year < 1000) year += 1900;

pagemod = document.write ("Last updated:" + " " + lmonth + " " + date + ", " + year);

return pagemod;
}

function checkEmail(myForm) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(feedback.email.value)) 
		{
		return (true)
		}
	alert("Invalid e-mail address! Please re-enter.")
	return (false)
	}

function protectAddress( name, account, domain )	{
	var tag1 = "mai"
	var tag2 = "lto:" 
	document.write("<a h" + "ref=" + tag1 + tag2 + account + "@" + domain + ">"+name +"</a>");
	}
	
/* display random links in "Project Partners" section on home page */

var random_links = {
	_links : [
		'<a href="http://www.bth.ca.gov/">California Business, Transportation and Housing Agency</a>',
		'<a href="http://www.bth.ca.gov/depts/dmhc.asp">California Department of Managed Health Care</a>',
		'<a href="http://www.oes.ca.gov/Operational/OESHome.nsf/">California Governor\'s Office of Emergency Services</a>',		
		'<a href="http://www.chhs.ca.gov/">California Health and Human Services Agency (CHHS)</a>',
		'<a href="http://www.calhealth.org/public/about/related.html#chft">California Health Foundation and Trust</a>',
		'<a href="http://www.calit2.net/">CA Institute for Telecommunications and Information Technology (CalIT2)</a>',
		'<a href="http://www.cpuc.ca.gov/puc/">California Public Utilities Commission</a>',
		'<a href="http://www.cpca.org/">California Primary Care Association</a>',		
		'<a href="http://www.csrha.org/">California State Rural Health Association</a>',
		'<a href="http://www.cteconline.org/">California Telemedicine and eHealth Center</a>',
		'<a href="http://www.calhealth.org/">California Hospital Association</a>',		
		'<a href="http://www.citris-uc.org/">The Center for Information Technology Research in the Interest of Society (CITRIS)</a>',
		'<a href="http://www.cvhnclinics.org/">Central Valley Health Network</a>',
		'<a href="http://www.cchealthnetwork.com/about.aspx">Community Clinics Health Network</a>',
		'<a href="http://www.oehe.ihs.gov/telemed/">Indian Health Service</a>',
		'<a href="http://www.nsrhn.org/">Northern Sierra Rural Health Network</a>',
		'<a href="http://gov.ca.gov/">Office of the Governor</a>',
		'<a href="http://www.oshpd.ca.gov/">Office of Statewide Health Planning and Development (OSHPD)</a>',
		'<a href="http://www.opendoorhealth.com/">Open Door Health Network/Open Door Community Health Center</a>',
		'<a href="https://www.rrh.org/ridgecrest/services.aspx">Southern Sierra Telehealth Network</a>'
		],

	fill : function(id, num) {
		var except = []
		var container = document.getElementById(id);
		var ul = document.createElement('ul');

		if (num > this._links.length)
			num = this._links.length;

		for(var i=0; i<num; i++) {
			text = this.find(except); // find our random text
			if (text == null) // if we get null, we ran out of things to find
				break;

			var li = document.createElement('li'); // create the element...
			li.innerHTML = text; // ... with the text

			ul.appendChild(li); // add it to the ul
			except.push(text); // keep track of what we've selected.
		}

		container.appendChild(ul);
	},

	find : function(except) {
		except = except || [];

		var links_copy = this._links;
		for(var i=0; i<except.length; i++) {
			links_copy = this.remove_from_array(links_copy, except[i]);
		}

		if (links_copy.length == 0)
			return null;

		idx = Math.floor(Math.random() * links_copy.length);
		return links_copy[idx];
	},

	remove_from_array : function(arr, elm) {
		var new_array = [];
		for(var i=0; i<arr.length; i++) {
			if (elm != arr[i]) {
				new_array.push(arr[i]);
			}
		}
		return new_array;
	}
}