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 clicknoti()
{
	alert("Simply fill out the form below and you will be contacted with more information!");
	document.getElementById('email').style.background = '#FFEF7A';
	document.getElementById('email').focus();
	return false;
}

function onlyshowOne()
{
	try
	{
		MM_preloadImages('/newimages/nav-over.jpg');

        var the_a = document.getElementById('a_1');
		the_a.style.color = '#FFF';
		the_a.style.background = 'url(/newimages/nav-over.jpg) 100% 100% no-repeat';
		var tabContent = document.getElementById('tabcontent');
		var arrElem = getElementsByClass('hiddiv',tabContent);
		for (i=0;i<arrElem.length;i++)
		{
			if (arrElem[i].id != 'showTab_1')
			{
				arrElem[i].style.display = 'none';
			}
		}
		document.getElementById('showTab_1').style.display = '';
	}
	catch (e) {}
}

var olda = 1;
function mouseOverLi(tabid)
{
    if (tabid == 5)
    {
        document.getElementById('readmore').style.display = 'none';
    }
    else
    {
        document.getElementById('readmore').style.display = 'block';
    }

	var the_a = document.getElementById('a_'+tabid);
	var old_a = document.getElementById('a_'+olda);

	old_a.style.color = '#0E3566';
	old_a.style.background = 'url(/newimages/nav-btn.jpg) 100% 100% no-repeat';

	the_a.style.color = '#FFF';
	the_a.style.background = 'url(/newimages/nav-over.jpg) 100% 100% no-repeat';

	olda = tabid;

	var tabContent = document.getElementById('tabcontent');
	var arrElem = getElementsByClass('hiddiv',tabContent);
	for (i=0;i<arrElem.length;i++)
	{
		if (arrElem[i].id != 'showTab_'+tabid)
		{
			arrElem[i].style.display = 'none';
		}
	}
	document.getElementById('showTab_'+tabid).style.display = '';
    return false;
}

function nextLi()
{
    return mouseOverLi(olda+1);
}

function showEM(dom,user,where)
{
	if (where.className == 'reva')
	{
		return false;
	}

	where.className = 'reva';
	orig = dom+'@'+user;
	text = '';
	for (i = 0; i <= orig.length; i++)
	{
		text = orig.substring(i, i+1) + text;
	}
	where.href = "mailto:"+text;
	where.innerHTML = text;
	return false;
}

window.addOnloadEvent = function(addToOnload) {
var oldOnload;
if (window.onload) {
oldOnload = window.onload;
window.onload = function(){
oldOnload();
addToOnload();
};
}
else {
window.onload = addToOnload;
}
}

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (
			anchor.getAttribute("href") && (
			anchor.getAttribute("rel") == "external" ||
			anchor.getAttribute("rel") == "external nofollow" ||
			anchor.getAttribute("rel") == "nofollow external" )
			)
		anchor.target = "_blank";
	}
}

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;
}

function doevents()
{
	try {
	document.getElementById('a_1').onmouseover = function() { mouseOverLi(1); };
	document.getElementById('a_1').onfocus = function() { mouseOverLi(1); };
	document.getElementById('a_1').onclick = function() { mouseOverLi(1); return false; };
	document.getElementById('a_1').onkeypress = function() { mouseOverLi(1); return false; };

	document.getElementById('a_2').onmouseover = function() { mouseOverLi(2); };
	document.getElementById('a_2').onfocus = function() { mouseOverLi(2); };
	document.getElementById('a_2').onclick = function() { mouseOverLi(2); return false; };
	document.getElementById('a_2').onkeypress = function() { mouseOverLi(2); return false; };

	document.getElementById('a_3').onmouseover = function() { mouseOverLi(3); };
	document.getElementById('a_3').onfocus = function() { mouseOverLi(3); };
	document.getElementById('a_3').onclick = function() { mouseOverLi(3); return false; };
	document.getElementById('a_3').onkeypress = function() { mouseOverLi(3); return false; };

	document.getElementById('a_4').onmouseover = function() { mouseOverLi(4); };
	document.getElementById('a_4').onfocus = function() { mouseOverLi(4); };
	document.getElementById('a_4').onclick = function() { mouseOverLi(4); return false; };
	document.getElementById('a_4').onkeypress = function() { mouseOverLi(4); return false; };

	document.getElementById('a_5').onmouseover = function() { mouseOverLi(5); };
	document.getElementById('a_5').onfocus = function() { mouseOverLi(5); };
	document.getElementById('a_5').onclick = function() { mouseOverLi(5); return false; };
	document.getElementById('a_5').onkeypress = function() { mouseOverLi(5); return false; };
	
	document.getElementById('readmore1').onclick = function() { return nextLi(); };
	document.getElementById('readmore1').onkeypress = function() { return nextLi(); };
	
	} catch(e) {}
}

/*
Neato colored buttons!
*/
var btn = {
   init : function() {
       if (!document.getElementById || !document.createElement || !document.appendChild) return false;
       as = btn.getElementsByClassName('btn(.*)');
       for (i=0; i<as.length; i++)
       {
           if ( as[i].tagName == "INPUT" && ( as[i].type.toLowerCase() == "submit" || as[i].type.toLowerCase() == "button" ) )
           {
               var a1 = document.createElement("a");
				a1.title = as[i].value;
               a1.appendChild(document.createTextNode(as[i].value));
               a1.className = as[i].className;
               a1.id = as[i].id;
               as[i] = as[i].parentNode.replaceChild(a1, as[i]);
               as[i] = a1;
               as[i].style.cursor = "pointer";
				btn.addEvent(as[i],'click',function() {
				var form = btn.findForm(this);
				var hiddenElement = document.createElement("input");
				hiddenElement.setAttribute("type", "hidden");
				hiddenElement.setAttribute("name", "action");
				hiddenElement.setAttribute("value", this.title);
				form.appendChild(hiddenElement);
		                var ret = false;
		                if(typeof form.onsubmit == 'function') { ret = form.onsubmit(); }
		                if (!ret) { form.submit(); }
				});
				var i1 = document.createElement('i');
	            var i2 = document.createElement('i');
	            var s1 = document.createElement('span');
	            var s2 = document.createElement('span');
	            s1.appendChild(i1);
	            s1.appendChild(s2);
	            while (as[i].firstChild) {
	              s1.appendChild(as[i].firstChild);
	            }
	            as[i].appendChild(s1);
	            as[i] = as[i].insertBefore(i2, s1);
		     }  
		}
   },
   findForm : function(f) {
       while(f.tagName != "FORM") {
           f = f.parentNode;
       }
       return f;
   },
   addEvent : function(obj, type, fn) {
       if (obj.addEventListener) {
           obj.addEventListener(type, fn, false);
       }
       else if (obj.attachEvent) {
           obj["e"+type+fn] = fn;
           obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
           obj.attachEvent("on"+type, obj[type+fn]);
       }
   },
   getElementsByClassName : function(className, tag, elm) {
       var testClass = new RegExp("(^|\s)" + className + "(\s|$)");
       var tag = tag || "*";
       var elm = elm || document;
       var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
       var returnElements = [];
       var current;
       var length = elements.length;
       for(var i=0; i<length; i++){
           current = elements[i];
           if(testClass.test(current.className)){
               returnElements.push(current);
           }
       }
       return returnElements;
   }
}
btn.addEvent(window,'load', function() { btn.init();} );

window.addOnloadEvent(doevents);
window.addOnloadEvent(onlyshowOne);
window.addOnloadEvent(externalLinks);