

function show_div(divName) {
	document.getElementById(divName).style.display = "block";
}
function hide_div(divName) {
	document.getElementById(divName).style.display = "none";
}







function getLocationOne(winWidth, winHeight, winLeft, winTop){
  var winLocation = ""
  if (winLeft < 0)
    winLeft = screen.width - winWidth + winLeft
  if (winTop < 0)
    winTop = screen.height - winHeight + winTop
  if (winTop == "cen")
    winTop = (screen.height - winHeight)/2 - 20
  if (winLeft == "cen")
    winLeft = (screen.width - winWidth)/2
  if (winLeft>0 & winTop>0)
    winLocation =  ",screenX=" + winLeft + ",left=" + winLeft	
                + ",screenY=" + winTop + ",top=" + winTop
  else
    winLocation = ""
  return winLocation
}









// data validations
function checkFields() {
	var pwrd = document.add_form.Passcode.value ;
	var pwrd2 = document.add_form.Passcode2.value ;

// now make sure if textarea, not above 200
for (i=0; i < add_form.length; i++)
{
	var formelement = add_form.elements[i];
	if (formelement.type == 'textarea')
	{
		var name = formelement.name ;
		var full = eval('document.add_form.' + name + '.value.length');
		
		if (full > 250)
		{
		alert("Please keep answers in large text boxes to 250 character maximum!");
		return false;
		}
	}
}


if (document.add_form.Country.value == 'US')
	{
			return(
			  validatepwrd(pwrd,pwrd2) && 
			  checkEmail(add_form.elements["Email"]) &&
			  checkZIPCode(add_form.elements["Zip"],true) &&
			  checkUSPhone(add_form.elements["Phone"],true)     
			 ) 
     }	
else {		   
		
		return(
		  validatepwrd(pwrd,pwrd2) && 
		  checkEmail(add_form.elements["Email"]) &&
		  checkInternationalPhone(add_form.elements["Phone"],true)
	 			)
	 }
// end function
}

function checkstate()
{
	if ((document.add_form.Country.value != 'US') && 
	(document.add_form.Country.value != 'CA') && 
	(document.add_form.Country.value != 'UM'))
	{
	document.add_form.State.value = "XX";
	}
}











function  _CF_checksearch(_CF_this)
{
	//reset on submit
	_CF_error_exists = false;
	_CF_error_messages = new Array();
	_CF_error_fields = new Object();
	_CF_FirstErrorField = null;

	//form element searchbox required check
	if( !_CF_hasValue(_CF_this['searchbox'], "TEXT", false ) )
	{
		_CF_onError(_CF_this, "searchbox", _CF_this['searchbox'].value, "You must enter search criteria in the text box to search on!");
		_CF_error_exists = true;
	}


	//display error messages and return success
	if( _CF_error_exists )
	{
		if( _CF_error_messages.length > 0 )
		{
			// show alert() message
			_CF_onErrorAlert(_CF_error_messages);
			// set focus to first form error, if the field supports js focus().
			if( _CF_this[_CF_FirstErrorField].type == "text" )
			{ _CF_this[_CF_FirstErrorField].focus(); }

		}
		return false;
	}else {
		return true;
	}
}







function  _CF_checkadd_form(_CF_this)
{
	//reset on submit
	_CF_error_exists = false;
	_CF_error_messages = new Array();
	_CF_error_fields = new Object();
	_CF_FirstErrorField = null;

	//form element First_Name required check
	if( !_CF_hasValue(_CF_this['First_Name'], "TEXT", false ) )
	{
		_CF_onError(_CF_this, "First_Name", _CF_this['First_Name'].value, "Please enter a first name.");
		_CF_error_exists = true;
	}

	//form element Last_Name required check
	if( !_CF_hasValue(_CF_this['Last_Name'], "TEXT", false ) )
	{
		_CF_onError(_CF_this, "Last_Name", _CF_this['Last_Name'].value, "Please enter a last name.");
		_CF_error_exists = true;
	}

	//form element Email required check
	if( !_CF_hasValue(_CF_this['Email'], "TEXT", false ) )
	{
		_CF_onError(_CF_this, "Email", _CF_this['Email'].value, "Please enter an email address.");
		_CF_error_exists = true;
	}

	//form element Passcode required check
	if( !_CF_hasValue(_CF_this['Passcode'], "PASSWORD", false ) )
	{
		_CF_onError(_CF_this, "Passcode", _CF_this['Passcode'].value, "You must enter and verify a password.");
		_CF_error_exists = true;
	}

	//form element Passcode2 required check
	if( !_CF_hasValue(_CF_this['Passcode2'], "PASSWORD", false ) )
	{
		_CF_onError(_CF_this, "Passcode2", _CF_this['Passcode2'].value, "You must verify your password.");
		_CF_error_exists = true;
	}

	//form element Hint required check
	if( !_CF_hasValue(_CF_this['Hint'], "TEXT", false ) )
	{
		_CF_onError(_CF_this, "Hint", _CF_this['Hint'].value, "You must enter a password hint.");
		_CF_error_exists = true;
	}


	//display error messages and return success
	if( _CF_error_exists )
	{
		if( _CF_error_messages.length > 0 )
		{
			// show alert() message
			_CF_onErrorAlert(_CF_error_messages);
			// set focus to first form error, if the field supports js focus().
			if( _CF_this[_CF_FirstErrorField].type == "text" )
			{ _CF_this[_CF_FirstErrorField].focus(); }

		}
		return false;
	}else {
		// run userdefined onSubmit javascript. 
		return checkFields()
		return true;
	}
}



