// Our Javascript Library.
$(document).ready(function(){
function Open(id)
{
document.getElementById(id).style.display='block';
}
function Close(id)
{
document.getElementById(id).style.display='none';
}
function changeText(id, text)
{
document.getElementById(id).innerHTML=text;
}
$('#recover_pass_cancel').click(function(){
window.location='./';
});
$('#signup').click(function(){
firstname = document.getElementById('firstname');
lastname = document.getElementById('lastname');
email = document.getElementById('email_reg');
email_confirm = document.getElementById('email_confirm');
password = document.getElementById('password');
sex = document.getElementById('sex');
birthday_month = document.getElementById('birthday_month');
birthday_day = document.getElementById('birthday_day');
birthday_year = document.getElementById('birthday_year');
emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
if(firstname.value.length<3 || !email.value.match(emailExp) || !email_confirm.value.match(emailExp) || email.value.toLowerCase()!=email_confirm.value.toLowerCase() || lastname.value.length<3 || sex.value==0 || birthday_month.value==0 || birthday_day.value==0 || birthday_year.value==0 || password.value.length<5)
{
if(firstname.value.length<3) {
firstname.focus();
changeText('reg_error', 'First name must be 3+ characters');
}
else if(lastname.value.length<3) {
lastname.focus();
changeText('reg_error', 'Last name must be 3+ characters');
}
else if(!email.value.match(emailExp)) {
email.focus();
changeText('reg_error', 'Must be a valid email');
}
else if(!email_confirm.value.match(emailExp)) {
email_confirm.focus();
changeText('reg_error', 'Confirm your email');
}
else if(email.value.toLowerCase()!=email_confirm.value.toLowerCase() || email.value=='' || email_confirm.value=='') {
email_confirm.value='';
email_confirm.focus();
changeText('reg_error', 'Emails did not match');
}
else if(password.value.length<5) {
password.focus();
changeText('reg_error', 'Password must be 5+ characters');
}
else if(sex.value==0) {
sex.focus();
changeText('reg_error', 'Select your sex');
}
else if(birthday_month.value==0) {
birthday_month.focus();
changeText('reg_error', 'Select your birth month');
}
else if(birthday_day.value==0) {
birthday_day.focus();
changeText('reg_error', 'Select your birth day');
}
else if(birthday_year.value==0) {
birthday_year.focus();
changeText('reg_error', 'Select your birth year');
}
$('#reg_error').fadeIn(300);
return;
}
else
{
$("#reg").submit();
return;
}
});
$('#recover_pass_cancel').click(function(){
window.location='./';
});
$('#recover_pass_not_my_account').click(function(){
window.location='./recover.php';
});
$('#popupClose').click(function(){
// this is the listener
popupReset();
});
function popupReset() {
// reset the pop up window.
$('#popupWindow').hide(); // instead of hide, you can use effects like fade.
$('#popupTitle').html(''); // this can be changed to a default title
$('#popupContent').html(''); // this can be changed to a default title
$('#popupFooter').show(); // default; show the close window button
$('#popupClose').attr('value', 'Close'); // resets close button value
}
function popup(title, content, close_text, show_close) {
// must be called through listeners
// makes for sexy source code anyways ;)
// 'content' will be used as functions quite often
// show_close & close_text optional
if(close_text==null) {
close_text = 'Close';
} else {
show_close = 1;
}
if(show_close==null) {
show_close = 1;
}
$('#popupTitle').html(title);
$('#popupContent').html(content);
if(show_close==1) {
$('#popupFooter').show();
} else {
$('#popupFooter').hide();
}
$('#popupWindow').show();
$('#popupClose').attr('value', close_text);
}
$('#why_provide_birthday').click(function() {
popup('Why do I need to provide my birthday?', 'Facebook requires all users to provide their real date of birth to encourage authenticity and provide only age-appropriate access to content. You will be able to hide this information from your profile if you wish, and its use is governed by the Facebook Privacy Policy.', 'Okay', 0);
});
});