

function psOnSubmit()
	{
	return formOnSubmit("ps");
	}

function wsfyOnSubmit()
	{
	return formOnSubmit("wsfy");
	}

function formOnSubmit(type)
	{
	var f = $("#"+type+"Form");
	f[0].submitted_once = true;
	var ok = true;
	
	var fn = $("[name='"+(type=="ps"?"searchFirstName":"firstName")+"']",f);
	var ln = $("[name='"+(type=="ps"?"searchLastName":"lastName")+"']",f);
	var a = $("[name='"+(type=="ps"?"searchAge":"age")+"']",f);

	if (fn.val() != fn[0].defaultValue) fn.val(fixName(fn.val()));
	if (ln.val() != ln[0].defaultValue) ln.val(fixName(ln.val()));
	if (a.val() != a[0].defaultValue) a.val(fixAge(a.val()));
	
	var des = type == "ps" ? "their" : "your";
	if (!inputHasValue(fn)) ok = alertField(fn,{id:"first_name",message:"Please enter "+des+" <strong>first name</strong>."});
	else alertField(fn,{id:"first_name"},true);
	if (!inputHasValue(ln)) ok = alertField(ln,{id:"last_name",message:"Please enter "+des+" <strong>last name</strong>."});
	else alertField(ln,{id:"last_name"},true);
	if (!inputHasValue(a)) ok = alertField(a,{id:"age",message:"Please enter "+des+" <strong>age</strong>."});
	else alertField(a,{id:"age"},true);
	
	return ok;
	}

function regOnSubmit(check_only)
	{
	var f = $("#regForm");
	f[0].submitted_once = true;
	var ok = true;
	
	var fn = $("[name='firstName']",f);
	var ln = $("[name='lastName']",f);
	var p = $("[name='password']",f);
	var cp = $("[name='confirmPassword']",f);
	var e = $("[name='email']",f);
	var g = $("[name='gender']",f);
	var bm = $("[name='birthMonth']",f);
	var bd = $("[name='birthDay']",f);
	var by = $("[name='birthYear']",f);
	var z = $("[name='zip']",f);

	if (fn.val() != fn[0].defaultValue) fn.val(fixName(fn.val()));
	if (ln.val() != ln[0].defaultValue) ln.val(fixName(ln.val()));
	if (e.val() != e[0].defaultValue) e.val(fixEmail(e.val()));
	if (z.val() != z[0].defaultValue) z.val(fixZip(z.val()));
	
	if (!inputHasValue(fn)) ok = alertField(fn,{id:"first_name",message:"Please enter your <strong>first name</strong>."});
	else alertField(fn,{id:"first_name"},true);
	if (!inputHasValue(ln)) ok = alertField(ln,{id:"last_name",message:"Please enter your <strong>last name</strong>."});
	else alertField(ln,{id:"last_name"},true);
	
	if (p.length && p.is(":visible"))
		{
		if (!inputHasValue(p)) ok = alertField(p,{id:"pass",message:"Please enter a password."});
		else if (p.val().length < 4 || p.val().length > 20) ok = alertField(p,{id:"pass",message:"Password must be between 4 and 20 characters in length."});
		else if (!isValidPassword(p.val())) ok = alertField(p,{id:"pass",message:"Password may contain only numbers, letters and underscores."});
		else alertField(p,{id:"pass"},true);
		if (cp.length)
			{
			if (cp.is(":visible"))
				{
				if (cp.val() != p.val()) ok = alertField(cp,{id:"confirm_pass",message:"Passwords do not match."});
				else alertField(cp,{id:"confirm_pass"},true);			
				}
			else cp.val(p.val());
			}
		}
	
	if (!inputHasValue(e)) ok = alertField(e,{id:"email",message:"Please enter your <strong>email</strong> address."});
	else if (!strContains(e.val(),["@","."])) ok = alertField(e,{id:"email",message:"Please enter a valid <strong>email</strong> address."});
	else alertField(e,{id:"email"},true);
	
	if (g.attr("type") == "radio")
		{
		if (!g[0].checked && !g[1].checked) ok = alertField(g,{id:"gender",message:"Please select <strong>male</strong> or <strong>female</strong>."});
		else alertField(g,{id:"gender"},true);
		}
	else
		{
		if (!g.val()) ok = alertField(g,{id:"gender",message:"Please select <strong>male</strong> or <strong>female</strong>."});
		else alertField(g,{id:"gender"},true);
		}
	
	if (!by.val()) ok = alertField(by,{id:"birthdate",message:"Please select the <strong>year</strong> in which you were born."});
	else alertField(by,{},true);
	if (!bm.val()) ok = alertField(bm,{id:"birthdate",message:"Please select the <strong>month</strong> in which you were born."});
	else alertField(bm,{},true);
	if (!bd.val()) ok = alertField(bd,{id:"birthdate",message:"Please select the <strong>day</strong> on which you were born."});
	else alertField(bd,{},true);
	if (bm.val() && bd.val() && by.val()) alertField(by,{id:"birthdate"},true);
	
	if (!inputHasValue(z)) ok = alertField(z,{id:"zip",message:"Please enter your <strong>zip code</strong>."});
	else if (!strHasLengthOf(z.val(),[5,6,9,10])) ok = alertField(z,{id:"zip",message:"Please enter a <strong>valid US/Canadian zip code (no dashes)</strong>."});
	else alertField(z,{id:"zip"},true);

	if (ok && !check_only)
		{
		if (p.length && !p.is(":visible")) p.remove();
		if (cp.length && !cp.is(":visible")) cp.remove();
		if (typeof(visit_history) == "object") visit_history.current_visit.registered = true;
		loadProcessingOverlay({loading_copy:"Processing...",bg_color:"#000000",bg_alpha:"85"});
		}

	return ok;
	}

