function popup() {
	// check to see that the browser supports the getElementsByTagName method
	// if not, exit the loop
	if (!document.getElementsByTagName) {
		return false; 
	} 
	// create an array of objects of each link in the document 
	var popuplinks = document.getElementsByTagName("a");
	// loop through each anchor tag
	for (var i=0; i < popuplinks.length; i++) {	
		// if the link has a class of "popup"
		if (popuplinks[i].className == "popup") {
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, openPopUp 	
			popuplinks[i].onclick = function() {	
				openPopUp(this.getAttribute("href"));
				return false; 	
			} 	
		}
	} 
}
function openPopUp(linkURL) {
	window.open(linkURL,'popup');
}

function hideems(div,status) {
	if (status == 1) {
		status = "block";
	} else {
		status = "none";	
	}
	if (document.all) {
		document.getElementById(div).style.display = status;
	} else if (document.getElementById) {
		document.getElementById(div).style.display = status;
	}
}

function showems(div,status) {
	if (status == 1) {
		status = "none";
	} else {
		status = "block";	
	}
	if (document.all) {
		document.getElementById(div).style.display = status;
	} else if (document.getElementById) {
		document.getElementById(div).style.display = status;
	}
}

function emailCloak() {
	if (document.getElementById) {
		var alltags = document.all? document.all : document.getElementsByTagName("*");
		for (i=0; i < alltags.length; i++) {
		  if (alltags[i].className == "emailCloak") {
			var oldText = alltags[i].firstChild;
			if(oldText) {
			    var emailAddress = alltags[i].firstChild.nodeValue;
			    if(emailAddress != null) {
			        var user = emailAddress.substring(0, emailAddress.indexOf("("));
			        var website = emailAddress.substring(emailAddress.indexOf(")")+1, emailAddress.length);
			        var newText = user+"@"+website;
			        var a = document.createElement("a");
			        a.href = "mailto:"+newText;
			        var address = document.createTextNode(newText);
			        a.appendChild(address);
			        alltags[i].replaceChild(a,oldText);
			    }
		    }
		  }
		}
	}
}
window.onload = emailCloak;


function Homepage() {
	DocURL = document.URL;
	protocolIndex=DocURL.indexOf("://",4);
	serverIndex=DocURL.indexOf("/",protocolIndex + 3);
	
	BeginURL=DocURL.indexOf("#",1) + 1;
	urlresult=DocURL.substring(BeginURL,serverIndex);
	displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex);
	InsertElementAnchor(urlresult, displayresult);
}
function HtmlEncode(text) {
	return text.replace(/&/g, '&amp').replace(/'/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
function TagAttrib(name, value) {
	return ' '+name+'="'+HtmlEncode(value)+'"';
}
function PrintTag(tagName, needCloseTag, attrib, inner) {
	document.write( '<' + tagName + attrib + '>' + HtmlEncode(inner) );
	if (needCloseTag) document.write( '</' + tagName +'>' );
}
function URI(href) {
	IEVer = window.navigator.appVersion;
	IEVer = IEVer.substr( IEVer.indexOf('MSIE') + 5, 3 );

	return (IEVer.charAt(1)=='.' && IEVer >= '5.5') ?
		encodeURI(href) :
		escape(href).replace(/%3A/g, ':').replace(/%3B/g, ';');
}
function InsertElementAnchor(href, text) {
	PrintTag('A', true, TagAttrib('HREF', URI(href)), text);
}
function hasSearchTerms(frm)
{
    var val;
    for(var i=0; i<frm.elements.length; i++)
    {
        switch(frm.elements[i].type)
        {
            case "text":
                val = frm.elements[i].value;
                break;
            case "select-one":
                val = frm.elements[i].options[frm.elements[i].selectedIndex].value;
                break;
            default:
                val = "";
        }
        if(val.length > 0) return true;
    }
    alert("Please enter some search criteria.");
    return false;
}

function flashDetect9() {
    var flashDiv;
    var flashPrompt = "<div class=\"centered tac\">Download <a href=http://www.adobe.com/go/getflash/>Adobe Flash Player version 9</a> now to see enhanced content!</div>";
    if(!DetectFlashVer(9, 0, 0)) {
           
        if((flashDiv = document.getElementById("flash_graph1")) != null)
            flashDiv.innerHTML = flashPrompt; 

        if((flashDiv = document.getElementById("flash_graph2")) != null)
            flashDiv.innerHTML = flashPrompt;

        if((flashDiv = document.getElementById("flash_graph3")) != null)
            flashDiv.innerHTML = flashPrompt;
            
	if((flashDiv = document.getElementById("flash_video_small")) != null)
            flashDiv.innerHTML = '<a href="http://www.adobe.com/go/getflash/" target="_blank" rel="nofollow"><img src="/FLVPlayer/images/NoFlash-small.gif" /></a>'

	if((flashDiv = document.getElementById("flash_video_large")) != null)
            flashDiv.innerHTML = '<a href="http://www.adobe.com/go/getflash/" target="_blank" rel="nofollow"><img src="/FLVPlayer/images/NoFlash-large.gif" /></a>'
    }
}

function latestFlashVerDetected(){
    var result = true;
    if(!DetectFlashVer(9, 0, 0)) {
        result = false;
    }
    
    return result;
}

try {
    AddEventHandler(window,"load","flashDetect9");
} catch(e) {
    void(0);
}

//Trims string on left and right
function trim(sString) 
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
return sString;
}


function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));
    }
    return null;
}

function setCookie(name,value,days) {
if (days) {
	var date = new Date();
	date.setTime(date.getTime()+(days*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
}
    else var expires = "";
    document.cookie = name+"="+escape(value)+expires+"; path=/";
}


//check for empty form field
function IsEmpty(pfield) {
    if ((pfield.value.length==0) ||(pfield.value==null)) {
        return true;
    }
    else 
    { 
        return false; 
    }
}


function IsNumeric(sText)
{
    var ValidChars = "0123456789.";
    var IsNumber=true;
    var Char;

    for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
        Char = sText.charAt(i); 
        if (ValidChars.indexOf(Char) == -1) 
        {
            IsNumber = false;
        }
    }
    return IsNumber;
}

