// Image roll-over function that works via the classname for an image.
function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '-over'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('-over'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}
/* uncomment next line to load automatically */
/* window.onload = initRollovers;*/

// make a link be clickable multiple times with each click firing doing something unique.
var clickee = '';
function multiClick() {
/*	for (var i=0; i<multiClick.arguments.length; i++) { 
		document.write (multiClick.arguments[i] + "<br>");
	}  */
	if (multiClick.arguments.length > 0) {
		if (multiClick.arguments[0] != clickee) {
			if(clickee) {
				document.getElementById('span_' + clickee.name).innerHTML = '';
			}
			//then do first thing
			eval(multiClick.arguments[1]);
			// then set this to clickee
			clickee = multiClick.arguments[0];
		} else {
			for (var i=2; i<multiClick.arguments.length; i++) {
				eval(multiClick.arguments[i]);
			}
		}
	}
}


// goto URL
function gotoURL(url) {
	location.href = url;
}


//  Break email address into into components
// original script snagged from Web Blazonry www.blazonry.com
// modified by me(Beau) to allow for user-defined link text and style class
// 031704 - modified again by Beau to allow for user-defined user and server address
// var lhs = "beau";
// var rhs = "halibutharpoon.com";
function print_mail_to_link(lhs, rhs, lnkclass, lnktxt) {

	lhs 			= ((lhs) && lhs != "" ? lhs : "beau");					// site specific, obviously
	rhs 			= ((rhs) && rhs != "" ? rhs : "halibutharpoon.com");	// ditto
	addy 			= lhs + "@" + rhs;
	styleclass 	= ((lnkclass) && lnkclass != "" ? "class=\"" + lnkclass + "\"" : "");
	lnktxt 		= ((lnktxt) && lnktxt != "" ? lnktxt : addy);
	
	document.write("<A " + styleclass + " HREF=\"mailto");
	document.write(":" + addy);
	document.write("\"><span>" + lnktxt + "</span><\/a>");
}


// correctly handle PNG transparency in Win IE 5.5 or higher.
function correctPNG() 
   {
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }
window.attachEvent("onload", correctPNG);
