var xmlHttp;

//Will attempt to crate XMLHttpRequest object if the browser supports it.
function verifyBrowser()
{  
	try
	{ 
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();    
	}
	catch (e)
	{    
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
			}
			catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
			}     
		}    
	} 
}

/* adds a function to the onload event handler */
function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

/*	Detects the browser */
function detectBrowser()
{
	var browser = navigator.appName;
	return browser;
}

//Will adjust the height of an element
function adjustHeightRealTime(element)
{
	if(typeof(element) != "object")
		element = document.getElementById(element);
	
	element.style.height = element.scrollHeight+"px";
}

function changeClass(element,class_name)
{
	//Accept objects and id's of objects
	if(typeof(element) != "object")
		element = document.getElementById(element);
	
	element.className = class_name;
}

//Performs the click method on a search button.
//Called when enter is pressed when the focus is on the search field.
function doSearch(event,searchButtonID)
{
	//13 is the keycode for enter key
	if(event.keyCode == 13)
	{
		var searchButton = document.getElementById(searchButtonID);
		if(searchButton)
		{
			searchButton.click();
		}
	}
}

function submitForm(form,action,target, validated)
{
	if(!validated) return;
	
	form.action = action;
	form.target = target;
	form.submit();
}
