﻿$(document).ready(function () {

    //QUICK CONTACT FORM VALIDATION
    /*select*/
    $("#quickContact_form input").click(function () {
        var inptID = $(this).attr('ID');
        var inptVal = $(this).val();

        if (inptID != 'qContact_submit') {
            $(this).removeClass("inputRequired");
            $(this).addClass("activeInput");
            $(this).val('');
        } else {
            /*validate*/
            if ($('#qContact_name').val() == 'Name [required]' || $('#qContact_email').val() == 'Email [required]' || $('#qContact_phone').val() == 'Phone [required]') {

                if ($('#qContact_name').val() == 'Name [required]') {
                    $('#qContact_name').addClass('inputRequired');
                }
                if ($('#qContact_email').val() == 'Email [required]') {
                    $('#qContact_email').addClass('inputRequired');
                }
                if ($('#qContact_phone').val() == 'Phone [required]') {
                    $('#qContact_phone').addClass('inputRequired');
                }
                return false;
            }
        }
    });
    $("#inquiry_interest").change(function () {
        if ($(this).val() != "I am interested in:") {
            $(this).addClass("activeInput");
        } else {
            $(this).removeClass("activeInput");
        }
    });
    $("textarea#qContact_comments").click(function () {

        if ($(this).text() == 'Comments') {
            $(this).addClass("activeInput");
            $(this).val('');
        }
    });
    /*blur*/
    $("#quickContact_form input").blur(function () {
        var inptID = $(this).attr('ID');
        var inptVal = $(this).val();

        if (inptID != 'qContact_submit') {
            if ($(this).val() == "") {

                switch (inptID) {
                    case 'qContact_name':
                        $(this).val('Name [required]');
                        $(this).removeClass("activeInput");
                        break;
                    case 'qContact_email':
                        $(this).val('Email [required]');
                        $(this).removeClass("activeInput");
                        break;
                    case 'qContact_phone':
                        $(this).val('Phone [required]');
                        $(this).removeClass("activeInput");
                        break;
                    default:
                        document.write("");
                }
            }
        }
    });
    $("textarea#qContact_comments").blur(function () {

        if ($(this).val() == '') {
            $(this).removeClass("activeInput");
            $(this).val('Comments');
        }

    });


    //END QUICK CONTACT FORM VALIDATION


});
