function compat_makeXmlHttp()
{
    if (window.XMLHttpRequest)
    {
        var result = new XMLHttpRequest();

	if (result.overrideMimeType)
	{
		result.overrideMimeType("text/plain");
	}

	return result;
    }
    else if (ActiveXObject)
    {
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
        return null;
    }
}

function compat_event(event)
{
    var e;
    
    if (!event)
    {
        e = window.event;
    }
    else
    {
        e = event;
    }
    
    if (e && e.srcElement)
    {
        e.target = e.srcElement;
    }
    
    return e;
}

function isStructEmpty(struct)
{
    if (!struct)
    {
        return true;
    }
    
    for (var k in struct)
    {
        return false;
    }
    
    return true;
}

function compat_makePost(parts)
{
    var result = [];
    
    for (var k in parts)
    {
        result.push([encodeURIComponent(k), encodeURIComponent(parts[k])].join('='));
    }
    
    return result.join('&');
}

// some lists (like nodelists) don't do iteration properly.
//handler = function(value, key, count)
function compat_dodgyForeach(list, handler)
{
    var count = list.length;
    
    for (var i = 0; i < count; i++)
    {
        handler(list[i], i, count);
    }
}

//Cancels the default event
/*Input Parameter(s):
 *			event		-	event to cancel
 *
 *Output Parameter:
 *			void		-	cacnels the specified event
 */	
function compat_cancelDefaultEvent(event)
{
	//For mozzilla compatability
	if(event.preventDefault)
	{
		event.preventDefault();
	}
	//For IE Compatability
	else if(document.selection)
	{
		event.returnValue = false;
	}
	else
	{
		//for browsers other then mozzilla and ie. As a matter of fact i dont care.
		//alert('Please dont make life difficult for everyone.');
	}
}

function compat_shiftCursor(start, finish, field)
{
	

	//For mozzilla compatability
	if(field.setSelectionRange)
	{
		field.setSelectionRange(start, finish);
	}
	//For IE compatability
	else if(field.createTextRange)
	{
		var oRange = field.createTextRange();
		oRange.moveStart("character", start);
		oRange.moveEnd("character", -field.value.length + finish);
		oRange.select();
	}
	else
	{
		//text selection is not supported
	}
}

//Select the input search text
/*Input Parameter(s):
 *			start		-	starting index of the selection
 *			finish		-	ending index of the selection
 *			elementId	-	input text element id in which the text is selected
 *
 *Output Parameter:
 *			void		-	selects the specified text
 */	
function compat_selectText(start, finish, elementId)
{
	var oInputField = document.getElementById(elementId);

	//For mozzilla compatability
	if(oInputField.setSelectionRange)
	{
		oInputField.setSelectionRange(start, finish);
	}
	//For IE compatability
	else if(oInputField.createTextRange)
	{
		var oRange = oInputField.createTextRange();
		oRange.moveStart("character", start);
		oRange.moveEnd("character", -oInputField.value.length + finish);
		oRange.select();
	}
	else
	{
		//text selection is not supported
	}
}


//Get the starting index of the text selection
//If no text is selected then the length of the input text is returned
/*Input Parameter(s):
 *			elementId	-	input text element id in which the text is selected
 *
 *Output Parameter:
 *			start		-	if the text is selected then the starting index of the selection
 *							else the length of the text in the input field
 */
function compat_getStartingTextSelectionIndex(elementId)
{
	var oInputField = document.getElementById(elementId); 
	var start = 0;
	
	//For mozzilla compatability
	if(oInputField.selectionStart)
	{
		start = oInputField.selectionStart;
	}
	//For IE compatability
	else if(document.selection)
	{
		//Get the starting position of the text selection
		//1. Create a range on the current selection
		//2. Change the start position of the range by moving to the left by input value length until the end of the length
		//3. Since the move is to the left the value is always negative, change it to a positive value by getting the absolute value of the negative number
		start = Math.abs(document.selection.createRange().moveStart("character",-oInputField.value.length));
		
		//Take care of the position when no text has been selected.
		if (start == 0)
		{
			start = oInputField.value.length;
		}
	}
	else
	{
		//for browsers other then mozzilla and ie. As a matter of fact i dont care.
		//alert('Please dont make life difficult for everyone.');
	}
	
	return start;
}