<!--
function popUp(url){
	window.open(url,'',   'toolbar=no,scrollbars=yes,width=550,height=450');
}

function popUp650(url){
	window.open(url,'',   'toolbar=no,scrollbars=yes,width=680,height=700');
}
function popLarge(pop_url) {
	var url = pop_url;
	regwindow = window.open (url , 'large', 'width=550,height=470,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no')
}
function popMedium(pop_url) {
	var url = pop_url;
	regwindow = window.open (url , 'medium', 'width=550,height=470,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no')
}
function popSmall(pop_url) {
	var url = pop_url;
	regwindow = window.open (url , 'small', 'width=550,height=470,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no')
}

// Remove all spaces from a string
function removeSpaces(string) {
	var newString = '';
	for (var i = 0; i < string.length; i++) {
		if (string.charAt(i) != ' ') newString += string.charAt(i);
	}
	return newString;
}
//only numbers
function isNumeric(string, ignoreWhiteSpace) {
	if (string.search) {
		if ((ignoreWhiteSpace && string.search(/[^\d\s]/) != -1) || (!ignoreWhiteSpace && string.search(/\D/) != -1)) return false;
	}
	return true;
}
//only letters
function isAlphabetic(string, ignoreWhiteSpace) {
	if (string.search) {
		if ((ignoreWhiteSpace && string.search(/[^a-zA-Z\s]/) != -1) || (!ignoreWhiteSpace && string.search(/[^a-zA-Z]/) != -1)) return false;
	}
	return true;
}
//check for blank field
function isBlank(str) {
	if( str == "" )  return true ;
	return false ;
}
//check the state
function isState(state){
	state = removeSpaces(state);
	if( state.length != 2) return false;
	else if(state.length == 2 && !isAlphabetic(state)) return false;
	return true;
}
//check for a valid zip code
function isZipcode(zip){	
    zip = removeSpaces(zip);
   	if (!(zip.length == 5 || zip.length == 9 || zip.length == 10)) return false;
  	if ((zip.length == 5 || zip.length == 9) && !isNumeric(zip))  return false;
   	 //&& zip.search
  	if (zip.length == 10  && zip.search(/^\d{5}-\d{4}$/) == -1) return false;
	return true;
}
// Check that an email address is valid based on RFC 821 (?)
function isValidEmail(address) {
	if (address != '' && address.search) {
      if (address.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) return true;
      else return false;
	}
}
//set focus and clear the field
function clearAndFocus(field){
	field.value = "";
	field.focus();
}
//check empty field and output the message
function empty(fieldValue, fieldName, msg){
	if(isBlank(fieldValue)){
    	alert( "Please enter the " + msg + " field." );
		clearAndFocus(fieldName);
   		return false ; 	
 	}else return true;
}
//check for state value
function stateField(fieldValue, fieldName, msg){
	if(!isState(fieldValue)){
			alert( "Please enter " + msg);
			clearAndFocus(fieldName);
			return false;
	}else return true;
}
//check for zip value
function zipField(fieldValue, fieldName, msg){
	if(!isZipcode(fieldValue))
		{
			alert("Please enter " + msg);
			clearAndFocus(fieldName);
			return false;
		}else return true;
}
//check for email value
function emailField(fieldValue, fieldName, msg){
	if(!isValidEmail(fieldValue)){
    		alert( "Please enter " + msg);
			clearAndFocus(fieldName);
			return false ; 
		}else return true;
}
//check for an interger value value
function ageField(fieldValue, fieldName, msg){
	if(!isNumeric(fieldValue)){
    		alert( "Please enter " + msg);
			clearAndFocus(fieldName);
			return false ; 
		}else return true;
}
//get the value of the 
function getRadioValue(strFieldName){
	//call this function: getRadioValue(form.fieldName);
	var strValue = "";
	var intControlLength = strFieldName.length;
    for (i=0;i<intControlLength;i++){
         if(strFieldName[i].checked){
                   strValue = strFieldName[i].value;
				   //return true;
                   return strValue;
         }
    }  
	return false;
}
//check for valid number
function checknumber(fieldValue, fieldName, msg){
	var x=fieldName.value;
	var anum=/(^\d+$)|(^\d+\.\d+$)/
	if (anum.test(x)) return true;
	else{
		alert( "Please enter " + msg);
		clearAndFocus(fieldName);
		return false;
	}
}
function trim(str) {
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
//get the drop down value
function getDropDown(field){
	var i = field.selectedIndex;
         if (i == -1)   return "";
         else   return (field.options[i].value == "") ? field.options[i].text : field.options[i].value;

}

//validate request app form
function checkformHowtoAdopt ( form )
{
	//alert("Test");
	var name = trim(form.from_name.value), spouse_name = trim(form.spouse_name.value);
	var address=trim(form.address.value), city=trim(form.city.value);
	var state=form.state.value, country=trim(form.country.value), zip=form.zip.value;
	var email = form.from_email.value, phone=trim(form.phone.value);
	var heard_from = trim(form.heard_from.value);
	
	if(!form.Bulgaria.checked && !form.China.checked && !form.Ethiopia.checked && !form.Nepal.checked && !form.Haiti.checked && !form.India.checked && !form.Korea.checked
	 && !form.Philippines.checked && !form.Thailand.checked && !form.Ukraine.checked && !form.Vietnam.checked && !form.Not_sure.checked ){
		alert( "Please choose the countries you are interested in adopting from." );
		form.Bulgaria.focus();
		return false ; 	
	}
	
	if(!empty(name, form.from_name, "Name")) 	return false;	
	if(!empty(spouse_name, form.spouse_name, "Name")) 	return false;	
	if(!empty(address, form.address, "Address")) 	return false;
	if(!empty(city, form.city, "City")) 	return false;
	if(!empty(state, form.state, "State")) 	return false;
	else{ if(!stateField(state, form.state, "2 letters for State."))   return false;}
	if(!empty(country, form.country, "Country")) 	return false;
	if(!empty(zip, form.zip, "Zip")) 	return false;
	else{ if(!zipField(zip, form.zip, "a valid zipcode."))   return false;}
	if(!emailField(email, form.from_email, "a valid email address."))  return false;	
	if(!empty(phone, form.phone, "Phone")) 	return false;
	if(!empty(heard_from, form.heard_from, "How did you learn about Holt")) 	return false;

	return true ;
}

//-->