﻿///*******************************************************************************
//*
//*   PowerSearch.js
//*   David Cordner
//*   Fluent Technology 2008
//*
//********************************************************************************/


/*******************************************************************************
*
*   Scripts to handle the search functions
*
********************************************************************************/

		var egmsdef;
		
		function getAllEGMSDefinitions()
		{
			var url = 'get/getEGMSDefinitions.aspx';
			xmlhttp=new HTTP();
			if (xmlhttp) 
			{				
				xmlhttp.open("GET",url,false);
				xmlhttp.onreadystatechange=ProcessEGMSDefinition;
   				xmlhttp.send();
			}
			else
			{
			alert('Failed to get statistics for this year.');
			}
		}
		
		
		function ProcessEGMSDefinition() 
		{
			if (xmlhttp.readyState == 4) 
			 {
				if (xmlhttp.status == 200) 
				{
					var obj = xmlhttp.responseXML;
					egmsdef = xmlhttp.responseXML.getElementsByTagName('row');
				}
				else
				 {alert("There was a problem retrieving the XML data:\n" + xmlhttp.statusText); }
    		 }
		}
		
		function getEGMSDefinition(el)
		{
			var div = document.getElementById('divEGMSDefinition');	
			for (var i = 0; i < egmsdef.length; i++) 
			{
				if (egmsdef[i].attributes[0].text == el)
				{
					div.innerHTML = egmsdef[i].attributes[1].text;
				}
			}
		}	
		
		
		function CheckReturn(el,sb)
		{
		var k = event.keyCode;
		if (k==13)
			{
			var z = checkSubmit(el);
			if (z==true)
			    {
			    __doPostBack(sb,'')
			    }
			 else
			    {return false;}
			}
		}
		
		function checkSubmit(el)
		{	
    
			if (el.value.length<3)
				{
				alert('Query must be at least 3 characters long');
				el.focus();
				return false;
				}
			else
				{return true;}
		}
		
