//IF SITE IS LOADED IN CONTEXT OF ANOTHER SITE, RELOAD WINDOW WITH SITE (ABSOLUTE POSITIONING ISSUE WITH CACHED LINK ON GOOGLE)
//if (document.domain != "www.ezrealtyconnect.com" && document.domain != "www.heartandfire.org"){
//	window.location = "http://www.ezrealtyconnect.com"
//}

// Trims all leading and trailing space characters
function trim(s) {
  while ((s.substring(0,1) == ' '))  {
    s = s.substring(1,s.length);
  }
  while ((s.substring(s.length-1,s.length) == ' '))  {
    s = s.substring(0,s.length-1);
  }
  return s;
}


function isFilled(field) {	
	if (trim(field.value) == "") {
		strError = "true";
		field.style.background="#FBB3B1";
	}  else {
		field.style.background="#FFFFFF";
	}
}

function matching(field1, field2) {	
	if (field1.value != field2.value) {
		strError = "true";
		field1.style.background="#FBB3B1";
		field2.style.background="#FBB3B1";
	}  else {
		isFilled(field1);
		isFilled(field2);
	}
}

//Validation for multiple fields to ensure at least on is filled
function isFilledMultiple(array) {
	blnFilled = false;
	for(i=0; i<array.length; i++) {
		if (array[i].value != "") {
			blnFilled = true;
		}
	}
	
	if (blnFilled == false) {
		strError = "true";
		for(i=0; i<array.length; i++) {
			array[i].style.background="#FBB3B1";
		}
	} else {
		for(i=0; i<array.length; i++) {
			array[i].style.background="#FFFFFF";
		}
	}
}

// Validation for radio button array or built checkbox array
function isChecked(field) {	
	blnChecked = false;
	for(i=0; i<field.length; i++){
		if(field[i].checked == true){
			blnChecked = true;
		} 
	}	
	
	if (blnChecked == false) {
		strError = "true";
		for(i=0; i<field.length; i++){
			field[i].style.background="#FBB3B1";
		}
	} else {
		for(i=0; i<field.length; i++){
			field[i].style.background="#FFFFFF";
		}
	}
}

function isInteger(field) {
	field.style.background="#FFFFFF";
	if (field.value != "") {
		for (var i = 0; i < field.value.length; i++) {
			if (field.value.charAt(i) < "0" || field.value.charAt(i) > "9") {
				strError = "true";
				field.style.background="#FBB3B1";	
			}	
		}
	}
}

function popUp(url,width,height) {
  		self.name = "opener";
  		remote = window.open(url, "remote", "status,scrollbars,width="+width+",height="+height+",left=20,top=20");
		remote.focus();
}

function launch(url, width, height)	{
  		self.name = "opener";
  		remote = open(url, "remote", "width="+(width+50)+",height="+(height+90)+",status,scrollbars,left=10,top=10");
		remote.resizeTo(width+50,height+90);
		remote.focus();
}