function setAction(form, action){
    document.getElementById(form).action.value = action;
}

/*Clear field on click*/
function clickclear(field, defval) {
    if (field.value == defval){
        field.value = ''
        field.style.fontStyle="normal"
        field.style.color="#333333"
    }
}

/*Set default value when field is empty*/
function restoredefault(field, defval){
    if(field.value==''){
        field.value=defval;
        field.style.fontStyle="italic"
        field.style.color="#888888"
    }
}

/*Count the number of character and display it in box*/
function charcount(field, maxlimit) {
    var cnt = field.value.length;
    if (cnt > maxlimit) // if too long trim text
        field.value = field.value.substring(0, maxlimit);
    else{
        document.getElementById("count").value = "Count: "+cnt+" out of 140 characters";
    }
}

function checkmemory(){
    document.getElementById("memory").checked = !document.getElementById("memory").checked;

    if (document.getElementById("memory").checked==true){
        document.getElementById("memoryDiv").style.background = "url('../images/memory.gif') no-repeat 0 -25px";
    }else{
        document.getElementById("memoryDiv").style.background = "url('../images/memory.gif') no-repeat 0 -2px";
        removeCookie();

    }
}

function hoverOnMemory(){
    document.getElementById("memoryDiv").style.background = "url('../images/memory.gif') no-repeat 0 -49px";
}

function hoverOffMemory(){
    if (document.getElementById("memory").checked==true){
        document.getElementById("memoryDiv").style.background = "url('../images/memory.gif') no-repeat 0 -25px";
    }else{
        document.getElementById("memoryDiv").style.background = "url('../images/memory.gif') no-repeat 0 -2px";
    }
}

function tempDisabled(elementId,delay){
    document.getElementById(elementId).disabled=true;
    setTimeout("document.getElementById('"+elementId+"').disabled=false",delay);
}