function alertField(jobj,err,pass)
	{
	var err_elm = jobj.parents("form:first").find(".error."+err.id);
	if (pass)
		{
		jobj.removeClass("highlight");
		jobj.addClass("successful");
		if (err.id) err_elm.html("");
		if (err_elm.hasClass("dblock")) err_elm.fadeOut(300);
		return true;
		}
	else
		{
		jobj.removeClass("successful");
		jobj.addClass("highlight");
		err_elm.html(err.message);
		if (err_elm.hasClass("dblock")) err_elm.fadeIn(300);
		return false;
		}
	}

var reg_exp_bad_age_chars = new RegExp("[^0-9]","g");
var reg_exp_bad_name_chars = new RegExp("[^a-zA-Z\-\' ]","g");
var reg_exp_bad_email_chars = new RegExp("[^a-zA-Z0-9_@\+\-\.]","g");
var reg_exp_bad_zip_chars = new RegExp("[^a-zA-Z0-9]","g");
var reg_exp_bad_password_chars = new RegExp("[^a-zA-Z0-9_]","g");
var reg_exp_perimeter_spaces = new RegExp("^( )+|( )+$","g");
var reg_exp_consecutive_spaces = new RegExp(" +","g");

function fixAge(age)
	{
	var max = 120;
	age = age ? age+"" : "";
	age = age.substring(0,3);
	age = age.replace(reg_exp_bad_age_chars,"");
	if (age && age > max) age = age.substring(0,2);
	return age;
	}

function fixName(name)
	{
	name = name ? name+"" : "";
	name = name.replace(reg_exp_perimeter_spaces,"");
	name = name.replace(reg_exp_consecutive_spaces," ");
	name = name.replace(reg_exp_bad_name_chars,"");
	var lcase = name.toLowerCase();
	if (lcase == "firstname" || lcase == "lastname" || lcase == "theirfirstname" || lcase == "theirlastname") name = "";
	return name;
	}

