function XY(x,y)
{
	this.Left = x;
	this.Top = y;
} 

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function WindowSize() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	return [myWidth, myHeight];
}

/* 
 * Begin XMLHTTP request object methods */
var xmlHttp;
function XmlHttp(inUrl, outMethod)
{
	var Url = inUrl;
	var Target = outMethod;

	xmlHttp = GetXmlHttpObject();

	if (xmlHttp == null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}

	var url = Url;
	xmlHttp.onreadystatechange = eval(Target);
	xmlHttp.open("POST", url, true);
	xmlHttp.send(url);
}

function GetXmlHttpObject()
{
	xmlHttp = null;
	try
	{
		// For Firefox
		xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		// Try IE
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
/* 
 * End XMLHTTP request object methods */

function DisplayDoc(docId, schoolId)
{
	var winId = window.open("docViewer.php?din="+docId+","+schoolId, "DocViewer","width=580,height=440,toolbar=no, scrollbars=1");
}

function Pop(url)
{
	var child = window.open(url, "NewWindow", "width=800, height=600");
}

function View(imgSource, w, h)
{
	var _dim = [0,0];

	var _percent = (w > h) ? 350/w : 350/h;
	if (percent < 1)
	{
		_dim[0] = w*percent;
		_dim[1] = h*percent;
	}
	else
	{
		_dim[0] = w;
		_dim[1] = h;
	}
	return _dim;
}

function IsValidTime(value) 
{
   var hasMeridian = false;
   var re = /^\d{1,2}[:]\d{2}([:]\d{2})?( [aApP][mM]?)?$/;

   if (!re.test(value)) { return false; }

   if (value.toLowerCase().indexOf("a") != -1 || value.toLowerCase().indexOf("p") != -1) { hasMeridian = true; }

   var values = value.split(":");

   if ( (parseFloat(values[0]) < 0) || (parseFloat(values[0]) > 23) ) { return false; }
   if (hasMeridian) 
   {
      if ( (parseFloat(values[0]) < 1) || (parseFloat(values[0]) > 12) ) { return false; }
   }
   if ( (parseFloat(values[1]) < 0) || (parseFloat(values[1]) > 59) ) { return false; }
   if (values.length > 2) 
   {
      if ( (parseFloat(values[2]) < 0) || (parseFloat(values[2]) > 59) ) { return false; }
   }
   return true;
}
			
function FormatTime(t)
{
	var meridiem = "am";
	var time = t;
	var timeSplit = time.split(":");
	var workingTime = timeSplit[0] + timeSplit[1];
	
	if (workingTime > 1159)
	{
		// time is PM
		meridiem = "pm";
		workingTime = (workingTime > 1259) ? workingTime - 1200 : workingTime;
		workingTime = (workingTime < 1000) ? "0" + workingTime : workingTime;
	}
	var strpos = (workingTime < 1000) ? 1 : 0;
	var strlen = (workingTime < 1000) ? 1 : 2;
	var displayTime = workingTime.substr(strpos, strlen) + ":" + workingTime.substr(2, 2) + " " + meridiem;

	return (displayTime);
}
