function checkUncheckAll(theElement) {
    var theForm = theElement.form, z = 0;
    for(z=0; z<theForm.length;z++){
        if(theForm[z].type == 'checkbox' && theForm[z].name != 'check_all'){
            theForm[z].checked = theElement.checked;
        }
    }
}

function resetKey(e){
    var code;

    if(e && e.which){ //if which property of event object is supported (NN4)
        e = e;
        code = e.which; //character code is contained in NN4's which property
    }
    else{
        e = event;
        code = e.keyCode; //character code is contained in IE's keyCode property
    }

    if ((code==17)||(code==16)||(code==18)) ctrl=0;
}

function checkEmail(email){

    if(email != ''){
        if(email.match(/^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}/) == null){
           return true;
        }
        else return false;
    }
}


function checknumber(e){
    var code;
    
    if(e && e.which){ //if which property of event object is supported (NN4)
        e = e
        code = e.which; //character code is contained in NN4's which property
    }
    else{
        e = event
        code = e.keyCode; //character code is contained in IE's keyCode property
    }
    
    if (e.ctrlKey) return 1; 
    if ((code>47&&code<58)||(code>95&&code<106)||code==9||code==8||code==116||code==13||code==37||code==39||code==45||code==36||code==33||code==35||code==46) {
        return true;
    }
    e.returnValue=false;
    return false;
}

function checksum(e,obj){   
    
    var code;
    
    if(e && e.which){ //if which property of event object is supported (NN4)
        e = e;
        code = e.which; //character code is contained in NN4's which property
    }
    else{
        e = event;
        code = e.keyCode; //character code is contained in IE's keyCode property
    }
    
    //obj=e.srcElement;
    
    if (code==110||code==190) {   
        var bla = new String(obj.value);
        if (bla.search(/\./)==-1) {
            //obj.value=obj.value+'.';
            e.returnValue=true;
            return true;
        }
        e.returnValue=false;
        return false;
    }

    if (code==109||code==189) {
        var bla=new String(obj.value);
        if (bla.search(/-/)==-1) {
            e.returnValue=true;
            return true;
        }
        e.returnValue=false;
        return false;
    }

    if (e.ctrlKey) return 1; 
    if ((code>47&&code<58)||(code>95&&code<106)||code==9||code==110||code==190||code==8||code==116||code==13||code==37||code==39||code==45||code==36||code==33||code==35||code==46) {
        e.returnValue=true; 
        return true;
    }
    e.returnValue=false;
    return false;
}

function checkenter(e){
    if(e && e.which){ //if which property of event object is supported (NN4)
        e = e;
        code = e.which; //character code is contained in NN4's which property
    }
    else{
        e = event
        code = e.keyCode; //character code is contained in IE's keyCode property
    }
    //alert(code);
    if(code == 13 && now_sel > -1) return false;
}

    function reset_form(id){
        form = $(id);
        selects = form.getElementsBySelector('select');
        
        for(i=0; i<form.elements.length; i++){
            if(form.elements[i].type != 'submit' && form.elements[i].type != 'button'){
                form.elements[i].value = "";
            }
        }
        
        for(i=0; i<selects.length; i++){
            selects[i].value = "-2";
        }
    }