var WebGear = window.WebGear || { };

WebGear.regenerateContactCaptcha = function() {
	new Ajax.Updater('captchaBox', WEBSITE_URL + 'Helpers/GetNewContactCaptchaImage/');
}

WebGear.toggleTreeNavigation = function(currElement) {
	if(currElement.className == "closed") currElement.className = "open";
	else currElement.className = "closed";

	var allElems = $$('ul.docNavigation li.open');

	for(var i = 0; i < allElems.length; i++) {
		if(allElems[i] != currElement) allElems[i].className = "closed";
	}
}

window.onload = function() {
    parseLinks();
}

/**
 * Parses all the links in the page, and sets them target accordingly
 * This is done to preserve the validity of the XHTML document.
 */
var parseLinks = function()
{
    var links = document.getElementsByTagName('a');

    if(links.length > 0) {
        for(i = 0; i < links.length; i++) {
            if(links[i].rel) {
                if(links[i].rel == 'external') {
                    links[i].target = '_blank';
                }
            }
        }
    }
}
