function ToggleRadio( RADIONAME , POSITION ) {
	eval( "document." + RADIONAME + "[" + POSITION + "].checked=true" );
}


function ToggleCB( CB ) {
	var MYCB = eval( "document." + CB );
	if( MYCB.checked == true ) {
		MYCB.checked = false;
	} else {
		MYCB.checked = true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function PopUp( URL , Name , X , Y , Xoff , Yoff ) {
	if( ! Xoff ) { Xoff = 25; }
	if( ! Yoff ) { Yoff = 25; }
	var newWindow = window.open( URL , Name , "screenX=" + Xoff + ",left=" + Xoff + ",screenY=" + Yoff + ",top=" + Yoff + ",width=" + X + ",height=" + Y + ",scrollbars=yes,resizable=yes" , false );
	newWindow.focus();
}

function PopUpLocator( URL , Name , X , Y , Xoff , Yoff ) {
	if( ! Xoff ) { Xoff = 25; }
	if( ! Yoff ) { Yoff = 25; }
	var newWindow = window.open( URL , Name , "screenX=" + Xoff + ",left=" + Xoff + ",screenY=" + Yoff + ",top=" + Yoff + ",width=" + X + ",height=" + Y + ",scrollbars=yes,resizable=yes,toolbar=yes" , false );
	newWindow.focus();
}

//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #
//
// Function to pop up the bigger picture in a new window.


function PopUpStorePic( myPic ) {
	var myURL = ( "/cgi-bin/p/w66p-showpic.cgi?p=" + myPic );
	var PreviewWindow = window.open( myURL , "storepic" , "width=600,height=600,top=25,left=50,screenX=50,screenY=25,resizable" , false );
	PreviewWindow.focus();
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function VFGB() {
	var Mesg = "";
	if( ! document.guestbook.name.value ) {
		Mesg += "      Please fill in the NAME field.          \n";
	}
	if( document.guestbook.address.value.length > 160 ) {
		Mesg += "      Address too long. Please limit to 160 characters.       \n";
	}
	if( Mesg ) {
		alert( "\n\n    The form cannot be submitted:          \n\n" + Mesg + "\n\n" );
		return false;
	} else {
		document.guestbook.thing.value="desmond";
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ValidPhone( Phone ) {
	var GoodSwitch = 0;
	if( Phone.match( /^[\d \-\(\)\.]+$/ ) ) {
		if( Phone.replace( /[^\d]/g , "" ).match( /^1?[23456789]\d{9}$/ ) ) {
			GoodSwitch++;
		}
	}
	return GoodSwitch;
}


function VFServicePublic() {
	var Mesg = "";
	var DF = document.service;
	var GoodEmail = 1;
	var GoodPhone = 1;
	if( ! DF.name.value ) {
		Mesg += "      Please fill in the NAME field.          \n";
	}
	if( ! DF.phone.value ) {
		GoodPhone = 0;
	}
	if( ( ! DF.email.value ) || ( ! DF.email.value.match( /^[\w\.-_]+@[^\.][\w\.]+$/ ) ) | ( ! DF.email.value.match( /\.[a-zA-Z]{2,}$/ ) ) ) {
		GoodEmail = 0;
	}
	if( GoodPhone + GoodEmail == 0 ) {
		Mesg += "      Please fill in either the PHONE or EMAIL field.          \n";
	}
	if( ! DF.service.value ) {
		Mesg += "      Please fill in the SERVICES NEEDED area.          \n";
	}
	if( Mesg ) {
		alert( "\n\n    The form cannot be submitted:          \n\n" + Mesg + "\n\n" );
		return false;
	} else {
		DF.thing.value = "desmond";
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ValidEmail( Email ) {
	Email = trim( Email );
	if( ( ! Email ) | ( ! Email.match( /^[\w\.\-_]+@[^\.][\w\.\-_]+$/ ) ) | ( ! Email.match( /\.[a-zA-Z]{2,}$/ ) ) ) {
		return false;
	} else {
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function VFForm() {
	var Mesg = "";
	if( ! document.contact.name.value ) {
		Mesg += "      + Name is empty          \n";
	}
	if( ! document.contact.comments.value ) {
		Mesg += "      + Comments field is empty          \n";
	}
	if( ! ValidEmail( document.contact.email.value ) ) {
		Mesg += "      + Email is empty or invalid          \n";
	}
	if( Mesg ) {
		alert( "\n    The form can't be submitted yet:          \n\n" + Mesg + "\n" );
		return false;
	} else {
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function trim( myStr ) {
	myStr = myStr.replace( /^\s+/ , "" );
	myStr = myStr.replace( /\s+$/ , "" );
	return myStr;
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function HL( Row , Color ) {
	document.getElementById( Row ).bgColor=Color;
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function UHL( Row , Color ) {
	document.getElementById( Row ).bgColor=Color;
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #

function ZeroPad( thisString , Length ) {
	if( Length > thisString.length ) {
		var RetStr = thisString;
		for( var i = thisString.length ; i < Length ; i++ ) {
			RetStr = "0" + RetStr;
		}
		return RetStr;
	} else {
		return thisString;
	}
}


