function viewCard(name, id) {
    var cards=document.getElementsByName(name);
    for (i=0; i<cards.length; i++) {
        cards[i].style.display='none';
    }
    if(is_ie){
        cards = document.getElementsByTagName('div');
        for(i = 0; i < cards.length; i++) {
            att = cards[i].getAttribute('name');
            if(att == name) {
                cards[i].style.display='none';
            }
        }
    }
    document.getElementById(id).style.display='block';
    document.mainForm.mode.value=id;
}

function setFocus() {
    try {
        document.getElementById('wantFocus').focus();
    } catch (e) {
        try {
            document.forms[0].elements[0].focus();
        } catch (e) {}
    }
}

function getRadioValue(groupName) {
    return (getRadioObject(groupName) != '' && getRadioObject(groupName).value != undefined) ? getRadioObject(groupName).value : '';
}

function getRadioObject(groupName) {
    var radObject = document.getElementsByName(groupName);
    for (x=0; x<radObject.length; x++) {
        if (radObject[x].checked) {
            return radObject[x];
        }
    }
    return '';
}

function getComboValue(comboId) {
    var combo = document.getElementById(comboId);
    return combo.options[combo.selectedIndex].value;
}

function placeBackground() {
    document.body.style.backgroundPosition='100% 0%';
}

function consistOfSpace(str) {
    for (j = 0; j < str.length; j++) {
        if (str.substr(j,1)!=' ') return false;            
    }
    return true;
}

function createHidden(name, value) {
    var result = document.createElement('input');
    result.setAttribute('type', 'hidden');
    result.setAttribute('name', name);
    result.setAttribute('value', value);
    return result;
}

function createHiddenWithId(name, id, value) {
    var result = document.createElement('input');
    result.setAttribute('type', 'hidden');
    result.setAttribute('name', name);
    result.setAttribute('id', id);
    result.setAttribute('value', value);
    return result;
}

function validateName(name, message){
    if (name=='' || consistOfSpace(name)) {
        alert(message);
        setFocus();
        return false;
    }
    return true;
}

function validateFloat(obj, nLength, nPrecision) {
    if (obj.value != '') {
        if (obj.value.indexOf(',') >= 0) {
            obj.value = obj.value.replace(',', '.');
        }
        var strVal = new String(obj.value);
        var nIndexOfDot = strVal.indexOf('.');
        var nValidLength = nIndexOfDot==-1?strVal.length:strVal.length+1
        if (nValidLength < strVal.length) {
            alert('Maximum length can be '+nLength);
            strVal = strVal.substring(0,nValidLength);
        }
        if (strVal.charAt(strVal.length-1) != '.' || nIndexOfDot!=(strVal.length-1)) {
            if (isNaN(parseFloat(strVal))) {
                strVal='0';
            }
            obj.value=parseFloat(strVal);
        }
        if (-1 != nIndexOfDot && strVal.substring(nIndexOfDot+1).length > nPrecision) {
            strVal=strVal.substring(0, strVal.length-1);
            obj.value=strVal;
        }
    }
}

function viewWaitSplash() {
    viewElement('waitsplash');
}

function hideWaitSplash() {
    hideElement('waitsplash');
}

function viewElement(id) {
    document.getElementById(id).style.display = displayBlock;
}

function hideElement(id) {
    document.getElementById(id).style.display = 'none';
}

