function isValidEmailAddress(emailAddress) {
2.
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
3.
return pattern.test(emailAddress);
4.
}

/*****************************************************************
Add Suggestion Text to Your Input Fields
*****************************************************************/
function inputFieldhandleFocus(element)  
{  
      
    if (element.value == element.defaultValue)   
    {  
        element.value = '';  
    }  
    
}  
  
function inputFieldhandleBlur(element)  
{  
  
    if (element.value == '')  
    {  
        element.value = element.defaultValue;  
    }  
  
}  

///sample: <input type="text" id="someInputField" value="Suggestion..." onfocus="inputFieldhandleFocus(this);" onblur="inputFieldhandleBlur(this);">

/*****************************************************************
FB Connect JS Stuff
*****************************************************************/
function populate_date(month, day, year) {
  ge('date_month').value = month;
  ge('date_day').value = day;
  ge('date_year').value = year;
}

function ge(elem) {
  return document.getElementById(elem);
}

/*
 * Simple Ajax call method.
 *
 * From http://en.wikipedia.org/wiki/XMLHttpRequest
 */
function ajax(url, vars, callbackFunction) {
  var request =  new XMLHttpRequest();
  request.open("POST", url, true);
  request.setRequestHeader("Content-Type",
                           "application/x-www-form-urlencoded");

  request.onreadystatechange = function() {
    if (request.readyState == 4 && request.status == 200) {
      if (request.responseText) {
        callbackFunction(request.responseText);
      }
    }
  };
  request.send(vars);
}
/*****************************************************************
Javascript Popup
*****************************************************************/
function popUp(p_URL, p_Width, p_Height, p_CanScroll, p_Resizable, p_Menubar) {
newWindow = window.open(p_URL, '__', 'toolbar=0,location=0,directories=0,status=0,menubar='+ p_Menubar + ',scrollbars='+ p_CanScroll + ',resizable='+ p_Resizable + ',width=' + p_Width + ',height=' + p_Height );
<!-- <A HREF="javascript:popUp('sample.html', 400, 400)">Open the Popup Window</A>-->
}
/*****************************************************************
*****************************************************************/
/*** Temporary text filler function. Remove when deploying template. ***/
var gibberish=["This is just some filler text", "Demo content nothing to read here", "Demo content nothing to read here"]
function filltext(words){
	for (var i=0; i<words; i++){
		document.write(gibberish[Math.floor(Math.random()*3)]+" ")
	}
}
/*****************************************************************
							Ajax Object
*****************************************************************/
function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		ro = new XMLHttpRequest();
	}
	return ro;
}

var http = createRequestObject();

function sndReq(action, callBack) {
	http.open('get', action);
	http.onreadystatechange = callBack;
	http.send(null);
}
		
function getstates(target) { 
	//Ajax.Request('_PHP/ajax_getStates.php?country_id='+target.value, handleGetStateResponse);
	var action='_PHP/ajax_getStates.php?country_id='+target.value;
	sndReq(action, handleGetStateResponse);
} 

function handleGetStateResponse() { 
	if(http.readyState == 4 || http.readyState == "complete"){
		var response = http.responseText;
		document.getElementById("DIVstate").style.visibility = "visible";
		document.getElementById("statefield").style.visibility = "visible";
		document.getElementById("DIVstate2").innerHTML = response;
	}
}

function highlight(checkbox) {
   if (document.getElementById) {
      var tr = eval("document.getElementById(\"TR" + checkbox.value + "\")");
   } else {
      return;
   }
   if (tr.style) {
      if (checkbox.checked) {
         tr.style.backgroundColor = "lightgreen";
      } else {
         tr.style.backgroundColor = "white";
      }
   }
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}
/*
Ajax.CheckReadyState = function(obj)
{
			//if(obj.readyState == 0) { document.getElementById('loading').innerHTML = "Sending Request..."; }
			//if(obj.readyState == 1) { document.getElementById('loading').innerHTML = "Loading..."; }
			//if(obj.readyState == 2) { document.getElementById('loading').innerHTML = "Loading..."; }
			//if(obj.readyState == 3) { document.getElementById('loading').innerHTML = "Loading..."; }
			if(obj.readyState == 4)
			{
				if(obj.status == 200)
				{
					document.getElementById('loading').innerHTML = "";
					return true;
				}
				else
				{
					document.getElementById('loading').innerHTML = "HTTP " + obj.status;
				}
			}
}
*/
