/* basic functions */

/* expand submenu */
function showSub(which) {
	if( which ) {
		var submenuArr = document.getElementById('menu').getElementsByTagName('ul');
		for(var i=0; i < submenuArr.length; i++){
			if(submenuArr[i].className.indexOf('submenu') != -1){
				if((submenuArr[i].id == document.getElementById(which).id) && (document.getElementById(which).style.display == 'none')){
					document.getElementById(which).style.display = 'block';
				}else if((submenuArr[i].id == document.getElementById(which).id) && (document.getElementById(which).style.display == 'block')){
					document.getElementById(which).style.display = 'none';
				}else{
					submenuArr[i].style.display = 'none';
				}
			}
		}
	}
}

function urchinPDF() {
    
    as = document.getElementsByTagName("a");
    
    for (i = 0; i < as.length; i++) {
        
        href  = as.item(i).getAttribute("href");
        path  = href.split("/");
        parts = path[path.length - 1].split(".");
        
        if (parts[parts.length - 1].toLowerCase() == "pdf" ||
            parts[parts.length - 1].toLowerCase() == "doc") {
            urchinhref = href.replace("http://" + window.location.hostname, "");
            as.item(i).setAttribute("urchinhref", urchinhref);
            as.item(i).onclick = function() {
                //alert(this.getAttribute("urchinhref"));
                //return false;
                urchinTracker(this.getAttribute("urchinhref"));
            }
        }
    }
    
}

//-- change language
function setLanguage(_lang) {
    window.location.href = window.location.pathname.replace(/\/(nl|en|es|fr|de)/, "/" + _lang) + window.location.search;
}

addOnLoadFunction("urchinPDF");
