// this function is needed to work around 
// a bug in IE related to element attributes
function hasClass(obj) {
   var result = false;
   if (obj.getAttributeNode("class") != null) {
       result = obj.getAttributeNode("class").value;
   }
   return result;
}

function MT_actionButton(linkElement, linkFunction)	{
		if(!document.getElementById) return false;
		var le = document.getElementById(linkElement);
		if(!le) return false;
		var lf = linkFunction;
		le.onclick = function(){lf(); return false;};
}
	
function MT_printPage()
{
	window.print();
}

function MT_emailPage()
{
	var mailit = "mailto:?subject=Page on Blue Shield of California Foundation Website";
	mailit += "&body=%0D%0A%0D%0ABelow is a link to a page on Blue Shield of California Foundation's Website that might be of interest. To view the page visit:%0D%0A%0D%0A";
	mailit += +document.location.href;
	document.location.href = mailit;
	return false;
}

function MT_emailSignup(){
	document.forms["emailsignup"].submit();
	return false;
}

function MT_inputText(linkElement){
	if(!document.getElementById) return false;
	var le = document.getElementById(linkElement);
	if(!le) return false;
	le.originalvalue = le.value;
	le.onfocus = function(){
		if(this.value == this.originalvalue){
			le.value = "";
		}
	}
	le.onblur = function(){
		if(this.value == ""){
			this.value = this.originalvalue;
		}
	}
	
	
}

function MT_bookmarkPage()
{
	if (navigator.appName == 'Microsoft Internet Explorer' && 
	parseInt(navigator.appVersion) >= 4){
		window.external.AddFavorite(document.location.href,document.title);
	} else {
		alert("You can bookmark this page by using the keyboard shortcut 'Ctrl+D'")
	}	
}


function MT_keyfacts(divname, prefix, num)
{
	var div, html;
	if(!document.getElementById) return false;
	div = document.getElementById(divname);
	if(!div) return false;
	html = "<img src='"+prefix+(Math.round(Math.random()*[num-1])+1)+".gif' alt='Key Fact' />";
	div.innerHTML = html;
}

function MT_checkEmail(){
	if (document.forms.emailsignup["cm-35370-35370"].value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
	return true;
	else
	alert('Please check the email address you have entered.')
	return false;
}

function MT_stripelist(classname)
{
	var even = false;
	/* this cool stuff is conditional assignment :o) */
   	var evenColor = arguments[1] ? arguments[1] : "#fff";
   	var oddColor = arguments[2] ? arguments[2] : "#f7f";
	if(document.getElementsByTagName)
	{
		var uls = document.getElementsByTagName('ul')	;
		if (!uls) { return; }
		for (var t = 0; t< uls.length; t++)
		{
			var ul = uls[t];
			
			var a = ul.className.split(' ');
	 		for (z = 0; z < a.length; z++)
			{
				if (a[z] == classname)
				{	
				   	var lis = ul.getElementsByTagName("li");
				   	for (var h = 0; h < lis.length; h++)
					{
						lis[h].style.backgroundColor = even ? evenColor : oddColor;
				  		// flip from odd to even, or vice-versa
				       even =  ! even;					     
					}
				}
			}
  		}
	}
}
