//  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 : "buymusichere.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("\">" + lnktxt + "<\/a>");
} // print_mail_to_link


// 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'));
			} // end function
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('-over'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			} // end function
		} // endif
	} // endfor
} // initRollovers

function openpopup(img){
  var imgpfx = "images/equipment/"
  var image = imgpfx + img
  var feat = "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=300,height=300"
  
  window.open(image,"",feat)
}  // open equipment popup


function MM_findObj(n, d) { //v4.01
 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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
} // MM_validateForm

window.onload = initRollovers;
