// JavaScript Document
function checkEmail(eMail) {
var pattern = /^[\_]*([a-zA-Z0-9]+(\.|\_*)?)+@([a-zA-Z0-9][a-zA-Z0-9\-]+(\.|\-*\.))+[a-zA-Z]{2,6}$/;
return pattern.test(eMail);
}
function checkPhone(phone) {
if(phone.length<7)
return false;
for (var i = 0; i < phone.length; i++) {
if ( ( (phone.charAt(i) < "0") || (phone.charAt(i) > "9") ) && (phone.charAt(i) != "-") )
return false;
}
return true;
}
function checkName(name) {
for( var i=0; i < name.length; i++ ) {
if((name.charAt(i)>='0' && name.charAt(i)<='9') ||
name.charAt(i) == '/' ||
name.charAt(i) == '\\' ||
name.charAt(i) == ',' ||
name.charAt(i) == '.' ||
name.charAt(i) == '=' ||
name.charAt(i) == '+' ||
name.charAt(i) == ':' ||
name.charAt(i) == ';' ||
name.charAt(i) == '|' ||
name.charAt(i) == '#' ||
name.charAt(i) == '$' ||
name.charAt(i) == '%' ||
name.charAt(i) == '^' ||
name.charAt(i) == '&' ||
name.charAt(i) == '*' ||
name.charAt(i) == '(' ||
name.charAt(i) == ')' ||
name.charAt(i) == '_' ||
name.charAt(i) == '[' ||
name.charAt(i) == ']' ||
name.charAt(i) == '{' ||
name.charAt(i) == '}' ||
name.charAt(i) == '~' ||
name.charAt(i) == '@' ) {
return true;
}
}
return false
}
function checkForm() {
if(document.getElementById('fullName').value=="" || document.getElementById('fullName').value=="שם מלא") {
alert(".נא למלא שם מלא *");
document.getElementById('fullName').focus();
return false;
}
if(checkName(document.getElementById('fullName').value) ) {
alert(".שם מלא יכול להכיל אותיות בלבד *");
document.getElementById('fullName').focus();
return false;
}
if(document.getElementById('eMail').value=="" || document.getElementById('eMail').value=='דוא"ל') {
alert(".נא למלא דוא\"ל *");
document.getElementById('eMail').focus();
return false;
}
if(document.getElementById('eMail').value != '' && document.getElementById('eMail').value!='דוא"ל') {
if(!checkEmail(document.getElementById('eMail').value)) {
alert('.כתובת דוא\"ל אינה תקינה *');
document.getElementById('eMail').focus();
return false;
}
}
if(document.getElementById('phone').value=="" || document.getElementById('phone').value=="טלפון") {
alert(".נא למלא טלפון *");
document.getElementById('phone').focus();
return false;
}
if(document.getElementById('phone').value!='' || document.getElementById('phone').value=="טלפון") {
if(!checkPhone(document.getElementById('phone').value)) {
alert("מספר טלפון אינו תקין *");
document.getElementById('phone').focus();
return false;
}
}
return true;
}
$(function() {
		   
	$(".search_submit").mouseenter(function() {
		$(this).css("background", "url(images/search_submit.png) bottom no-repeat");
	}).mouseleave(function() {
		$(this).css("background", "url(images/search_submit.png) top no-repeat");
	});	
	
	
$("#search").focus(function() {
if($(this).attr("value") == 'חיפוש באתר') $(this).attr("value", '');
}).blur(function() {
if($(this).attr("value") == '') $(this).attr("value", 'חיפוש באתר');
});		 
$("#eMail").keypress(function() {
$(this).attr("value", jQuery.trim($(this).attr("value")));
});
$("#eMail").focus(function() {
if($(this).attr("value") == 'דוא"ל') $(this).attr("value", '');
}).blur(function() {
if($(this).attr("value") == '') $(this).attr("value", 'דוא"ל');
});
$("#fullName").focus(function() {
if($(this).attr("value") == 'שם מלא') $(this).attr("value", '');
}).blur(function() {
if($(this).attr("value") == '') $(this).attr("value", 'שם מלא');
});
$("#phone").focus(function() {
if($(this).attr("value") == 'טלפון') $(this).attr("value", '');
}).blur(function() {
if($(this).attr("value") == '') $(this).attr("value", 'טלפון');
});
});
