﻿function FormValidation() {
	var send = true;
	$(".required").each(function(key, value) {
		if ($(value).val().length == 0) {
			this.style.border = "1px #9E1111 solid";
			send = false;
		}
	});
	return (send == true) ? true : false;
}

function Check(url) {
	if (confirm("האם אתה בטוח שברצונך לבצע פעולה זו?")) {
		window.location = url;
	}
}

function Search(elm) {
	if (document.getElementById("q").value == "") {
		document.getElementById("q").style.background = "#CD5C5C";
		document.getElementById("q").focus();
	}
	else {
		window.location = 'index.php?module=search&act=display&q='+encodeURIComponent(document.getElementById("q").value);
	}
}

function submitSearchOnEnter(variable)
{
  var keyCode;

  //get whatever key was just pressed
  //try to account for different methods of getting
  //event keys depending on implementation
  if(window.event)
  {
      keyCode = window.event.keyCode;
  }
  else if(variable)
  {
      keyCode = variable.which;
  }

  //if the key was the enter key, perform the necessary function
  if(keyCode == 13) //13 = enter key
  {
      //here is where you process the form item or call a function to do that
      Search(); //call search
  }
}

$(document).ready(function(){
	document.getElementById('q').onkeyup = submitSearchOnEnter;
});
