function fixSpaces(obj) {
	var str = obj.value;
	while(str.indexOf('  ') >= 0)
		str = str.replace('  ', ' ');
	while(str.charAt(0) == ' ')
		str = str.substring(1);
	while(str.charAt(str.length-1) == ' ')
		str = str.substring(0, str.length-1);
	obj.value = str;
}

function removeSpaces(obj) {
	var str = obj.value;
	while(str.indexOf(' ') >= 0)
		str = str.replace(' ', '');
	obj.value = str;
}

function hasValidChars(str, numbers, letters, other) {
	var letter_arr = new Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
	for(var i = 0; i < str.length; i++)
	{
		var c = str.charAt(i);
		c = c.toLowerCase();
		found = false;
		for(var j = 0; j < other.length && !found; j++) {
			if((""+c) == (""+other[j]))
				found = true;
		}
		if(numbers) {
			for(var j = 0; j <= 9 && !found; j++) {
				if((""+c) == (""+j))
					found = true;
			}
		}
		if(letters) {
			for(var j = 0; j <= letter_arr.length && !found; j++) {
				if((""+c) == (""+letter_arr[j]))
					found = true;
			}
		}
		if(!found)
			return false;
	}
	return true;
}

function isValidEmail(str) {
	str = str.split("@");

	if(str.length == 2 &&
	hasValidChars(str[0], true, true, new Array("~", "!", "#", "$", "%", "&", "*", "-", "_", "+", ".")) &&
	hasValidChars(str[1], true, true, new Array("~", "!", "#", "$", "%", "&", "*", "-", "_", "+", "."))
	){
		str = str[1].split(".");
		if(str.length > 1 &&
		str[0].length > 0 &&
		str[1].length > 1
		) return true;
	}
	return false;
}

function view_picture(url, obj) {
	//
	// THE FOLLOWING HTML CODE MUST
	// APPEAR SOMEWHERE ON THE PAGE
	// THAT CALLS THIS FUNCTION:
	//
	//	<DIV ID='PHOTO_VIEW_PANEL' STYLE='position:absolute'></DIV>
	//

	// GRAB PICTURE DIMENSIONS
	var tmp = new Image();
	tmp.src = obj.src;
	pic_w = tmp.width;
	pic_h = tmp.height; 

	// GRAB SCREEN DIMENSIONS
	if(typeof window.pageXOffset != 'undefined') {
		scroll_w = window.pageXOffset;
		scroll_h = window.pageYOffset;
		screen_w = window.innerWidth;
		screen_h = window.innerHeight;
	} else {
		if(document.documentElement.clientWidth*1 <= 0) {
			screen_w = document.body.clientWidth;
			screen_h = document.body.clientHeight;
		} else {
			screen_w = document.documentElement.clientWidth;
			screen_h = document.documentElement.clientHeight;
		}
		if(document.body.scrollLeft > 0) {
			scroll_w = document.body.scrollLeft;
			scroll_h = document.body.scrollTop;
		} else {
			scroll_w = document.documentElement.scrollLeft;
			scroll_h = document.documentElement.scrollTop;
		}
	}

	// MODIFY TO FIT IN BOUNDS
	bound_w = 40;
	bound_h = 60;
	max_w = screen_w - bound_w;
	max_h = screen_h - bound_h;
	if(pic_w > max_w) {
		pic_h *= max_w/pic_w;
		pic_w = max_w;
	}
	if(pic_h > max_h) {
		pic_w *= max_h/pic_h;
		pic_h = max_h;
	}
	var left = Math.round((screen_w-pic_w-bound_w)/2+scroll_w)*1;
	var top = Math.round((screen_h-pic_h-bound_h)/2+scroll_h)*1;

	// DISPLAY PICTURE
	div = document.getElementById('PHOTO_VIEW_PANEL');
	div.style.cssText = "position:absolute;left:"+left+"px;top:"+top+"px";
	div.innerHTML = "<table cellpadding='5' cellspacing='0' border='5'><tr><td align='center' nowrap><h1 style='margin:0'>Click Picture To Close</h1> <img src='/"+ url +"' onclick=\"document.getElementById('PHOTO_VIEW_PANEL').innerHTML=''\" height='"+ pic_h +"' width='"+ pic_w +"'></td></tr></table><br>";
}

function leave(url)
{
//	if(confirm("Are you sure you want to leave FishShowalter.com?")) {
		window.alert("You are leaving www.FishShowalters.com.\nTo come back, click your browser's back button.");
		document.location.replace(url);
//	}
}
