function initMenu() {
  $('#cats ul').hide();
  //$('#cats ul#item20').show();
  $('#cats li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('#cats ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  }
  
$(document).ready(function() {initMenu();});

function openNav(item) {
    $('#cats ul#item'+item).show();
}

function isValidEmail(str) {
    //return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    return pattern.test(str);
}

function highlight(id) {
    document.getElementById(id).style.border = "2px solid #990000";
}

function checkForm() {

    var error = '';

    var fields = new Array();
    fields[0] = 'name';
    fields[1] = 'tel';
    fields[2] = 'quantity';
    fields[3] = 'colors';

    str = document.getElementById('email').value;

    if (isValidEmail(str) == false) {
        document.getElementById('erremail').innerHTML = 'E-mail not valid.'
        highlight('email');
        error = 1;
    }

    for (var i=0; i < fields.length; i++) {
        if (document.getElementById(fields[i]).value == '') {
            highlight(fields[i]);
            document.getElementById('err').innerHTML = 'Please fill in the red hilighted fields before submitting form...<br/><br/>';
            error = 1;
        }
    }


    if (error == 1) {
        return false;
    } else {
        return true;
    }

}