function _inwEnterPressToButtonClick(buttonId, evt)
{
	if (evt == null)
	{
		evt = window.event; 
	}
	
	if(!evt)
	{
		return; 
	}

	var key = 0; 
	
	if (evt.keyCode) 
	{ 
		key = evt.keyCode; 
	}
	else if (typeof(evt.which)!= 'undefined') 
	{
		// for moz if keyCode==0 use 'which'
		key = evt.which;		
	}
	
	if (key == 13)
	{
		var btn = document.getElementById(buttonId);
		
		if (btn != null)
		{
			btn.click();
		}
		
		return false;
	}
}


function _inwEnterPressToNull(evt)
{
	if (evt == null)
	{
		evt = window.event; 
	}
	
	if(!evt)
	{
		return; 
	}

	var key = 0; 
	
	if (evt.keyCode) 
	{ 
		key = evt.keyCode; 
	}
	else if (typeof(evt.which)!= 'undefined') 
	{
		// for moz if keyCode==0 use 'which'
		key = evt.which;		
	}
	
	if (key == 13)
	{
		return false;
	}
}

function _inwKeyPressToPostBack(keyCode, ctrlTarget,  ctrlArgument, evt)
{
	if (evt == null)
	{
		evt = window.event; 
	}
	
	if(!evt)
	{
		return; 
	}

	var key = 0; 
	
	if (evt.keyCode) 
	{ 
		key = evt.keyCode; 
	}
	else if (typeof(evt.which)!= 'undefined') 
	{
		// for moz if keyCode==0 use 'which'
		key = evt.which;		
	} 
	
	if (key == keyCode)
	{
		__doPostBack(ctrlTarget,ctrlArgument);
		return false;
	}
};


function setTodayDate(cbDayId,cbMonthId,cbYearId)
{
	var d = new Date()
	var ctrlDay = document.getElementById(cbDayId);
	var ctrlMonth = document.getElementById(cbMonthId);
	var ctrlYear = document.getElementById(cbYearId);
	
	if (ctrlDay != null) ctrlDay.value = d.getDate();
	if (ctrlMonth != null) ctrlMonth.value = d.getMonth() + 1;
	if (ctrlYear != null) ctrlYear.value = d.getFullYear();
}


function ino_IsValidEmail(email)
{
    return email.match('^.+@.+[.].+$');
}

function ino_CopyrightYear(startYear)
{
	d = new Date();
	
	if (startYear != d.getFullYear())
		{
		return startYear + " - " + d.getFullYear();
		}
	else
		{
		return startYear;
		}
}

// Variables to hold mouse x-y pos.s
var ino_MouseLocation = new Object();
    ino_MouseLocation.X = 0;
    ino_MouseLocation.Y = 0;

//document.onmousemove = ino_GetMouseXY;

// Main function to retrieve mouse x-y pos.s
function ino_GetMouseXY(e)
{
    // Detect if the browser is IE or not.
    // If it is not IE, we assume that the browser is NS.
    var IE = document.all ? true : false;
    
	if (IE) { // grab the x-y pos.s if browser is IE
		ino_MouseLocation.X = window.event.clientX + document.body.scrollLeft;
		ino_MouseLocation.Y = window.event.clientY + document.body.scrollTop;
	} else {  // grab the x-y pos.s if browser is NS
		ino_MouseLocation.X = e.pageX;
		ino_MouseLocation.Y = e.pageY;
	}  
	// catch possible negative values in NS4
	if (ino_MouseLocation.X < 0){ino_MouseLocation.X = 0;}
	if (ino_MouseLocation.Y < 0){ino_MouseLocation.Y = 0;}  
}

function inoHideControl(controlID, transitionID, stayDuration, transitionDuration)
{
    switch (transitionID)
    {
        case 0: 
            window.setTimeout("document.getElementById('"+controlID+"').style.display='none'", stayDuration);
            break;
        case 1: 
            window.setTimeout("inoTransitionFade('"+controlID+"', 100, 'fadeOut', " + 10000/transitionDuration + ")", stayDuration);
            break;            
    }
}

function inoTransitionFade(controlID, opacity, fadeDirection, fadeStep)
{  
    var ctrl = document.getElementById(controlID);
    
    if (!ctrl)
    {
        return;
    }
    
    if (ctrl.style.opacity != null )
    {
        ctrl.style.opacity = opacity/100;
    }

    if (ctrl.style.filter != null)
    {
        ctrl.style.filter = 'alpha(opacity=' + opacity + ')';
    }

    if (fadeDirection == "fadeIn")
    {
        opacity+=fadeStep;
    }
    else
    {
        opacity-=fadeStep;
    }

    if ((fadeDirection == "fadeIn" && opacity <= 100)||(fadeDirection == "fadeOut" && opacity > 0))
    {
        window.setTimeout("inoTransitionFade('" + controlID + "'," + opacity + ", '" + fadeDirection + "'," + fadeStep + ")", 100);
    } 
    else if (fadeDirection == "fadeOut")
    {
        ctrl.style.display = "none";
    }
}


// ****************************************************************
// AJAX functions
// ****************************************************************
function ReceiveCallBackData(callBackResult, context) 
{
    var actionMatches = callBackResult.match(/<Action>([\s\S]*?)<\/Action>/gi);

    if (actionMatches != null) {
        for (var xmlNodeCounter = 0; xmlNodeCounter < actionMatches.length; xmlNodeCounter++) {
            var actionType = actionMatches[xmlNodeCounter].match(/<Type>(.*?)<\/Type>/i)[1];

            if (actionType == null) {
                alert('Missing xml element - type');
            }

            if (actionType.toLowerCase() == 'setproperty') {
                var controlId = actionMatches[xmlNodeCounter].match(/<Id>(.*?)<\/Id>/i)[1];
                var controlProperty = actionMatches[xmlNodeCounter].match(/<Property>(.*?)<\/Property>/i)[1];
                var propertyValue = actionMatches[xmlNodeCounter].match(/<Value>([\s\S]*?)<\/Value>/i)[1];
                var control = document.getElementById(controlId);

                if (control != null) {
                    eval("control." + controlProperty + " = propertyValue;");
                }

                //Uncomment to debug the property value  
                //alert("document.getElementById('"+controlId+"')." + controlProperty + "= " + eval("document.getElementById('"+controlId+"')." + controlProperty));
            }
            else if (actionType.toLowerCase() == 'evalscript') {
                var evalScript = actionMatches[xmlNodeCounter].match(/<Script>([\s\S]*?)<\/Script>/i)[1];
                eval(evalScript);
            }
        }
    }
}

function ErrorMessage(node)
{
    //var controlId = node.match(/<id>(.*?)<\/id>/)[1];
    //var controlProperty = node.match(/<property>(.*?)<\/property>/)[1];
    //var controlSubProperty = node.match(/<subproperty>(.*?)<\/subproperty>/)[1];
    var propertyValue = node.match(/<value>(.*?)<\/value>/)[1];

    alert(propertyValue);
}


