<!--hide this script from non-javascript-enabled browsers

function textareaLimit(field, maxlimit) {
	if ( field.value.length > maxlimit )
		field.value = field.value.substring( 0, maxlimit );
}

function showElement(name) {
	var obj = document.getElementById(name);
	if (obj) {
		if (!obj.style.display || obj.style.display == 'none') {
			obj.style.display = 'block';
		}
		else {
			obj.style.display = 'none';
		}
	}

	return false;
}

function DisplayDateSelect( name, def, start, count, increment, selected )
{
	var postfix;

	if ( document.URL.indexOf( 'listitem' ) > 0 || document.URL.indexOf( 'achieveitem' ) > 0 ||
		 document.URL.indexOf( 'chaldates' ) > 0 )
	{
		var index = 0;
		if ( name == 'bdaySelect' )
			index = 1;
		document.write( '<select name="' + name + '" OnChange=\"return OnCompleteDateChange( ' + index + ' );\">\n' );
	}
	else
	{
		document.write( '<select name="' + name + '">\n' );
	}

	if ( def != null && def.length > 0 )
		document.write( '<option>' + def + '</option>\n' );

	var val = start;
	var c = ' ';
	var found = false;
	for ( i = 0 ; i < count ; i ++ )
	{
		found = false;
		var tmp = "";
		tmp += val;
		postfix = "th";

		if ( tmp.length > 1 )
		{
			c = tmp.substr( tmp.length - 2 );

			if ( c > 10 && c < 21 )
				found = true;
		}

		if ( !found )
		{
			c = tmp.charAt( tmp.length - 1 );
			switch( c )
			{
				case '1':	postfix = 'st';		break;
				case '2':	postfix = 'nd';		break;
				case '3':	postfix = 'rd';		break;
			}
		}

		document.write( '<option value="' + val + '"' );
		if ( selected == val )
			document.write( ' selected' );
		document.write( '>' + val + postfix + '</option>\n' );
		val += increment;
	}

	document.write( '</select>\n' );
}

function DisplayMonthSelect( name, def, selected )
{
	var months = new Array( 'January', 'February', 'March', 'April', 'May', 'June',
							'July', 'August', 'September', 'October', 'November', 'December' );

	if ( document.URL.indexOf( 'listitem' ) > 0 || 
		 document.URL.indexOf( 'chaldates' ) > 0 )
	{
		document.write( '<select name="' + name + '" OnChange=\"return OnCompleteDateChange( 0 );\">\n' );
	}
	else
	{
		document.write( '<select name="' + name + '">\n' );
	}

	if ( def != null && def.length > 0 )
		document.write( '<option>Month</option>\n' );

	for ( i = 1 ; i <= 12 ; i ++ )
	{
		document.write( '<option value="' + i + '"' );
		if ( selected == i )
			document.write( ' selected' );
		document.write( '>' + months[ i - 1 ] + '</option>\n' );
	}

	document.write( '</select>\n' );
}

function DisplayYearSelect( name, def, start, count, increment, selected )
{
	if ( document.URL.indexOf( 'listitem.php' ) > 0 )
	{
		document.write( '<select name="' + name + '" OnChange=\"return OnCompleteDateChange( 0 );\">\n' );
	}
	else
	{
		document.write( '<select name="' + name + '">\n' );
	}

	if ( def != null && def.length > 0 )
		document.write( '<option>Year</option>\n' );

	var val = start;

	for ( i = 0 ; i <= count ; i ++ )
	{
		document.write( '<option value="' + val + '"' );
		if ( selected == val )
			document.write( ' selected' );
		document.write( '>' + val + '</option>\n' );

		val += increment;
	}

	document.write( '</select>\n' );
}

function Show50Page( num )
{
	document.form1.action='50list.php?page=' + num;
	document.form1.submit();
	return false;
}

function ShowList( id )
{
	document.form1.action='yourlistro.php';
	document.form1.id.value=id;
	document.form1.submit();
	return false;
}

function OnCompleteDateChange( index )
{
	var radioComplete = document.form1.completion.value;

	if ( radioComplete == 'date' )
		currentDateRadioIndex = 0;
	else if ( radioComplete == 'bday' )
		currentDateRadioIndex = 1;
	else
		currentDateRadioIndex = 2;

	if ( currentDateRadioIndex != index )
	{
		var radioComplete = document.form1.completion;

		radioComplete[index].checked=true;
	}
}

function OnRegisterChange()
{
	var countryId = -1;
	countryId = document.form1.country.value;

	if ( countryId == '-' )
		return true;

	// UK and US

	if ( ( countryId == 223 || countryId == 224 ) ||
			 document.form1.area != null )
	{
		document.form1.validateData.value = -1;
		document.form1.submit();
		return false;
	}

	return true;
}

var completeChkSelected=false;

function OnCompleteCheckUpdate( check )
{
	completeChkSelected = !completeChkSelected;

	var textArea = document.form1.completetext;

	textArea.disabled = !completeChkSelected;

	return true;
}

function OpenCustomerSite( link )
{
	window.open( link );
}

function OnRelationshipChange( id, combo ) {
//	document.location = 'aboutyou.php?action=change_relation&list=' + id + '&rel=' + combo.value + '#familyandfriends';
	PostOrGet('friendsandfamily.php', 'action=change_relation&list=' + id + '&rel=' + combo.value);
}

// use this method if you want to save the current state of the form
// using a POST, when using an '<a>' link
// this will check the compatibility, and post if possible
function PostOrGet( pageUrl, params )
{
	var action = pageUrl;

	if ( params.length > 0 )
	{
		if ( params.charAt( 0 ) != '?' )
			action += '?';
		action += params;
	}

	// check browser compatibility

	if ( 1 == 1 )
	{
		document.form1.action = action;
		document.form1.submit();
		return false;
	}
	else
	{
		document.location = action;
		return true;
	}
}

function PostRedirect( page )
{
	var action = document.form1.action;

	if ( 1 == 1 )
	{
		action += '?';
		action += 'action=redirect&page=' + page

		document.form1.action = action;
		document.form1.submit();
		return false;
	}
	else
	{
		return true;
	}
}

function goAddPlace() {
  document.form1.action = 'addplace.php';
  document.form1.submit();
	return false;
}

function checkAll(chkObj) {
	var bChkState = true;
	if (chkObj == null || chkObj.checked == false) {
		bChkState = false;
  }

	var elems = document.form1.elements;
	for (var i = 0 ; i < elems.length ; ++ i) {
		fldObj = elems[i];
		if (fldObj.type == 'checkbox') {
			fldObj.checked = bChkState;
		}
	}
}

function addSuggestion(id, achievement) {
	var f1 = document.form1;
	
	// check for double clicks
	if (f1.newgoal.value == '-1') {
		document.form1.newgoal.value=id;
		document.form1.achievement.value= (achievement) ? 'true' : 'false';
		document.form1.submit();
	}
	
	return false;
}
// stop hiding -->