function validateForm(A){if($("userauthFirstName")){if($F("userauthFirstName")==""){alert("Please enter a first name.");
return false;
}}if($("userauthLastName")){if($F("userauthLastName")==""){alert("Please enter a last name.");
return false;
}}if($("dobYear")){if($("dobYear").value==0){alert("Please enter your date of birth.");
return false;
}if($("dobYear").value>0){age=calcAge($("dobYear").value,$("dobMonth").value,$("dobDay").value);
if(age<=12){showTooYoung();
return false;
}}}if($("gender")){if($("gender").value!="M"&&$("gender").value!="F"){alert("Please select your gender.");
return false;
}}if($("male")){if(!$("male").checked&&!$("female").checked){alert("Please select your gender.");
return false;
}}if($("userauthEmail")){email=$F("userauthEmail");
if(email==""||email.indexOf("@")<0||email.indexOf(".")<0){alert("Please enter a valid email address.");
return false;
}}if($("userauthPassword")){password=$F("userauthPassword");
if(password.length<4){alert("Your password must be at least 4 characters long.");
return false;
}}if($("captcha")){captcha=$F("captcha");
if(captcha==""){alert("Please enter the letters you see in the image.");
return false;
}}if($("terms")){tos=$F("terms");
if(tos!="true"){alert("You must check the box indicating you agree to the terms of service.");
return false;
}}return Clicker.guard();
}function showTooYoung(){if($("mainform")){Element.hide($("mainform"));
}if($("scrapeform")){Element.hide($("scrapeform"));
}if($("message")){Element.hide($("message"));
}if($("anonRegForm")){Element.hide($("anonRegForm"));
}Element.show($("tooyoung"));
}function doTooYoung(A){if(A){dobstr=getDobDisplay($("dobYear").value,$("dobMonth").value,$("dobDay").value);
top.document.location="/account/do-confirm-age?dob="+dobstr+"&ageButton=Yes";
}else{if($("mainform")){Element.show($("mainform"));
}if($("scrapeform")){Element.show($("scrapeform"));
}if($("message")){Element.show($("message"));
}if($("anonRegForm")){Element.show($("anonRegForm"));
}Element.hide($("tooyoung"));
}}function updateAge(){$("dobPreview").innerHTML=getDobDisplay($("dobYear").value,$("dobMonth").value,$("dobDay").value);
age=calcAge($("dobYear").value,$("dobMonth").value,$("dobDay").value);
if($("checkFriendsRow")&&age<=21&&age>=13){showRow("checkFriendsRow");
$("checkfriends").checked=true;
}}function getDobDisplay(C,B,A){dobStr=(B>0?(B+"/"):"")+(A>0?(A+"/"):"")+C;
return dobStr;
}function calcAge(D,K,F){var A=new Date();
var I=new Date(A.getYear(),A.getMonth(),A.getDate());
var G=A.getFullYear();
var B=A.getMonth()+1;
var H=A.getDate();
var C=G-D;
if(B>=K){var J=B-K;
}else{C--;
var J=12+B-K;
}if(H>=F){var E=H-F;
}else{J--;
var E=31+H-F;
if(J<0){J=11;
C--;
}}return C;
}var FormTip=Class.create();
FormTip.prototype={initialize:function(A){this.fields=A;
},selectedField:null,show:function(A){if(this.selectedField==A){return ;
}this.selectedField=A;
this.fields.each(function(C,B){if(Element.visible($(C))){$(C).hide();
}});
$(this.selectedField).show();
},hideAll:function(){this.fields.each(function(B,A){if(Element.visible($(B))){$(B).hide();
}});
}};
function changeBook(A){if(A=="Hotmail"){Element.show("hotmail");
Element.hide("yahoo");
Element.hide("aol");
Element.hide("gmail");
}else{if(A=="Yahoo"){Element.hide("hotmail");
Element.show("yahoo");
Element.hide("aol");
Element.hide("gmail");
}}if(A=="Gmail"){Element.hide("hotmail");
Element.hide("yahoo");
Element.hide("aol");
Element.show("gmail");
}if(A=="AOL"){Element.hide("hotmail");
Element.hide("yahoo");
Element.show("aol");
Element.hide("gmail");
}}function scrape_submit_handler(A){$("submit"+A).disabled="true";
$("prescrape").style.cursor="wait";
$("waitmessage"+A).innerHTML="Retrieving contacts.";
$("waitmessage"+A).style.color="green";
$("waitmessage"+A).style.fontWeight="bold";
setTimeout(function(){timer_handler(A);
},1500);
return true;
}function timer_handler(A){$("waitmessage"+A).innerHTML=$("waitmessage"+A).innerHTML+" .";
setTimeout(function(){timer_handler(A);
},1500);
}function showRow(A){$(A).style.display=(navigator.userAgent.indexOf("Firefox")==-1)?"block":"table-row";
}var loginWidget={STATES:{READY:0,SUBMITTING:1},UPDATE_MSG_INTERVAL:1500,MARKER_START:'<div id="authStatus">',MARKER_END:"</div>",counter:0,handleAjaxLogin:function(A){this.state=this.STATES.SUBMITTING;
var B=Form.serialize("inviteForm");
new Ajax.Request($("inviteForm").action,{parameters:B,onSuccess:this.processLoginResponse.bind(this),onTimeout:this.onTimeout.bind(this),onFailure:this.onFailure.bind(this)});
$("inviteSubmit2").disabled=true;
$("preinvite").style.cursor="wait";
showRow("statusRow");
$("loginStatus").update("Attempting to log you in");
$("loginStatus").style.color="green";
this.drawSubmissionTicker();
Tracker.tag("PRE_Viral_Login");
return false;
},drawSubmissionTicker:function(){if(loginWidget.state==loginWidget.STATES.SUBMITTING){$("loginStatus").innerHTML=$("loginStatus").innerHTML+". ";
setTimeout(function(){loginWidget.drawSubmissionTicker();
},loginWidget.UPDATE_MSG_INTERVAL);
}},processLoginResponse:function(A){var D=A.responseText.indexOf(this.MARKER_START)+this.MARKER_START.length;
var B=A.responseText.indexOf(this.MARKER_END,D);
var C=A.responseText.substring(D,B).strip();
$("loginStatus").update(C);
showRow("statusRow");
if(C.search(/successful/i)>=0){$("loginStatus").style.color="green";
this.state=this.STATES.SUBMITTING;
this.drawSubmissionTicker();
this.handleSendInvites();
}else{this.allowPostErrorResubmission();
}},allowPostErrorResubmission:function(){$("loginStatus").style.color="red";
this.state=this.STATES.READY;
$("inviteSubmit2").disabled=false;
$("preinvite").style.cursor="default";
},onTimeout:function(A){$("loginStatus").update("Whoops, your request timed out. Please check your network connection and try again.");
showRow("statusRow");
this.allowPostErrorResubmission();
},onFailure:function(A){$("loginStatus").update("Whoops, our servers coughed.  Please try again.");
showRow("statusRow");
this.allowPostErrorResubmission();
},handleSendInvites:function(){$("inviteForm").action="/invite/action/address-book/send";
$("inviteForm").submit();
}};




