// JavaScript Document


function genemail(user,domain,suffix) {

	document.write('<a href="'+'mailto:'+user+'@'+domain+'.'+suffix+'">'+user+'@'+domain+'.'+suffix+'</a>');

}

function validate(){
	var errors = '';
	if ($F('name') == '' || $F('name') == "Enter name"){ 
		errors += "Please provide a name!\n";	
	}
	
	if ($F('email') == '' || $F('email') == "Email address" || $F('email').indexOf('@') == -1){ 
		errors += "Please provide a valid email address!\n";	
	}
	
	if ($F('zzip') != ''){
		errors += "You're a spammer!\n";	
	}
	
	if (errors.length){
		alert("Please fix the following errors:\n"+errors);
		return false;
			
	}else{
		return true;	
	}
	
	
}			

function lwValidate(){
	var errors = '';
	if ($F('firstname') == ''){ 
		errors += "Please provide a first name!\n";	
	}

	if ($F('lastname') == ''){ 
		errors += "Please provide a last name!\n";	
	}


	if ($F('email') == '' || $F('email').indexOf('@') == -1){ 
		errors += "Please provide a valid email address!\n";	
	}

	if ($F('county_org') == ''){ 
		errors += "Please provide an organization!\n";	
	}

	if ($F('phone') == ''){ 
		errors += "Please provide a phone!\n";	
	}

	
	if (errors.length){
		alert("Please fix the following errors:\n"+errors);
		return false;
			
	}else{
		return true;	
	}
	
	
}


function searchValidate(){
	var errors = '';
	if ($F('term') == '' || $F('term') == "Search" || $F('term').length > 63){
		errors += "Please enter a valid search term!";
		
	}
	if (errors.length){
		alert("Please fix the following errors:\n"+errors);
		return false;
			
	}else{
		return true;	
	}
	
	
	
	
}


function fancyPopup(oSourceImage,strPopupImageID) {
  var intShiftX = -75;
  var intShiftY = -75;
  if (arguments.length > 2) {
    if (typeof(arguments[2]) == "number") {
      // presume this is the x shift
      intShiftX = arguments[2];
    }
  }
  if (arguments.length > 3) {
    if (typeof(arguments[3]) == "number") {
      // presume this is the y shift
      intShiftY = arguments[3];
    }
  }
  
  setXY($(strPopupImageID),getAbsoluteX(oSourceImage)+intShiftX,getAbsoluteY(oSourceImage)+intShiftY);
  new Effect.Grow($(strPopupImageID));
}

function getAbsoluteX(oObjectToGetPosition) {
  // get the absolute X-coordinate of an object on the page
  var intCoords = {x: 0};
  while (oObjectToGetPosition) {
    intCoords.x += oObjectToGetPosition.offsetLeft;
    oObjectToGetPosition = oObjectToGetPosition.offsetParent;
  }
  return intCoords.x;
}

function getAbsoluteY(oObjectToGetPosition) {
  // get the absolute Y-coordinate of an object on the page
  var intCoords = {y: 0};
  while (oObjectToGetPosition) {
    intCoords.y += oObjectToGetPosition.offsetTop;
    oObjectToGetPosition = oObjectToGetPosition.offsetParent;
  }
  return intCoords.y;
}

function setXY(oObjectToSet,intX,intY) {
  if (typeof(oObjectToSet) != "undefined") {
    oObjectToSet.style.left = intX + "px";
    oObjectToSet.style.top = intY + "px";
  }
}