function fixEmail(email)
	{
	email = email ? email+"" : "";
	return email.replace(reg_exp_bad_email_chars,"");
	}

function fixZip(zip)
	{
	zip = zip ? zip+"" : "";
	return zip.replace(reg_exp_bad_zip_chars,"");
	}

function isValidPassword(str)
	{
	if (typeof(str) != "string") return false;
	if (str.length < 4 || str.length > 20) return false;
	if (str.replace(reg_exp_bad_password_chars,"") != str) return false;
	return true;
	}

function inputHasValue(jobj)
	{
	if (!jobj.val() || (jobj.attr("type") != "hidden" && jobj.val() == jobj[0].defaultValue)) return false;
	return true;
	}

function strHasLengthOf(str,l_arr)
	{
	for (var i=0;i<l_arr.length;i++)
		{
		if (str.length == l_arr[i]) return true;
		}
	return false;
	}

function strContains(val,str_arr)
	{
	val = typeof(val) == "object" ? val.value : (val || "");
	for (var i=0;i<str_arr.length;i++)
		{
		if (val.indexOf(str_arr[i]) == -1) return false;
		}
	return true;
	}

function capitalize(str)
	{
	var words = str.split(" ");
	for (var i=0;i<words.length;i++)
		{
		words[i] = words[i].charAt(0).toUpperCase()+words[i].substr(1).toLowerCase();
		if (words[i].substr(0,2) == "Mc") words[i] = words[i].substr(0,2) + words[i].substr(2,1).toUpperCase() + words[i].substr(3);
		else if (words[i] == "Hs") words[i] = words[i].toUpperCase();
		}
	return words.join(" ");
	}

function cacheImage(url)
	{
	if (typeof("img_cache") != "object") img_cache = new Array();
	img_cache.push(new Image());
	img_cache[img_cache.length-1].src = url;
	}

cacheImage("http://a1.mylife.com/a/landa/i/processing_overlay_logo.gif");
cacheImage("http://a1.mylife.com/a/landa/i/processing_overlay_loader.gif");
function loadProcessingOverlay(params)
	{
	if (typeof(params) != "object") var params = {};
	var bg_color = params["bg_color"] || "#000000";
	var bg_alpha = Math.round((params["bg_alpha"] || 85)*1);
	var loading_copy = params["loading_copy"] || "Processing...";
	var window_height = getWidthHeightOfWindow().height;
	var d = getWidthHeightOfDocument();
	var c = getCenterOfScreen();
	$("body").append('<div id="processing_overlay-cont"><div id="processing_overlay-bg"></div><div id="processing_overlay"></div></div>');
	$("#processing_overlay-cont").css({"position":"absolute","left":"-10000px","top":"0px","z-index":"9999"});
	$("#processing_overlay-bg").css({"position":"absolute","left":"0px","top":"0px","background":bg_color});
	$("#processing_overlay-bg").css({"opacity":bg_alpha/100,"filter":"alpha(opacity="+bg_alpha+")"});
	$("#processing_overlay-bg").css({"width":d.width+"px","height":(d.height < window_height ? window_height : d.height)+"px"});
	$("#processing_overlay").html('<img src="http://a1.mylife.com/a/landa/i/processing_overlay_logo.gif" alt="MyLife.com" width="96" height="58" /><br /><img src="http://a1.mylife.com/a/landa/i/processing_overlay_loader.gif" alt="loading..." width="128" height="15" /><br />'+loading_copy);
	$("#processing_overlay").css({"position":"absolute"});
	var i_xy = {
		x:c.x-$("#processing_overlay").width()/2,
		y:c.y-$("#processing_overlay").height()/2
		};
	if (i_xy.y < 0) i_xy.y = 0;
	$("#processing_overlay").css({"left":i_xy.x+"px","top":i_xy.y+"px"});
	$("#processing_overlay-cont").css({"display":"none","left":"0px"});
	$("#processing_overlay-cont").fadeIn(500);
	}

