/**********************************************************************
Deze functie kijkt of de enter knop is ingedrukt in het trefwoord veld.
**********************************************************************/
function handleKeyPress(e){
    var key=e.keyCode || e.which;
    if (key==13){
        showSearch(document.getElementById('keyword').value);
    }
}




/**********************************************************************
Stop teh click event from passing throught the dom object
**********************************************************************/
function stopClick(e){
    if (!e){
        var e = window.event;
    }
    e.cancelBubble = true;
    if (e.stopPropagation){
        e.stopPropagation();
    }
}



/**********************************************************************
You can use the checkForTag method to check whether specific tags exist.
**********************************************************************/
function checkForTag(tag){
    if(tag != undefined){
        return true;
    } else {
        return false;
    }
}

/**
*   Return document.getElementById() without the typing.
**/
function $(id){
    return document.getElementById(id);
}


/**********************************************************************
Statistieken teller. De stats zijn in webbeheer uit te lezen.
Je kan een pagina adres opgeven (handig voor ajax requests).
Als je geen pagina opgeeft wordt document.location.href gebruikt. 
**********************************************************************/
function pageHit(pagina){
    
    if(pagina != null){
        p = escape(pagina);
    } else {
        p = escape(document.location.href);
    }
        
    rfr = escape(document.referrer);
    if (rfr == "undefined"){ rfr = "";}
    sx = screen.width;
    sy = screen.height;
    sc = (navigator.appName.indexOf("Microsoft") > -1) ? screen.colorDepth : screen.pixelDepth;
    src = 'stats.php?p=' + p + '&rfr=' + rfr + '&sx=' + sx + '&sy=' + sy + '&sc=' + sc;
    //src = '<img style="position:absolute;left:-10px;top:-10px;" src="' + src + '" width="1" height="1" border="0" alt="" />';
    src = '<img src="' + src + '" width="1" height="1" border="0" alt="" />';
    
    document.getElementById('counter').innerHTML = src;
}

function cleanInput(sValue, sInputId){
    el = $(sInputId);
    
    if ( el.value == sValue ) {
        el.value='';
    }
}



/**********************************************************************
Drie functie om cookies te gebruiken binnen javascript
**********************************************************************/
function createCookie(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+"="+value+expires+"; path=/";
}

function readCookie(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 c.substring(nameEQ.length,c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name,"",-1);
}

function cookieHandler(){
    if ( document.getElementById('setcookie').checked ) {        
        createCookie('hideHelp', true, 31);        
    } else {        
        eraseCookie('hideHelp');        
    }
}
