function isEmpty (item){
    if (document.getElementById(item).value == ''){
        return true;
    }
}

// Begin Signup
function validateSignup (){
    theForm = document.getElementById('step1');
    var msg = '';

    if (isEmpty ('first_name')){msg += 'First Name, '}
    if (isEmpty ('last_name')){msg += 'Last Name, '}
    if (isEmpty ('state')){msg += 'State, '}
    if (isEmpty ('city')){msg += 'City, '}
    if (isEmpty ('zip_code')){msg += 'Zip Code, '}

    if (isEmpty ('birthdate_m') || isEmpty ('birthdate_d') || isEmpty ('birthdate_y')){
        msg += 'Birth date, ';
    }

    if (isEmpty ('email')){
        msg += 'Email, ';
    }else if (theForm.email.value.indexOf('@') < 1 || theForm.email.value.indexOf('.') < 1){
        alert ('Invalid email address.');
        return false;
    }

    if (isEmpty ('password') || isEmpty ('passwordV')){
        msg += 'Password, ';
    }else if (theForm.password.value != theForm.passwordV.value){
        alert ('Passwords do not match.');
        return false;
    }

    if (isEmpty ('captcha', 1)){
        alert ('Confirmation Code can\'t be left empty.');
        return false;
    }

    if (!theForm.terms.checked){
        alert ('To create an account in our site you must accept the \r\nTerms Of Services.');
        return false;
    }

    if (msg != ''){
        msg = msg.slice (0, msg.length - 2);
        msg = 'Please, complete the following required (*) fields:\n\r' + msg + '\n\r';
        alert (msg);
        return false;
    }else{
        return true;
    }
}
// End Signup

// Begin Checkout
var CheckOutCounter=0;
function doCheckOut (){
    if (CheckOutCounter == 0){
        if(confirm ("Are you sure you want to submit this transaction?\nDo not click back or refresh your browser.\n\nThank you.")){
            CheckOutCounter++;
            return true;
        }else{
            return false;
        }
    }else{
        alert("Form is being sent, please wait a momment.");
        return false;
    }
}

function unlockCouponCode (){
    document.forms.checkoutForm.couponCode.disabled = false;
    document.forms.checkoutForm.couponCode.className = 'text';
}

function lockCouponCode (){
    document.forms.checkoutForm.couponCode.disabled = true;
    document.forms.checkoutForm.couponCode.className = 'text disabled';
}
// End Checkout

// Begin Advanced Search
function aSrchShowHide (item) {
    for (var i = 0; i < aSrchForms.length; i++) {
        var wichItem = document.getElementById(aSrchForms[i]);
        if (aSrchForms[i] === item) {
            wichItem.className='itemShown';
            var success = true;
        }else{
            wichItem.className='itemHidden';
        }
    }
    if (!success){
        aSrchShowHide (aSrchForms[0]);
    }
}

function show (item) {
    wichItem = document.getElementById(item);
    wichItem.className='itemShown forms';
}

function hide (item) {
    wichItem = document.getElementById(item);
    wichItem.className='itemHidden';
}
// End Advanced Search

function aCaptcha(field){
    var strlen=document.getElementById(field).value.length;
    document.getElementById('captcha').value=strlen;
}

function evenHeights() {
    if (!document.getElementsByTagName) return;
    var l=parseInt(document.getElementById('pBox1L').offsetHeight);
    var r=parseInt(document.getElementById('pBox1R').offsetHeight);
    if(r > l){
        document.getElementById('prfBasic').style.paddingBottom=(r-l)+'px';
    }
}