//Generate commentary text for required textboxes
function SetCommentary(elementID, commentaryText, commentaryClassName)
{
    var element = document.getElementById(elementID);
    
    if (element.value == '')
    {
        element.value = commentaryText;
        element.className = commentaryClassName;
    }
}

function RemoveCommentary(elementID, commentaryText, defaultClassName)
{
    var element = document.getElementById(elementID);
    
    element.className = defaultClassName;
    
    if (element.value == commentaryText)
    {
        element.value = '';
    }
}

//Block non numercal key values
function BlockNonNumericalsValue(id, allowNegativeNumbers, leadingNumbersCount, decimalCount, englishDecimal, e)
{   
	var key = '';
	var success = false;
	var decimalType = '.';

    if (!englishDecimal)
    {
        decimalType = ',';
    }

    if (!e)
    {
        key = event.keyCode ? event.keyCode : event.which;
    }
    else
    {
        key = e.keyCode ? e.keyCode : e.which;
    }
    
    if (document.getElementById(id).value == null || document.getElementById(id).value == '') 
    {
        return true;
    }
    
    var regString = '';
    
    if (decimalCount == 0)
    {
        if (allowNegativeNumbers)
        {
            regString = '^[-]$|^[-]?(0)$|^[-]?([1-9][0-9]{0,' + (leadingNumbersCount - 1) + '})$';
        }
        else
        {
            regString = '^(0)$|^([1-9][0-9]{0,' + (leadingNumbersCount - 1) + '})$';
        }
    }
    else
    {
        if (allowNegativeNumbers)
        {
            regString = '^[-]$|^[-]?(0)$|^[-]?([1-9][0-9]{0,' + (leadingNumbersCount - 1) + '})$|^[-]?([0-9]{0,' + leadingNumbersCount + '}\\' + decimalType + '[0-9]{0,' + decimalCount + '})$';
        }
        else
        {
            regString = '^(0)$|^([1-9][0-9]{0,' + (leadingNumbersCount - 1) + '})$|^([0-9]{0,' + leadingNumbersCount + '}\\' + decimalType + '[0-9]{0,' + decimalCount + '})$';
        }
    }
    
    var reg = new RegExp(regString);
    
    success = reg.test(document.getElementById(id).value);
	
	return success;
}

//Set attributes using javascript
function SetAttribute(id, attributeName, attributeValue)
{
    document.getElementById(id).setAttribute(attributeName, attributeValue);
}

//Set style using javascript
function SetStyle(id, styleName, styleValue)
{
    document.getElementById(id).style[styleName] = styleValue   ;
}

