﻿$(document).ready(function() {
    $(".Logo").click(function() {
        window.location = 'http://www.cityloft.co.il/';
    })
    $(".InputNum").keypress(function(e) {
        if (e.whice != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) return false;
    })
    $(document).pngFix();
});
function ContactUsFormSubmit() {
    var flag = true;
    $(".CheckField").each(function(i) {
        if (typeof $(this).attr("regex") != 'undefined') {
            var regex = new RegExp($(this).attr("regex"));
            if ($(this).attr("class").indexOf("required") != -1) {
                if (!(regex).test($(this).val())) {
                    $(this).addClass("RedBorder");
                    flag = false;
                }
                else $(this).removeClass("RedBorder");
                //else $("#" + ($(this).attr("ErrMsg"))).css("display","none"); 
            }
            else // IF IT NOT A REQUIRED FIELD
            {
                if ($(this).val().length > 0) {
                    if (!(regex).test($(this).val())) {
                        $(this).addClass("RedBorder");
                        flag = false;
                    }
                    else $(this).removeClass("RedBorder");
                }
            }
        }
    })
    if (flag) {
        $("#ContactUsSendBtn").attr("onclick", "");
        $(".ErrMsg").css("display", "none");
        document.ContactUsForm.submit();
    }
    else $(".ErrMsg").css("display", "block");

}
function submitenter(myfield, e) {
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;

    if (keycode == 13) {
        ContactUsFormSubmit();
        return false;
    }
    else
        return true;
}


