function checkForgotPass(f)
{
    errors = "The following errors have been found: \n\n";
    valid = true;

    if (f.forgot_email.value == "")
    {
        errors += "- Email address must be completed.\n";
        valid = false;
    }

    if (!valid)
    {
        errors += "\nPlease try again";
        alert(errors);
    }
    else
    {
        f.submit();
    }
}


function checkLogin(f)
{
    errors = "The following errors have been found: \n\n";
    valid = true;

    if (f.email.value == "")
    {
        errors += "- email must be completed.\n";
        valid = false;
    }

    if (f.password.value == "")
    {
        errors += "- password must be completed.\n";
        valid = false;
    }

    if (!valid)
    {
        errors += "\nPlease try again";
        alert(errors);
    }
    else
    {
        f.submit();
    }
}

function checkContactUs(f)
{
    errors = "The following errors have been found: \n\n";
    valid = true;

    if (f.Name.value == "")
    {
        errors += "- Name must be completed.\n";
        valid = false;
    }

    if (f.Email.value == "")
    {
        errors += "- Email must be completed.\n";
        valid = false;
    }

    if (f.Enquiry.value == "")
    {
        errors += "- Your Enquiry must be completed.\n";
        valid = false;
    }

    if (!valid)
    {
        errors += "\nPlease try again";
        alert(errors);
    }

    return valid;
}

function checkBecomeYummi(f)
{
    errors = "The following errors have been found: \n\n";
    valid = true;

    if (f.Name.value == "")
    {
        errors += "- Name must be completed.\n";
        valid = false;
    }

    if (f.Email.value == "")
    {
        errors += "- Email must be completed.\n";
        valid = false;
    }

    if (f.Region.value == "")
    {
        errors += "- Region must be completed.\n";
        valid = false;
    }

    if (f.About.value == "")
    {
        errors += "- About Yourself must be completed.\n";
        valid = false;
    }

    if (!valid)
    {
        errors += "\nPlease try again";
        alert(errors);
    }

    return valid;
}

function checkYummiMembership(f)
{
    errors = "The following errors have been found: \n\n";
    valid = true;

    if (f.contact_name.value == "")
    {
        errors += "- contact_name must be completed.\n";
        valid = false;
    }

    if (f.email.value == "")
    {
        errors += "- email must be completed.\n";
        valid = false;
    }

    if (f.address1.value == "")
    {
        errors += "- address1 must be completed.\n";
        valid = false;
    }

    if (f.town.value == "")
    {
        errors += "- town must be completed.\n";
        valid = false;
    }

    if (f.county.value == "")
    {
        errors += "- county must be completed.\n";
        valid = false;
    }

    if (f.country_id[f.country_id.selectedIndex].value == "")
    {
        errors += "- country_id must be completed.\n";
        valid = false;
    }

    if (f.postcode.value == "")
    {
        errors += "- postcode must be completed.\n";
        valid = false;
    }

    if (f.age.value == "")
    {
        errors += "- age must be completed.\n";
        valid = false;
    }

    if (f.profession.value == "")
    {
        errors += "- profession must be completed.\n";
        valid = false;
    }

    if (f.no_of_children.value == "")
    {
        errors += "- no_of_children must be completed.\n";
        valid = false;
    }

    if (f.tshirt_choice.value == "")
    {
        errors += "- tshirt_size must be completed.\n";
        valid = false;
    }

    if (!valid)
    {
        errors += "\nPlease try again";
        alert(errors);
    }

    return valid;
}

