function changeLogin(field) {
    document.getElementById(field).value = '';
    //document.getElementById(field).style.color = '#000000';
    if (field == 'password') {
        document.getElementById('pwdtxt').style.visibility = 'hidden';
        document.getElementById('pwdtxt').style.position = 'absolute';
        document.getElementById('password').focus();
    }
}

function showNews(id) {
    if (document.getElementById('text-'+id).style.visibility == 'hidden' || document.getElementById('text-'+id).style.visibility == '') {
        document.getElementById('text-'+id).style.visibility = 'visible';
        document.getElementById('text-'+id).style.position = 'relative';
        document.getElementById('arrow-'+id).className = 'reduce';
    } else {
        document.getElementById('text-'+id).style.visibility = 'hidden';
        document.getElementById('text-'+id).style.position = 'absolute';
        document.getElementById('arrow-'+id).className = 'expand';
    }
}

function showComments(id) {
    if (document.getElementById('comments').style.visibility == 'hidden' || document.getElementById('comments').style.visibility == '') {
        document.getElementById('comments').style.visibility = 'visible';
        document.getElementById('comments').style.position = 'relative';

        elm = getElementsByClass('comment');
        for(var i = 0; i < elm.length; i++) {
            elm[i].style.position = "relative";
        }

        document.getElementById('arrow').className = 'reduce';
    } else {
        document.getElementById('comments').style.visibility = 'hidden';
        document.getElementById('comments').style.position = 'absolute';

        elm = getElementsByClass('comment');
        for(var i = 0; i < elm.length; i++) {
            elm[i].style.position = "absolute";
        }

        document.getElementById('arrow').className = 'expand';
    }
}

function getElementsByClass(searchClass,node,tag) {
    var classElements = new Array();
    if(node == null) node = document;
    if(tag == null) tag = '*';

    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");

    for(i = 0, j = 0; i < elsLen; i++) {
        if (pattern.test(els[i].className) ) {
            classElements[j] = els[i];
            j++;
        }
    }

    return classElements;
}



function vote(value) {
    document.getElementById('vote').value = value;
}

function disableItem(name,id) {
    if (confirm('Are you sure you want to disable '+name+' ?     ')) {
        url = window.location.href;
        tmp = url.split('?');
        url = tmp[0];

        url += 'disable.html?id='+id
        window.location.href = url;
    }
}

function desactiverItem(name,id) {
    if (confirm('Êtes-vous certain de vouloir désactiver '+name+' ?     ')) {
        url = window.location.href;
        tmp = url.split('?');
        url = tmp[0];

        url += 'desactiver.html?id='+id
        window.location.href = url;
    }
}

function deleteItem(name,id) {
    if (confirm('Are you sure you want to delete '+name+' ?     ')) {
        url = window.location.href;
        tmp = url.split('?');
        url = tmp[0];

        url += '?delete='+id
        window.location.href = url;
    }
}

function supprimerItem(name,id) {
    if (confirm('Êtes-vous certain de vouloir supprimer '+name+' ?     ')) {
        url = window.location.href;
        tmp = url.split('?');
        url = tmp[0];

        url += '?delete='+id
        window.location.href = url;
    }
}
