// JavaScript Document

//AJAX FUNCTIONS
function getXmlHttpRequest()
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		return xmlHttp;
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			return xmlHttp;
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				return xmlHttp;
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
}
function sendRequest(url,task)
{
	
	var xmlHttp=getXmlHttpRequest();
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			responseText=xmlHttp.responseText;
			if(responseText.length>=2)
				taskDone(task,responseText.substring(0,2),responseText.substring(2));
		}
	}
	xmlHttp.open("GET",url,true);
  	xmlHttp.send(null);
}




//call like setInner(window,100,100);
function getBrowserType() 
{  
  if( typeof( window.innerWidth ) == 'number' ) 
  	return 1; //Non IE
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
    return 2; //IE 6,6+
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  	return 3; //IE 4
}

function setInner(width, height) {
	bType=getBrowserType();
	if(bType==1)
	{
    	window.innerWidth = width;
    	window.innerHeight = height;
	}
	else if(bType==2)
	{
		window.resizeBy(width-document.body.clientWidth, height-document.body.clientHeight);
	}
	/*else if(bType==3)
	{
		document.body.clientWidth=width;
		document.body.clientHeight=height;
	}*/
}

function setOuter(width, height) {
    window.outerWidth = width
    window.outerHeight = height
}

function restore() {
    window.outerWidth = originalWidth
    window.outerHeight = originalHeight
}

//form functions
function focusAndSelect(element)
{
	element.focus();
	element.select();	
}



function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}
