function test(opt_msg) {
  if (!opt_msg) {
    opt_msg = 'Poop!';
  }
  alert(opt_msg);
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

var RecaptchaOptions = {
   theme : 'custom',
   custom_theme_widget: 'recaptcha_widget'
};

leftPos = 0;
topPos = document.documentElement.scrollTop;
if (screen) {
  leftPos = (screen.width / 2) - 251
  topPos = (screen.height / 2) - 162
}

var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function JSFX_FloatDiv(id, sx, sy)
{
    var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
    var px = document.layers ? "" : "px";
    window[id + "_obj"] = el;
    if(d.layers)el.style=el;
    el.cx = el.sx = sx;el.cy = el.sy = sy;
    el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};

    el.floatIt=function()
    {
	    var pX, pY;
	    pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
	    document.documentElement && document.documentElement.clientWidth ? 
	    document.documentElement.clientWidth : document.body.clientWidth;
	    pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
	    document.documentElement.scrollTop : document.body.scrollTop;
	    if(this.sy<0) 
	    pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
	    document.documentElement.clientHeight : document.body.clientHeight;
	    this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;
	    this.sP(this.cx, this.cy);
	    setTimeout(this.id + "_obj.floatIt()", 40);
    }
    return el;
}

function go_to_free_estimate() {
  document.location.href = '#free_estimate';
  document.getElementById('tell-me-more-name').focus();
}

function validateTellMeMore() {
	var fm = document.getElementById('tell-me-more-form');
	var nf = document.getElementById('tell-me-more-name');
	var ef = document.getElementById('tell-me-more-email');
	var af = document.getElementById('tell-me-more-address');
	var cf = document.getElementById('tell-me-more-city');
	var sf = document.getElementById('tell-me-more-state');
	var zf = document.getElementById('tell-me-more-zipcode');
	var how_did_you_hear = document.getElementById('tell-me-more-how_did_you_hear');
	//var tf = document.getElementById('tell-me-more-topic');
	var er_msg = '';
	var er = 0;
	// Name Validation
	if (nf.value.trim() == '') {
		er = 1;
		er_msg += 'Please fill in your name\n\r';
		//alert('Please fill in your name');
	}
	// Street Address Validation
	if (af.value.trim() == '') {
		er = 1;
		er_msg += 'Please fill in your address\n\r';
		//alert('Please fill in your name');
	}
	// City Validation
	if (cf.value.trim() == '') {
		er = 1;
		er_msg += 'Please fill in your city\n\r';
		//alert('Please fill in your name');
	}
	// State Validation
	if (sf.value.trim() == '') {
		er = 1;
		er_msg += 'Please fill in your state\n\r';
		//alert('Please fill in your name');
	}
	// Zipcode Validation
	if (zf.value.trim() == '') {
		er = 1;
		er_msg += 'Please fill in your zip code\n\r';
		//alert('Please fill in your name');
	}
	// Email Validation
	if (ef.value.trim() == '') {
		er = 1;
		//alert('Please fill in your email address');
		er_msg += 'Please fill in your email address\n\r';
	} else if (ef.value.indexOf('@') < 0 || ef.value.indexOf('.') < 0 || ef.value.length < 5) {
		er = 1;
		//alert('Please enter a valid email address');
		er_msg += 'Please enter a valid email address\n\r';
	}

	if (how_did_you_hear) {
	  if (how_did_you_hear.value.trim() == '--') {
	    er = 1;
	    er_msg += 'Please tell us how you how you heard about us\n\r';
	  }
	}

	// Topic Selection
	//if (tf.options[tf.selectedIndex].value == '') {
	//	er = 1;
	//	alert('Please select a topic');
	//}
	// If no errors, submit the form!
	if (er == 0) {
		fm.submit();
	}
	else {
	  alert(er_msg);
	}
}
