function masterDataFormPost1(actionValue, actionControlId)
{
    document.getElementById(actionControlId).value = actionValue;   
}

function onDeleteClick(actionControlId, identifierValue, identifierControlId)
{
    if (confirm('Are you sure you wish to delete this record?'))
    {
        masterDataFormPost('Delete', actionControlId, identifierValue, identifierControlId);
        return true;
    }
    else
    {
        return false;
    }
}

function masterDataFormPost(actionValue, actionControlId, identifierValue, identifierControlId)
{
    document.getElementById(actionControlId).value = actionValue;    
    document.getElementById(identifierControlId).value = identifierValue;    
}

function fnDiscardKey()
{    
	var key = window.event.keyCode;
	window.event.returnValue = null;
	
	return;  	
}

function masterDataFormPostWithThreeValues(actionValue, actionControlId, identifierValue, identifierControlId, identifierValue2, identifierControlId2)
{
    document.getElementById(actionControlId).value = actionValue;
    document.getElementById(identifierControlId).value = identifierValue;
    document.getElementById(identifierControlId2).value = identifierValue2;
}


function masterDataFormPost4(actionValue, actionControlId, identifierValue, identifierControlId, identifierValue2, identifierControlId2, identifierValue3, identifierControlId3)
{
    document.getElementById(actionControlId).value = actionValue;
    document.getElementById(identifierControlId).value = identifierValue;    
    document.getElementById(identifierControlId2).value = identifierValue2;
    document.getElementById(identifierControlId3).value = identifierValue3;    
}

function masterDataFormPost5(actionValue, actionControlId, identifierValue, identifierControlId, identifierValue2, identifierControlId2, identifierValue3, identifierControlId3, identifierValue4, identifierControlId4)
{
    document.getElementById(actionControlId).value = actionValue;
    document.getElementById(identifierControlId).value = identifierValue;
    document.getElementById(identifierControlId2).value = identifierValue2;    
    masterDataFormPost(identifierValue3, identifierControlId3, identifierValue4, identifierControlId4)
}

function switchRowStyle(controlId, currentStyleClass)
{
    document.getElementById(controlId).className = ((document.getElementById(controlId).className == currentStyleClass) ? 'SelectedRow' : currentStyleClass);
}

function getCoords()
{
	var scrollX, scrollY;
	if (document.all)
	{
		if (!document.documentElement.scrollLeft)
			scrollX = document.body.scrollLeft;
		else
			scrollX = document.documentElement.scrollLeft;

		if (!document.documentElement.scrollTop)
			scrollY = document.body.scrollTop;
		else
			scrollY = document.documentElement.scrollTop;
	}
	else
	{
		scrollX = window.pageXOffset;
		scrollY = window.pageYOffset;
	}
	document.getElementById('scrollLeft').value = scrollX;
	document.getElementById('scrollTop').value = scrollY;	
}

function scrollToPosition(what) {
    document.getElementById(what).scrollTop = document.getElementById('scrollTop').value;
}

function setScrollPosition(val) {
    document.getElementById('scrollTop').value = val.scrollTop;
}

function pageWidth() {
    return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;
}

function pageHeight() {
    return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;
}

function setPageSize() {
    document.getElementById('pageWidth').value = pageWidth();
    document.getElementById('pageHeight').value = pageHeight();
}

function findPos(obj) {
	var curleft = curtop = 0;	
    if (obj.offsetParent) {   
        do {        
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
            } while (obj = obj.offsetParent);
		//return [curleft,curtop];
		return curtop;
	}	
}

function scrollToRow(checkBoxId, controlId) {    

    if (!document.getElementById(checkBoxId))
        return;

    var intialScrollPosition = document.getElementById('scrollTop').value;
    
    if (intialScrollPosition == '') {
        intialScrollPosition = '0'; }

    document.getElementById('txt_' + checkBoxId).focus();
    document.getElementById('txt_' + checkBoxId).blur();
    
    changeCheckboxState('d', controlId);
    
    document.getElementById(checkBoxId).checked = 1;    
    insertSelectedValueInTextbox(checkBoxId, controlId);
    
    if (document.getElementById('row_1_'+checkBoxId))		    
    {
        document.getElementById('row_1_'+checkBoxId).className = 'SelectedRow';
    }
    else
    {
        if (document.getElementById('row_0_'+checkBoxId))
        {
            document.getElementById('row_0_'+checkBoxId).className = 'SelectedRow';
        }
    }
    
    var scrollPosition = document.getElementById('scrollArea').scrollTop;
    
    if (scrollPosition == '') {
        scrollPosition = '0'; }
    
    if (parseInt(scrollPosition) < parseInt(intialScrollPosition)) {
        document.getElementById('txt_top_' + checkBoxId).focus(); 
        document.getElementById('txt_top_' + checkBoxId).blur();
        }        
            
    /*try {
        document.getElementById('row_0_' + checkBoxId).style.backgroundColor = 'yellow';        
    }
    catch(err) {alert('nr');}
    try {
        document.getElementById('row_1_' + checkBoxId).style.backgroundColor = 'yellow';
    }
    catch(err) {alert('nr2');}*/
}