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 inoFindPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function inoFindPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function inoEscapeStrip(script)
{
	while (script.indexOf("&lt;")!=-1) script=script.replace("&lt;", String.fromCharCode(60));
	while (script.indexOf("&gt;")!=-1) script=script.replace("&gt;", String.fromCharCode(62));
	while (script.indexOf("&amp;")!=-1) script=script.replace("&amp;", String.fromCharCode(38));
	while (script.indexOf(String.fromCharCode(38, 113, 117, 111, 116, 59))!=-1) script=script.replace(String.fromCharCode(38, 113, 117, 111, 116, 59), String.fromCharCode(34));

	return script;
}


// ****************************************************************
// AJAX functions
// ****************************************************************

//First things first, set up our array that we are going to use.
	var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + //all caps
	"abcdefghijklmnopqrstuvwxyz" + //all lowercase
	"0123456789+/="; // all numbers plus +/=

//Heres the encode function
function encode64(inp)
{
	var out = ""; //This is the output
	var chr1, chr2, chr3 = ""; //These are the 3 bytes to be encoded
	var enc1, enc2, enc3, enc4 = ""; //These are the 4 encoded bytes
	var i = 0; //Position counter

	do 
	{ 
		//Set up the loop here
		chr1 = inp.charCodeAt(i++); //Grab the first byte
		chr2 = inp.charCodeAt(i++); //Grab the second byte
		chr3 = inp.charCodeAt(i++); //Grab the third byte

		//Here is the actual base64 encode part.
		//There really is only one way to do it.
		enc1 = chr1 >> 2;
		enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
		enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
		enc4 = chr3 & 63;

		if (isNaN(chr2)) 
		{
			enc3 = enc4 = 64;
		} 
		else if (isNaN(chr3)) 
		{
			enc4 = 64;
		}	

		//Lets spit out the 4 encoded bytes
		out = out + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) +
		keyStr.charAt(enc4);

		// OK, now clean out the variables used.
		chr1 = chr2 = chr3 = "";
		enc1 = enc2 = enc3 = enc4 = "";

	} 
	while (i < inp.length); //And finish off the loop

	//Now return the encoded values.
	return out;
}

//Heres the decode function
function decode64(inp)
{
	var out = ""; //This is the output
	var chr1, chr2, chr3 = ""; //These are the 3 decoded bytes
	var enc1, enc2, enc3, enc4 = ""; //These are the 4 bytes to be decoded
	var i = 0; //Position counter

	// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
	var base64test = /[^A-Za-z0-9\+\/\=]/g;

	if (base64test.exec(inp)) 
	{ 
		//Do some error checking
		alert("There were invalid base64 characters in the input text.\n" +
		"Valid base64 characters are A-Z, a-z, 0-9, ?+?, ?/?, and ?=?\n" +
		"Expect errors in decoding.");
	}
	
	inp = inp.replace(/[^A-Za-z0-9\+\/\=]/g, "");

	do 
	{ 
		//Here’s the decode loop.

		//Grab 4 bytes of encoded content.
		enc1 = keyStr.indexOf(inp.charAt(i++));
		enc2 = keyStr.indexOf(inp.charAt(i++));
		enc3 = keyStr.indexOf(inp.charAt(i++));
		enc4 = keyStr.indexOf(inp.charAt(i++));

		//Heres the decode part. There’s really only one way to do it.
		chr1 = (enc1 << 2) | (enc2 >> 4);
		chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
		chr3 = ((enc3 & 3) << 6) | enc4;

		//Start to output decoded content
		out = out + String.fromCharCode(chr1);

		if (enc3 != 64) 
		{
			out = out + String.fromCharCode(chr2);
		}
		
		if (enc4 != 64) 
		{
			out = out + String.fromCharCode(chr3);
		}

		//now clean out the variables used
		chr1 = chr2 = chr3 = "";
		enc1 = enc2 = enc3 = enc4 = "";

	} 
	while (i < inp.length); //finish off the loop

	//Now return the decoded values.
	return out;
}

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);
            }
        }
    }

}