﻿

function SignupForm() 
{
    var strURL = "";
    // Use for turning off the site.
        var height = 225;
        var width = 475;
        strURL = "/RegistrationOver.aspx";
//    var height = 712;
//    var width = 775;
//    strURL = "/Contest-Sign-Up.aspx";
    GB_showCenter("", strURL, height, width);
}
function RulesRegs() {
    var strURL = "";
    var height = 900;
    var width = 775;
    strURL = "/rules.html";
    GB_showCenter("", strURL, height, width);
}
function HideShowLabel(obj, startValue) {
    if (obj.value == startValue) {
        obj.value = '';
        obj.setStyle('color', '');
    }
    else if (obj.value == '') {
    obj.value = startValue;
    }
}
function ReappearingLabel(obj, existingValue) {
        if (obj.value == '') {
            obj.value=existingValue;
            }
        }
        function CheckOnlyOne(currentChkBx) {
            var oneMonth = $('onemonth');
            var threeMonths = $('threemonths');
            var sixMonths = $('sixmonths');
            var sixPlusMonths = $('sixplusmonths');

            if (oneMonth.id != currentChkBx) {
                oneMonth.removeProperty('checked');
            }
            if (threeMonths.id != currentChkBx) {
                threeMonths.removeProperty('checked');
            }
            if (sixMonths.id != currentChkBx) {
                sixMonths.removeProperty('checked');
            }
            if (sixPlusMonths.id != currentChkBx) {
                sixPlusMonths.removeProperty('checked');
            }
   

        }
function ValidateForm() {
    var firstName = $('first');
    var lastName = $('last');
    var street = $('street');
    var city = $('city');
    var state = $('state').getSelected();
    var zip = $('zip');
    var email = $('email');
    var phone = $('phone');

    
    
    if (firstName.value == 'First Name**') {
        SetStatus('Please enter a first name.');
        firstName.setStyle('color', 'red');
        return false;
    }
    else {
        firstName.setStyle('color', '');
    }
    if (lastName.value == 'Last Name**') {
        SetStatus('Please enter a last name.');
        lastName.setStyle('color', 'red');
        return false;
    }
    else {
        lastName.setStyle('color', '');
    }
    if (street.value == 'Street**') {
        SetStatus('Please enter a street.');
        street.setStyle('color', 'red');
        return false;
    }
    else {
        street.setStyle('color', '');
    }
    if (city.value == 'City**') {
        SetStatus('Please enter a city.');
        city.setStyle('color', 'red');
        return false;
    }
    else {
        city.setStyle('color', '');
    }
    if (state.value == 'Select a State**') {
        SetStatus('Please select a state.');
        state.setStyle('color', 'red');
        return false;
    }
    else {
        state.setStyle('color', '');
    }
    if (zip.value == 'Zip**') {
        SetStatus('Please enter a zip.');
        zip.setStyle('color', 'red');
        return false;
    }
    else {
        zip.setStyle('color', '');
    }
    if (!ValidZip(zip.value)) {
        SetStatus('Please enter a valid zip.');
        zip.setStyle('color', 'red');
        return false;
    }
    else {
        zip.setStyle('color', '');
    }
    if (email.value == 'Email**') {
        SetStatus('Please enter a valid email.');
        email.setStyle('color', 'red');
        return false;
    }
    else {
        email.setStyle('color', '');
    }
    if (!ValidEmail(email.value)) {
        SetStatus('Please enter a valid email.');
        email.setStyle('color', 'red');
        return false;
    }
    else {
        email.setStyle('color', '');
    }
    if (phone.value == 'Phone**') {
        SetStatus('Please enter a valid phone number.');
        phone.setStyle('color', 'red');
        return false;
    }
    else {
        phone.setStyle('color', '');
    }
    if (!ValidPhone(phone.value)) {
        SetStatus("Please enter a valid phone.");
        phone.setStyle('color', 'red');
        return false;
    }
    else {
        phone.setStyle('color', '');
    }
    document.forms[0].action = "AddEntry.ashx";
    document.forms[0].submit();
}
function ValidEmail(value) {
    var pattern = /^([a-zA-Z0-9_\-\.]+)@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/;
    return pattern.test(value);
}
function ValidPhone(value) {
    //var pattern = /^([0-9][0-9][0-9](\-)?[0-9][0-9][0-9](\-)?[0-9][0-9][0-9][0-9](\-[0-9][0-9][0-9]\-[0-9][0-9][0-9][0-9])?)$/;
    var pattern = /^([0-9][0-9][0-9](\-)?[0-9][0-9][0-9](\-)?[0-9][0-9][0-9][0-9])/;
    return pattern.test(value)
}
function AlphaOnly(value) {
    var pattern = /^([a-zA-Z]+)$/;
    return pattern.test(value);
}
function NumericOnly(value) {
    var pattern = /^([0-9]+)$/;
    return pattern.test(value)
}
function ValidZip(value) {
    var pattern = /^[0-9][0-9][0-9][0-9][0-9](\-[0-9][0-9][0-9][0-9])?$/;
    return pattern.test(value)
}
function SetStatus(value) {
    //alert(value);
    var status = $('statusmessage');
    status.set('html', '<p><font color=red>**</font>' + value + '</p>');
    status.setStyle('display', 'block');
    status.setStyle('height', '50');
}
