﻿function clickButton(e, buttonid) {
    var evt = e ? e : window.event;
    var bt = document.getElementById(buttonid);

    if (bt) {
        if (evt.keyCode == 13) {
            bt.click(); 
            return false;
        }
    }
}


// http://bytes.com/topic/javascript/answers/437156-allow-only-numbers-input
function checkForFloat(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode;
    
    return ( (charCode >= 48 && charCode <= 57) || charCode == 44 || charCode == 46 );
}


function setStyleProp(elem, newStyle) {  // http: //stackoverflow.com/questions/344162/set-html-elements-style-property-in-javascript
    // Standards base browsers 
    elem.setAttribute('style', newStyle);

    // Non Standards based IE browser
    elem.style.setAttribute('cssText', newStyle);
}

function showHideElement(id) {
    var elem = document.getElementById(id);
    
    if (elem != undefined) {
        var style = elem.getAttribute('style');
        if (style == undefined) style = elem.getAttribute('cssText');  // bud pre ine prehliadace alebo pre explorer zoberieme style property

        if (style != undefined) {
            if (style == "") {
                setStyleProp(elem, "display:none;");
            } else {
                setStyleProp(elem, "");
            }
        } else {
            setStyleProp(elem, "display:none;");
        }
    }
}