function genderOnChange(inp,dont_animate)
	{
	var m = $("#maiden");
	var i = $(inp);
	if (i.val() == "2")
		{
		if (dont_animate) m.css("display","block");
		else m.fadeIn(300);
		}
	else
		{
		if (dont_animate) m.css("display","none");
		else m.fadeOut(300);
		}
	}

function maximizeWindow(relocate,set_width,set_height)
	{
	set_width = set_width || 9999;
	set_height = set_height || 9999;
	if (screen.availWidth || screen.width)
		{
		var max_width = screen.availWidth || screen.width;
		var max_height = screen.availHeight || screen.height;
		var new_width = (!set_width || max_width < set_width) ? max_width : set_width;
		var new_height = (!set_height || max_height < set_height) ? max_height : set_height;
		if (window.resizeTo) window.resizeTo(new_width,new_height);
		else if (window.outerWidth)
			{
			window.outerWidth = new_width;
			window.outerHeight = new_height;
			}
		}
	if (relocate)
		{
		if (window.moveTo) window.moveTo(0,0);
		else if (window.screenX)
			{
			window.screenX = 0;
			window.screenY = 0;
			}
		}
	}

function fireRegOpenedPixel()
	{
	if (typeof(global_regopenedpx) == "undefined" && !$_GET["debug"])
		{
		var px = new Image();
		px.src = "http://r.casalemedia.com/j.gif?u=123830&s=2";
		global_regopenedpx = true;
		}
	}

function stop_tab(e)
	{
	e = e || window.event;
	var key_code = e.which || e.keyCode;
	if (key_code == 9) return false;
	}

function getWidthHeightOf(element)
	{
	var e = $(element);
	return {width:e.width(),height:e.height()};
	}

function getWidthHeightOfWindow()
	{
	return {width:$(window).width(),height:$(window).height()};
	}

function getWidthHeightOfDocument()
	{
	return {width:$(document).width(),height:$(document).height()};
	}

function getCenterOfScreen()
	{
	var scrollHeight = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
	var w_wh = getWidthHeightOfWindow();
	var x = w_wh.width/2;
	var y = w_wh.height/2+scrollHeight;
	return {x:x,y:y};
	}

function selectOptionWithValue(sel,val)
	{
	for (var i=0;i<sel.length;i++) sel[i].selected = false;
	for (var i=0;i<sel.length;i++)
		{
		if (sel[i].value == val)
			{
			sel[i].selected = true;
			return sel[i];
			}
		}
	return null;
	}

function getURLVars(from_str)
	{
	if (from_str) var url = from_str;
	else var url = ((typeof(window.location) == "string") ? window.location : window.location.href) || "";
	var var_string = url.split("?")[1] || "";
	var var_pairs = var_string.split("&");
	var get_object = new Object();
	for (var i=0;i<var_pairs.length;i++)
		{
		var pair = var_pairs[i].split("=");
		if (pair.length == 2) get_object[pair[0]] = pair[1];
		}
	return get_object;
	}
$_GET = getURLVars();

function inputOnBlur(inp)
	{
	var i = $(inp);
	i.removeClass("current");
	if (!i.val() && i[0] && i[0].defaultValue)
		{
		i.val(i[0].defaultValue);
		i.addClass("example");
		}
	}

function inputOnFocus(inp)
	{
	var i = $(inp);
	i.addClass("current");
	if (i[0] && i.val() == i[0].defaultValue)
		{
		i.val("");
		i.removeClass("example");
		}
	}

function assignDefaultValue(inp,default_value)
	{
	var i = $(inp);
	i.val(default_value);
	i[0].defaultValue = default_value;
	i.addClass("example");
	}

