//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" && document.domain != "site374.mysite4now.com"){
	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";
	}
}

//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(val, fldname) {
	if (field.value != "") {
		for (var i = 0; i < field.value.length; i++) {
			if (field.value.charAt(i) < "0" || field.value.charAt(i) > "9") {
				strError = strError + "The field -" + fldname + "- does not contain a valid integer value. \n";						
				return false;
			}		
		}
	}
}

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();
}