function email(one, two) {
	document.write('<A href="mailto&#58;' + one + '&#64;' + two + '"><i>' + one + '&#64;</i><i>' + two + '</i></A>')
}
function isEmpty (inputString) {
	if (inputString==null || inputString=="") {return true;}
	return false
}

function popupImage (imageURL, imageTitle) {
	popup = window.open("","wir_popup", "menubar,resizable,scrollbars");
	if (!popup) return;
	popup.document.write("<HTML><Head><Title>" + imageTitle + "</Title></Head>"
		+ "<Body><H3>" + imageTitle + "</H3><Img src=\"" + imageURL + "\"></HTML>");
	popup.document.close()
}

function isIE () {
	return (navigator.appName.indexOf("Internet Explorer") != -1)
}

function isSafari () {
	return (navigator.userAgent.indexOf("Safari") != -1)
}

function isWin () {
	return (navigator.userAgent.indexOf("Win") != -1)
}

function isMac () {
	return (navigator.platform.substring(0,3) == 'Mac')
}

function isNav () {
	return (navigator.appName == "Netscape")
}

function isNav6 () {
	return ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 5));
}

function MM_findObj(n, d) { //v3.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[ii][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
 return x;
}
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 xgetElementById (elemID) {
	return (document.getElementById) ? document.getElementById(elemID) : ((document.all) ? document.all[elemID] : null);
}

// normalize coordinate planes by factoring out CSS borders in Netscape
// (from Javascript & DHTML Cookbook)
function getElementStyle (elemID, IEStyleAttr, CSSStyleAttr) {
	var elem = xgetElementById(elemID);
	if (elem.currentStyle) {
		return elem.currentStyle[IEStyleAttr];
	}
	else if (window.getComputedStyle) {
		var compStyle = window.getComputedStyle(elem, "");
		return compStyle.getPropertyValue(CSSStyleAttr);
	}
	return "";
}

// get the coordinates of an event within a _positioned_ element
// (from Javascript & DHTML Cookbook)
// added borders.top check so that this works in Safari
function getPositionedEventCoords (elemID, evt) {
	var elem = (evt.target) ? evt.target : evt.srcElement;
	var coords = {left:0, top:0};
	if (evt.layerX) {
		var borders = {left:parseInt(getElementStyle(elemID,
			"borderLeftWidth", "border-left-width")),
			top:parseInt(getElementStyle(elemID, "borderTopWidth",
			"border-top-width"))};
		if (borders.top) {
			coords.left = evt.layerX - borders.left;
			coords.top = evt.layerY - borders.top;
		}
		else {
			coords.left = evt.layerX;
			coords.top = evt.layerY;
		}
	} else if (evt.offsetX) {
		coords.left = evt.offsetX;
		coords.top = evt.offsetY;
	}
	evt.cancelBubble = true;
	return coords;
}

function confirmAdminAction (checkboxName) {
	var checked = document.forms.admin_form[checkboxName].checked;
	if (checked) return true;
	alert("You must put a check in the checkbox to perform the " + checkboxName + " action.");
	return false;
}

function confirmCommentAction (checkboxName, commentName) {
	if (document.forms.comment_form[checkboxName].checked) return true;
	alert("You must put a check in the checkbox to complete the " + checkboxName + " operation.");
	return false;
}

function showHide (livePlaceID, hidingPlaceID, defaultHREF, hideLinkOnShow) {
	var liveplace = xgetElementById(livePlaceID);
	var hidingplace = xgetElementById(hidingPlaceID);
	var linkplace = xgetElementById('link_'+livePlaceID);

	if (!liveplace || !hidingplace) {
		location.href = defaultHREF;
		return;
	}

	// show
	if (liveplace.childNodes.length == 0) {
		while (hidingplace.childNodes.length > 0) {
			liveplace.appendChild(hidingplace.removeChild(hidingplace.firstChild));
		}
		
		if (linkplace) {
			linkplace.style.display = 'none';
		}
	}
	
	// hide
	else {
		while (liveplace.childNodes.length > 0) {
			hidingplace.appendChild(liveplace.removeChild(liveplace.firstChild));
		}
	}
}

function bytesToString (size) {
	var x = Math.floor(size / (1024*1024*1024));
	if (x > 0) return ""+x+"GB";
	x = Math.floor(size / (1024*1024));
	if (x > 0) return ""+x+"MB";
	x = Math.floor(size / (1024));
	if (x > 0) return ""+x+"KB";
	return ""+x+" bytes";
}

function listProperties (obj, name) {
	var output = "";
	for (var i in obj) {
		output += name + "." + i + " = " + obj[i] + "\n";
	}
	alert(output);
}

// from http://www.dustindiaz.com/getelementsbyclass/
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