function applyFormEventHandlers()
	{
	var relevants = $("#psForm [type='text'],#wsfyForm [type='text'],#regForm [type='text'],#regForm [type='password'],#regForm select");
	relevants.bind("focus",function()
		{
		inputOnFocus(this);
		});
	relevants.bind("blur",function()
		{
		inputOnBlur(this);
		});
	
	$("#psForm [type='text']").bind("blur",function()
		{
		if ($("#psForm")[0].submitted_once) psOnSubmit();
		});
	$("#wsfyForm [type='text']").bind("blur",function()
		{
		if ($("#wsfyForm")[0].submitted_once) wsfyOnSubmit();
		});
	$("#regForm [type='text'],#regForm [type='password']").bind("blur",function()
		{
		if ($("#regForm")[0].submitted_once) regOnSubmit(true);
		});
	$("#regForm select").bind("change",function()
		{
		if ($("#regForm")[0].submitted_once) regOnSubmit(true);
		});
	$("#regForm select[name='gender']").bind("change",function()
		{
		genderOnChange(this);
		});
	$("#regForm [name='gender'][type='radio']").bind("click",function()
		{
		genderOnChange(this);
		if ($("#regForm")[0].submitted_once) regOnSubmit(true);
		});
	}

function regFormOnEnterForIE()
	{
	if ($.browser.msie && $.browser.version <= 7)
		{
		var submit_btn = null;
		var rf = $("#regForm");
		if ($("input[type='submit']:last",rf)[0]) submit_btn = $("input[type='submit']:last",rf);
		else if ($("input[type='image']:last",rf)[0]) submit_btn = $("input[type='image']:last",rf);
		if (submit_btn)
			{
			rf[0].submit_btn = submit_btn;
			rf.bind("keydown",function(e)
				{
				var key = e ? (e.which || e.keyCode || null) : null;
				if (key == 13)
					{
					this.submit_btn.click();
					return false;
					}
				});
			}
		}
	}

function qa_ids()
	{
	var wf = $("#wsfyForm");
	$("[name='firstName']",wf).attr("id","searchFName");
	$("[name='lastName']",wf).attr("id","searchLName");
	$("[name='age']",wf).attr("id","searchAge");
	$("[type='image']:last, [type='submit']:last",wf).attr("id","searchSubmit");

	var pf = $("#psForm");
	$("[name='searchFirstName']",pf).attr("id","searchFName");
	$("[name='searchLastName']",pf).attr("id","searchLName");
	$("[name='searchAge']",pf).attr("id","searchAge");
	$("[type='image']:last, [type='submit']:last",pf).attr("id","searchSubmit");
	
	var rf = $("#regForm");
	$("[name='firstName']",rf).attr("id","regFName");
	$("[name='lastName']",rf).attr("id","regLName");
	$("[name='email']",rf).attr("id","regEmail");
	$("[name='gender']",rf).attr("id","regGender");
	$("[name='maidenName']",rf).attr("id","regMName");
	$("[name='birthMonth']",rf).attr("id","regBdayMon");
	$("[name='birthDay']",rf).attr("id","regBdayDay");
	$("[name='birthYear']",rf).attr("id","regBdayYear");
	$("[name='zip']",rf).attr("id","regZipcode");
	$("[type='image']:last, [type='submit']:last",rf).attr("id","regSubmit");
	}

function setGender(to,hide)
	{
	if (to == 1) to = "m";
	else if (to == 2) to = "f";
	var gval = {"m":1,"f":2};
	var g = $("#regForm [name='gender']");
	if (typeof(global_custom_radio_controller) != "undefined" && global_custom_radio_controller && typeof(global_custom_radio_controller.setState) == "function")
		{
		global_custom_radio_controller.setState(to);
		}
	else if (g.attr("type") == "radio")
		{
		for (var i=0;i<g.length;i++)
			{
			if (g[i].value == gval[to]) $(g[i]).click();
			}
		}
	else
		{
		g.val(gval[to]);
		genderOnChange(g[0]);
		}
	if (hide) $("#gender").css("display","none");
	}

