/* ##############################################
# Charlotte School of Law						#
# File Name: global.js							#
# Date: 09.13.2006								#
# Contents: 									#
# 	- Mac Size Fix								#
# 	- Left Sidebar Profiles						#
# 	- Prototype Utilities & Global Functions	#
###############################################*/

/* ########
MAC SIZE FIX
######## */
function ns6fix() {
	if (navigator.userAgent.toLowerCase().indexOf('netscape')!=-1 && parseInt(parseFloat(navigator.appVersion)+1)==6) {
		objBodyWrap = document.getElementsByTagName("body").item(0);
		objAllDivs = document.getElementsByTagName("div");
		var objClear;

		for (i=0; i<objAllDivs.length; i++) {
			objClear = document.createElement("span");
			objClear.className = "clearblock";
			objClear.innerHTML = "&nbsp;";
			curDiv = objAllDivs[i];
			curDiv.appendChild(objClear);
		}
	}
}

function macfix() {
	var agt = navigator.userAgent.toLowerCase();
	var is_mac = (agt.indexOf("mac")!=-1);

	if (is_mac)	{ document.getElementById("body").style.fontSize = '11px'; }
}

window.onload = function() {
	macfix();
	ns6fix();
}

/* ########
PROTOTYPE UTILITIES & GLOBAL FUNCTIONS
######## */

Array.prototype.exists = function (x) {
	for (var i = 0; i < this.length; i++) {
		if (this[i] == x) return true;
	}
	return false;
}

function randOrd(a, b) {
	return (Math.round(Math.random())-0.5);
}
function findPosY(obj) {
	var curtop = 0;
	if(obj.offsetParent)
	while(1) {
		curtop += obj.offsetTop;
		if(!obj.offsetParent)
		break;
		obj = obj.offsetParent;
	}
	else if(obj.y)
	curtop += obj.y;
	return curtop;
}
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}


function toggleDrop(elem) {
	var ulObj = elem.parentNode.childNodes[2];
	var iOf = elem.parentNode.className.indexOf("Open");
	if (iOf < 0) {
		// menu item is already open	
		ulObj.style.display = "block";
		elem.parentNode.className += "Open";
	} else {
		ulObj.style.display = "none";
		elem.parentNode.className = elem.parentNode.className.substring(0,iOf);	
	}
}

function SpammersSuck(username, subject) {
    var hostname = "charlottelaw.edu";
    var linktext = username + "@" + hostname;
    if (subject.length > 0)
        document.write("<a href=\"mailto:" + linktext + "?Subject=" + subject + "\">" + linktext + "</a>")
    else
        document.write("<a href=\"mailto:" + linktext + "\">" + linktext + "</a>")
}