window.onload = function() {
    getNewWindowLinks();
}
// Display category images on Homepage
function showHPc(){
    var anch  = document.getElementById('content').getElementsByTagName('img');
    var spref = '/img/homepage/cat';
    var alen  = anch.length;
    for (i=0;i<alen;i++){
        var pnb = Math.floor(7*Math.random())+1; 
        anch[i].src = spref+(i+1)+pnb.toString()+'.jpg';
    }
}

function getswitch(){
    sch = document.getElementById('p-de');
    sch.onclick = function(){toggle('p-de' + 't', 'p-de')};
}

function toggle(divId,txtId){
    var d = (document.all)? document.all[divId] : document.getElementById(divId);
    var t = document.getElementById(txtId);
    if (d.style.display=='none'||d.style.display=='') {
        d.style.display = 'block';
        if (typeof t!="undefined" && t!=null){
            t.innerHTML = 'Andere Personen verstecken >>';
        };
    }
    else {
        d.style.display = 'none';
        if (typeof t!="undefined" && t!=null){
            t.innerHTML = 'Alle Personen anzeigen >>';
        };
    }
}

// Add the openInNewWindow function to the onclick event of links with a rel value = "external"
function getNewWindowLinks() {
    if (document.getElementById && document.createElement && document.appendChild) {
        // Find all links
        var links = document.getElementsByTagName('a');
        var link,llen = links.length;
        for (var i=0; i<llen;i++) {
            link = links[i];
            if (link.rel=='external') link.target = "_blank";
            if (link.rel=='helper') link.onclick = openInNewWindow;
        }
    }
}

// Create the new window
function openInNewWindow(e) {
    var event = (!e)? window.event : e;
    // Abort if a modifier key is pressed
    if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) {
        return true;
    }
    else {
        // Change "_blank" to something like "newWindow" to load all links in the same new window
        var newWindow = window.open(this.getAttribute('href'), 'Info','width=470,height=400');
        if (newWindow) {
            if (newWindow.focus) newWindow.focus();
            return false;
        }
        return true;
    }
}
function openBrWindow(theURL,winName,features) {
   window.open(theURL,winName,features);
}

function ShowHelpPage (url) {
    hlp=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=400,height=180');
}


// Display emoticons
function emo(tName,cName){
    var tags = document.getElementsByTagName(tName);
    var icop = '/img/icons/emoticons/';
    var tlen = tags.length;
    if (typeof cName!="undefined" && cName!=null){
        for (var i=0;i<tlen;i++){
            if (tags[i].className.match(cName)) display.changeSmiles(tags[i],icop);
        }
    } else {
        for (var i=0;i<tlen;i++) display.changeSmiles(tags[i],icop);
    }
}

// Page navigation
function changePage(pageNo){
    document.getElementById('pageID').value = pageNo;
    document.getElementById('othercamsFrm').submit();
    return false;
}
