            function validateFormOnSubmit(theForm) {
                var reason = "";
                reason += validatePhone(theForm.Client_HomeNumber);
                reason += validateMobilePhone(theForm.Client_MobileNumber);
                reason += validateEmail(theForm.Client_Email);
                reason += validateEmpty(theForm.Client_Firstname);
				reason += validateCheckEmpty(theForm.Client_Homeowner); 

                if (reason != "") {
                    alert("Some fields need correction:\n\n" + reason);
                    return false;
                }

                return true;
            }

            function validateEmpty(fld) {
                var error = "";

                if (fld.value.length == 0) {
                    fld.style.background = 'Silver';
                    error = "Please enter a first name.\n"
                } else {
                    fld.style.background = 'White';
                }
                return error;
            }
			
 function validateCheckEmpty(fld) {
                var error = "";  

                if (!fld.checked )
				{
                    fld.style.background = 'Silver';
                    error = "Please accept Privacy Policy.\n"
                } else {
                    fld.style.background = 'White';
                }
                return error;
            }
			
			
			
            function trim(s) {
                return s.replace(/^\s+|\s+$/, '');
            }

            function validateEmail(fld) {
                var error = "";
                var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
                var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/;
                var illegalChars = /[\(\)\<\>\,\;\:\\\"\[\]]/;

                if (fld.value == "") {
                    fld.style.background = 'Silver';
                    error = "Please enter an email address.\n";
                } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
                    fld.style.background = 'Silver';
                    error = "Please enter a valid email address.\n";
                } else if (fld.value.match(illegalChars)) {
                    fld.style.background = 'Silver';
                    error = "The email address looks incorrect.\n";
                } else {
                    fld.style.background = 'White';
                }
                return error;
            }

            function validatePhone(fld) 
			{
                var error = "";
                var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');

                if (fld.value == "") {
                    error = "Please enter a phone number.\n";
                    fld.style.background = 'Silver';
                } 
				
				else if (isNaN(parseInt(stripped))) {
                    error = "The phone number looks incorrect.\n";
                    fld.style.background = 'Silver';
                } 
				
				else if ((stripped.length >= 13)) {
                    error = "The phone number is the wrong length. Please make sure you included an area code.\n";
                    fld.style.background = 'Silver';
                }
                return error;
            }



 function validateMobilePhone(fld) 
			{
                var error = "";
                var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');

                if (isNaN(stripped)) {
                    error = "The mobile number looks incorrect.\n";
                    fld.style.background = 'Silver';
                } 
							
				if (fld.value == "")
				{
					
				}else if ((stripped.length > 11) || (stripped.length < 11))
				{
                    error = "The mobile number is the wrong length.\n";
                    fld.style.background = 'Silver';
                }
				
						
                return error;
            }




var dhtmlgoodies_slideSpeed = 60;	// Higher value = faster
var dhtmlgoodies_timer = 10;	// Lower value = faster

var objectIdToSlideDown = false;
var dhtmlgoodies_activeId = false;
var dhtmlgoodies_slideInProgress = false;
function showHideContent(e,inputId)
{
	if(dhtmlgoodies_slideInProgress)return;
	dhtmlgoodies_slideInProgress = true;
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);

	objectIdToSlideDown = false;
	
	if(!answerDiv.style.display || answerDiv.style.display=='none'){		
		if(dhtmlgoodies_activeId &&  dhtmlgoodies_activeId!=numericId){			
			objectIdToSlideDown = numericId;
			slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1));
		}else{
			
			answerDiv.style.display='block';
			answerDiv.style.visibility = 'visible';
			
			slideContent(numericId,dhtmlgoodies_slideSpeed);
		}
	}else{
		slideContent(numericId,(dhtmlgoodies_slideSpeed*-1));
		dhtmlgoodies_activeId = false;
	}	
}

function slideContent(inputId,direction)
{
	
	var obj =document.getElementById('dhtmlgoodies_a' + inputId);
	var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId);
	height = obj.clientHeight;
	if(height==0)height = obj.offsetHeight;
	height = height + direction;
	rerunFunction = true;
	if(height>contentObj.offsetHeight){
		height = contentObj.offsetHeight;
		rerunFunction = false;
	}
	if(height<=1){
		height = 1;
		rerunFunction = false;
	}

	obj.style.height = height + 'px';
	var topPos = height - contentObj.offsetHeight;
	if(topPos>0)topPos=0;
	contentObj.style.top = topPos + 'px';
	if(rerunFunction){
		setTimeout('slideContent(' + inputId + ',' + direction + ')',dhtmlgoodies_timer);
	}else{
		if(height<=1){
			obj.style.display='none'; 
			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
				document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display='block';
				document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility='visible';
				slideContent(objectIdToSlideDown,dhtmlgoodies_slideSpeed);				
			}else{
				dhtmlgoodies_slideInProgress = false;
			}
		}else{
			dhtmlgoodies_activeId = inputId;
			dhtmlgoodies_slideInProgress = false;
		}
	}
}



function initShowHideDivs()
{
	var divs = document.getElementsByTagName('DIV');
	var divCounter = 1;
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='dhtmlgoodies_question'){
			divs[no].onclick = showHideContent;
			divs[no].id = 'dhtmlgoodies_q'+divCounter;
			var answer = divs[no].nextSibling;
			while(answer && answer.tagName!='DIV'){
				answer = answer.nextSibling;
			}
			answer.id = 'dhtmlgoodies_a'+divCounter;	
			contentDiv = answer.getElementsByTagName('DIV')[0];
			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; 	
			contentDiv.className='dhtmlgoodies_answer_content';
			contentDiv.id = 'dhtmlgoodies_ac' + divCounter;
			answer.style.display='none';
			answer.style.height='1px';
			divCounter++;
		}		
	}	
}

function openwindow()
{
	window.open("/privacy-policy.html","mywindow","menubar=0,resizable=0,scrollbars=1,width=450,height=750");
}


var tooltip=function(){
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();