function insertQueryStringVarsIntoRegForm()
	{
	var rf = $("#regForm");
	var names = "firstName|lastName|searchFirstName|searchLastName|";
	var ages = "age|searchAge|";
	for (var k in $_GET)
		{
		if ($_GET[k])
			{
			var val = $_GET[k];
			if (names.indexOf(k+"|") != -1) val = fixName(val);
			else if (ages.indexOf(k+"|") != -1) val = fixAge(val);
			if (val)
				{
				var jelm = $("[name='"+k+"']",rf);
				if (k == "gender") setGender(val);
				else jelm.val(val);
				}
			}
		}
	}

$(function()
	{
	applyFormEventHandlers();
	regFormOnEnterForIE();
	qa_ids();
	insertQueryStringVarsIntoRegForm();
	if (typeof(activateVisitHistory) == "function") activateVisitHistory();
	});

function submitWSFY()
	{
	var form_elm = document.getElementById("wsfyForm");
	if (wsfyOnSubmit())
		{
		if (!form_elm.successfully_submitted)
			{
			fireRegOpenedPixel();
			form_elm.successfully_submitted = true;
			}
		loadTeaser(form_elm.firstName.value,form_elm.lastName.value,form_elm.age.value);
		$("#search_section").css("display","none");
		$("#results_section").css("display","block");
		$("#welcome_name .name_info_from_form").html(wsfy_info.full_name+", "+wsfy_info.age);
		var rform = $("#regForm")[0];
		rform.firstName.value = form_elm.firstName.value;
		rform.lastName.value = form_elm.lastName.value;
		if (rform.email.focus) rform.email.focus();
		}
	return false;
	}

function loadTeaser(fn,ln,a)
	{
	if (fn && ln && a && fn != "null" && ln != "null" && a != "null")
		{
		wsfy_info = {};
		wsfy_info.first_name = (fn.substr(0,1)).toUpperCase()+fn.substr(1);
		wsfy_info.last_name = (ln.substr(0,1)).toUpperCase()+ln.substr(1);
		wsfy_info.age = a;
		wsfy_info.full_name = wsfy_info.first_name+" "+wsfy_info.last_name;
		$.get("/WSFY/wsfy_api.php",{firstName:fn,lastName:ln,age:a},handleWSFYRequest);
		}
	}

function getPlusVersionOfCount(count,flag_type)
	{
	var new_count = count;
	if (flag_type == 1)
		{
		if (count > 5)
			{
			if (count < 20) new_count = Math.floor(count/5)*5;
			else new_count = Math.floor(count/10)*10;
			new_count = new_count+"+";
			}
		}
	else if (flag_type == 2)
		{
		if (count > 5 && count <= 10) new_count = "5+";
		if (count > 10) new_count = "10+";		
		}
	return new_count;
	}

