// Skills for Justice Horizon Scan JavaScript
var min_search_chars = 2;

function getElementsByClassName(oElm, strTagName, oClassNames){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();
	if(typeof oClassNames == "object"){
		for(var i=0; i<oClassNames.length; i++){
			arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
		}
	}
	else{
		arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
	}
	var oElement;
	var bMatchesAll;
	for(var j=0; j<arrElements.length; j++){
		oElement = arrElements[j];
		bMatchesAll = true;
		for(var k=0; k<arrRegExpClassNames.length; k++){
			if(!arrRegExpClassNames[k].test(oElement.className)){
				bMatchesAll = false;
				break;
			}
		}
		if(bMatchesAll){
			arrReturnElements.push(oElement);
		}
	}
	
	return (arrReturnElements);
}

// Array support for the push method in IE 5

if(typeof Array.prototype.push != "function") {
	Array.prototype.push = ArrayPush;

	function ArrayPush(value) {
		this[this.length] = value;
	}
}


function toggle_vis(obj) {
	var el = document.getElementById(obj);
    if (el.style.display != 'none' ) {
    	el.style.display = 'none';
    }
    else {
    	el.style.display = '';
    }
}

function valNavSearch() {
	var val = document.navsearchfrm.query.value;
	var def_val = document.navsearchfrm.query.defaultValue;
	
	if(val == def_val || val.length < min_search_chars) {
		return false;
	}
	
	return true;
}

function flashobject_xhtml(movie,width,height,quality,wmode,bgcolor,image,alt) {
	// note this technique does not stream swf in IE - not recommended for large swf
	// a stub swf should be used to load large movies 
	flash_object = '<object type="application/x-shockwave-flash" data="'+movie+'" width="'+width+'" height="'+height+'">';
	flash_object += '<param name="movie" value="'+movie+'" />';
	flash_object += '<param name="quality" value="'+quality+'" />';
	flash_object += '<param name="wmode" value="'+wmode+'" />';
	flash_object += '<param name="bgcolor" value="'+bgcolor+'" />';
	flash_object += '<img src="'+image+'" width="'+width+'" height="'+height+'" alt="'+alt+'" />';
	flash_object += '</object>';
	
	document.write(flash_object);
}

startList = function() {
	// IE 6 and below: Amend styles for <ul><li> elements for 'a:hover' styles to 'a.over'
	// For drop down menu
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			
			if (node.nodeName=="ul") {
				for (j=0; j<node.childNodes.length; j++) {
					node_child = node.childNodes[j];
					if (node_child.nodeName=="li") {
						node_child.onmouseover=function() {
							this.className+=" over";
						}
						node_child.onmouseout=function() {
							this.className=this.className.replace(" over", "");
						}
					}
				}
			}
		}
	}
}
window.onload=startList;