﻿function FooterNewsletterFormSetUp(){
	var fieldText = [
		{ fld:'FNFFirstName', txt:'' },
		{ fld:'FNFLastName', txt:'' },
		{ fld:'FNFEmail', txt:'' }
	];
	for(var i=0; i<fieldText.length; i++){
		var fld = document.forms.FooterNewsletterForm[fieldText[i].fld];
		if(fld.value) { fieldText[i].txt = fld.value; }
		fld.setAttribute('index', i);
		fld.onfocus = function(){
			if(this.value == fieldText[this.getAttribute('index')].txt){
				this.value = '';
			}
		};
		fld.onblur  = function(){
			if(this.value == ''){
				this.value = fieldText[this.getAttribute('index')].txt;
			}
		};
	}
};

function FooterContactFormSetUp(){
	var fieldText = [
		{ fld:'FCFFirstName', txt:'' },
		{ fld:'FCFLastName', txt:'' },
		{ fld:'FCFEmail', txt:'' },
		{ fld:'FCFPhone', txt:'' },
		{ fld:'FCFMassage', txt:'' }
	];
	for(var i=0; i<fieldText.length; i++){
		var fld = document.forms.FooterContactForm[fieldText[i].fld];
		if(fld.value) { fieldText[i].txt = fld.value; }
		fld.setAttribute('index', i);
		fld.onfocus = function(){
			if(this.value == fieldText[this.getAttribute('index')].txt){
				this.value = '';
			}
		};
		fld.onblur  = function(){
			if(this.value == ''){
				this.value = fieldText[this.getAttribute('index')].txt;
			}
		};
	}
};

function ValidateFooterContactForm(){
			if (document.getElementById("FCFFirstName").value == document.getElementById("FCFFirstName").defaultValue){
	        	alert("בבקשה הזן/ני את שמך הפרטי.");
	        	document.getElementById("FCFFirstName").focus();
	        	return false;
			}
			if (document.getElementById("FCFLastName").value == document.getElementById("FCFLastName").defaultValue){
	        	alert("בבקשה הזן/ני את שם משפחתך.");
	        	document.getElementById("FCFLastName").focus();
	        	return false;
			}
			if (!isEmail(document.getElementById("FCFEmail"))){
		        	alert("בבקשה הזן/ני כתובת דואר אלקטרוני תקינה");
		        	document.getElementById("FCFEmail").focus();
		        	return false;
			}
			if (document.getElementById("FCFPhone").value == document.getElementById("FCFPhone").defaultValue){
	        	alert("בבקשה הזן/ני מספר טלפון.");
	        	document.getElementById("FCFPhone").focus();
	        	return false;
			}
			if (document.getElementById("FCFMassage").value == document.getElementById("FCFMassage").defaultValue){
	        	alert("בבקשה הזן/ני את הודעתך.");
	        	document.getElementById("FCFMassage").focus();
	        	return false;
			}
			return true;
		}

function ValidateFooterNewsletterForm(){
			if (document.getElementById("FNFFirstName").value == document.getElementById("FNFFirstName").defaultValue){
	        	alert("בבקשה הזן/ני את שמך הפרטי.");
	        	document.getElementById("FNFFirstName").focus();
	        	return false;
			}
			if (document.getElementById("FNFLastName").value == document.getElementById("FNFLastName").defaultValue){
	        	alert("בבקשה הזן/ני את שם משפחתך.");
	        	document.getElementById("FNFLastName").focus();
	        	return false;
			}
			if (!isEmail(document.getElementById("FNFEmail"))){
		        	alert("בבקשה הזן/ני כתובת דואר אלקטרוני תקינה");
		        	document.getElementById("FNFEmail").focus();
		        	return false;
			}
	return true;
}