function checkCustomerDetails(f)
{
    errors = "The following errors have been found: \n\n";
    valid = true;

    if (f.contact_name.value == "")
    {
        errors += "- contact_name must be completed.\n";
        valid = false;
    }

    if (f.email.value == "")
    {
        errors += "- email must be completed.\n";
        valid = false;
    }

    if (f.password.value == "" || f.passwordc.value == "")
    {
         errors += "- password and password confirmation must be completed.\n";
         valid = false;
    }
    else
    {
        if (f.password.value != f.passwordc.value)
        {
             errors += "- password and password confirmation do not match.\n";
            valid = false;
        }
    }

     if (f.security_question.value == "")
    {
        errors += "- security_question must be completed.\n";
        valid = false;
    }

    if (f.security_answer.value == "")
    {
        errors += "- security_answer must be completed.\n";
        valid = false;
    }

    if (f.billing_line1.value == "")
    {
        errors += "- billing_line1 must be completed.\n";
        valid = false;
    }

    if (f.billing_town.value == "")
    {
        errors += "- billing_town must be completed.\n";
        valid = false;
    }

    if (f.billing_county.value == "")
    {
        errors += "- billing_county must be completed.\n";
        valid = false;
    }

    if (f.billing_country_id[f.billing_country_id.selectedIndex].value == "")
    {
        errors += "- billing_country must be completed.\n";
        valid = false;
    }

    if (f.billing_postcode.value == "")
    {
        errors += "- billing_postcode must be completed.\n";
        valid = false;
    }

    if (f.shipping_line1.value == "")
    {
        errors += "- shipping_line1 must be completed.\n";
        valid = false;
    }

    if (f.shipping_town.value == "")
    {
        errors += "- shipping_town must be completed.\n";
        valid = false;
    }

    if (f.shipping_county.value == "")
    {
        errors += "- shipping_county must be completed.\n";
        valid = false;
    }

    if (f.shipping_country_id[f.shipping_country_id.selectedIndex].value == "")
    {
        errors += "- shipping_country must be completed.\n";
        valid = false;
    }

    if (f.shipping_postcode.value == "")
    {
        errors += "- shipping_postcode must be completed.\n";
        valid = false;
    }

    if (f.daytime_tel.value == "")
    {
        errors += "- daytime telephone must be completed.\n";
        valid = false;
    }

    if (f.evening_tel.value == "")
    {
        errors += "- evening telephone must be completed.\n";
        valid = false;
    }

    if(!f.agree_terms.checked)
    {
        errors += "- terms and conditions must be read and agreed to.\n";
        valid = false;
    }

    if (!valid)
    {
        errors += "\nPlease try again";
        alert(errors);
    }
    else
    {
        f.submit();
    }
}

function copyAddress(f)
{
    f.shipping_line1.value = f.billing_line1.value;
    f.shipping_line2.value = f.billing_line2.value;
    f.shipping_line3.value = f.billing_line3.value;
    f.shipping_town.value = f.billing_town.value;
    f.shipping_county.value = f.billing_county.value;
    f.shipping_country_id.value = f.billing_country_id.value;
    f.shipping_postcode.value = f.billing_postcode.value;
}

function changeDelivery(url,s)
{
    var nxt_day = s[s.selectedIndex].value;
    url += "?change_del_type="  +  nxt_day;

    document.location.href=url;
}

function showGalleryImage(gallery_id)
{
    url = "showgalleryimage.php?gallery_id=" + gallery_id;
    var win = openWindow(url,"gallery",500,450);
}

function openWindow(url,name,width,height)
{
    props = "width=" + width + ",height=" + height + ",scrollbars";
    window.open(url,name,props);
}

function checkEmailFriend(f)
{
    errors = "The following errors have been found: \n\n";
    valid = true;

    if (f.name_of_recipient.value == "")
    {
        errors += "- Recipient Name must be completed.\n";
        valid = false;
    }

    if (f.email_of_recipient.value == "")
    {
        errors += "- Recipient Email must be completed.\n";
        valid = false;
    }

    if (f.your_name.value == "")
    {
        errors += "- Your Name must be completed.\n";
        valid = false;
    }

    if (f.your_email.value == "")
    {
        errors += "- Your Email must be completed.\n";
        valid = false;
    }

   if (f.msg.value == "")
   {
       errors += "- Message must be completed.\n";
       valid = false;
    }

    if (!valid)
    {
        errors += "\nPlease try again";
        alert(errors);
    }
    else
    {
        f.submit();
    }
}