function handleWSFYRequest(data)
	{
	var result_obj = eval("("+data+")");
	wsfy_info.result = result_obj.wsfy || null;
	if (!wsfy_info.result)
		{
		wsfy_info.result = {
			totalCount:0,
			numMales:0,
			numFemales:0,
			numSearchInLastWeek:0
		};
		}
	if (typeof(wsfy_count_cap_flag) != "undefined")
		{
		var n_totalCount = getPlusVersionOfCount(wsfy_info.result.totalCount,wsfy_count_cap_flag);
		var n_numMales = getPlusVersionOfCount(wsfy_info.result.numMales,wsfy_count_cap_flag);
		var n_numFemales = getPlusVersionOfCount(wsfy_info.result.numFemales,wsfy_count_cap_flag);
		var n_numSearchInLastWeek = getPlusVersionOfCount(wsfy_info.result.numSearchInLastWeek,wsfy_count_cap_flag);
		}
	else
		{
		var n_totalCount = wsfy_info.result.totalCount;
		var n_numMales = wsfy_info.result.numMales;
		var n_numFemales = wsfy_info.result.numFemales;
		var n_numSearchInLastWeek = wsfy_info.result.numSearchInLastWeek;
		}
	if (wsfy_info.result.totalCount)
		{
		$("#results_header_1").html(n_totalCount+" people searched for "+wsfy_info.full_name+".");
		$("#results_header_1").css("display","block");
		
		if (wsfy_info.result.numSearchInLastWeek)
			{
			$("#results_header_2").html(n_numSearchInLastWeek+" "+(wsfy_info.result.numSearchInLastWeek == 1 ? "person was" : "people were")+" looking for your name in the last week!");
			$("#results_header_2").css("display","block");
			}
		else $("#results_header_2").css("display","none");

		if (wsfy_info.result.numFemales)
			{
			$("#female_results .rbox_header").html(n_numFemales+" "+(wsfy_info.result.numFemales == 1 ? "was" : "were")+" female!");
			$("#female_results").css("display","block");
			}
		else $("#female_results").css("display","none");

		if (wsfy_info.result.numMales)
			{
			$("#male_results .rbox_header").html(n_numMales+" "+(wsfy_info.result.numMales == 1 ? "was" : "were")+" male!");
			$("#male_results").css("display","block");
			}
		else $("#male_results").css("display","none");
		}
	else
		{
		$("#results_header_1").html("Register now to find out exactly who has been searching for you!");
		$("#results_header_1").css("display","block");
		$("#male_results").css("display","none");
		$("#female_results").css("display","none");
		}
	}

function changeName()
	{
	$("#fn_row").css("display","block");
	$("#ln_row").css("display","block");
	$("#welcome_name").css("display","none");
	var fn = $("#fn_row .txt")[0];
	if (fn.focus) fn.focus();
	$("#pseudo_birthYear").css("display","block");
	return false;
	}

function launchItNow(fn,ln,a)
	{
	var ok_to_launch = true;
	
	var tform = document.getElementById("wsfyForm");

	fn = fixName(fn);
	ln = fixName(ln);
	a = fixAge(a);
	
	if (fn && ln && !a) a = "33";
	
	if (fn) tform.firstName.value = fn;
	else ok_to_launch = false;
	if (ln) tform.lastName.value = ln;
	else ok_to_launch = false;
	if (a) tform.age.value = a;
	else ok_to_launch = false;

	if (ok_to_launch) submitWSFY();
	else
		{
		if (!a) {try{tform.age.focus()}catch(e){}}
		if (!ln) {try{tform.lastName.focus()}catch(e){}}
		if (!fn) {try{tform.firstName.focus()}catch(e){}}		
		}
	}

function calculateBirthYear()
	{
	if ($("#pseudo_birthYear").val()) var birth_year = $("#pseudo_birthYear").val();
	else
		{
		var today = new Date();
		var age = wsfy_info.age;
		var birth_month = ($("#regForm [name='birthMonth']").val()*1 || 1)-1;
		var birth_day = ($("#regForm [name='birthDay']").val()*1 || 1);
		var current_month = today.getMonth();
		var current_day = today.getDate();
		var current_year = today.getFullYear();

		var birth_year = current_year-age;
		if (current_month < birth_month || (current_month == birth_month && current_day <= birth_day)) birth_year -= 1;
		}
	$("#regForm [name='birthYear']").val(birth_year);
	}

$(document).ready(function()
	{
	/*
	if ($_GET["autostate"])
		{
		$.getScript("/search/js/States.js",function()
			{
			var s = States.getState($_GET["autostate"]);
			if (s.name)
				{
				$(".wsfy_header").html("Who's searching for you in "+s.name+"? Find out!");
				$(".wsfy_header").css({"background":"transparent","text-indent":"0"});
				}
			});
		}
	*/
	launchItNow($_GET["firstName"] || "",$_GET["lastName"] || "",$_GET["age"] || "");
	});