
    // wait for the DOM to be loaded 
    $(document).ready(function() 
	{	var options = { 
        target:        '#output',   // target element(s) to be updated with server response 
        beforeSubmit:  validate,  // pre-submit callback 
        success:       showResponse,  // post-submit callback
		clearForm: true 
		}
		$('#myForm').ajaxForm(options);
		
		var options1 = { 
        target:        '#output1',   // target element(s) to be updated with server response 
        beforeSubmit:  validate,  // pre-submit callback 
        success:       showResponse,  // post-submit callback
		clearForm: true 
		}
		$('#myForm1').ajaxForm(options1);
		
		var path = location.pathname.substring(1);
		path = "/" + path;
		if (path) $('#sbm a[@href$="' + path + '"]').attr('class', 'current');
		$('div.botcontactform').hide();
		$('#contact').click(function(){
			$('div.hidediv').addClass("botcontactform").show("slow");
		});
		
    }); 
	
	$(function(){
	var spt = $('span.mailme');
	var at = / at /;
	var dot = / dot /g;
	var addr = $(spt).text().replace(at,"@").replace(dot,".");
	$(spt).after('<b><a href="mailto:'+addr+'" title="Send an email">'+ addr +'</a></b>').hover(function(){window.status="Send a letter!";}, function(){window.status="";});
	$(spt).remove();
	});

	$(function(){
	var spt = $('span.mailme1');
	var at = / at /;
	var dot = / dot /g;
	var addr = $(spt).text().replace(at,"@").replace(dot,".");
	$(spt).after('<a href="mailto:'+addr+'" title="Send an email">'+ addr +'</a>').hover(function(){window.status="Send a letter!";}, function(){window.status="";});
	$(spt).remove();
	});
	
	function showResponse(responseText, statusText)
	{	$('#waiting').hide();
		$('#waiting1').hide();
		//alert("Thank you! Your message has been emailed. We will get back to you.");
	}

	function validate(formData, jqForm, options) 
	{	var form = jqForm[0]; 
		if (form.fullNa.value=="")
		{	alert("Name cannot be blank. Please enter it.");
			form.fullNa.focus(); return false;
		}
	
		// Perform basic checks on email address
		if (form.fullEm.value != "")
		{	if ( (form.fullEm.value.indexOf('@') < 1)  ||
            	(form.fullEm.value.indexOf(' ') != -1) ||
             	(form.fullEm.value.indexOf('.') == form.fullEm.value.length -1)
           	)
			{ 	alert("Email address appears to be invalid. Please enter correct email address.");
           	form.fullEm.focus();
           	return false;
			}
		}
		else
		{	alert("Email address cannot be blank. Please enter it.");
			form.fullEm.focus(); return false;
		}		
	
		if (form.fullPh.value=="")
		{	alert("Phone number cannot be blank. Please enter it.");
			form.fullPh.focus(); return false;
		}
		
		if (form.fullSt.value=="")
		{	alert("State cannot be blank. Please enter it.");
			form.fullSt.focus(); return false;
		}
		
		if (form.fullCu.value=="")
		{	alert("Country cannot be blank. Please enter it.");
			form.fullCu.focus(); return false;
		}
		
		if (form.fullMe.value=="")
		{	alert("Message cannot be blank. Please enter it.");
			form.fullMe.focus(); return false;
		}
		
		if (form.wForm.value=="C") { $('#waiting1').show(); }
		if (form.wForm.value=="N") { $('#waiting').show(); }
		
		return true;
	}

function capitalizeMe(obj) {
        val = obj.value;
        newVal = '';
        val = val.split(' ');
        for(var c=0; c < val.length; c++) {
                newVal += val[c].substring(0,1).toUpperCase() +
val[c].substring(1,val[c].length) + ' ';
        }
        obj.value = newVal;
}
	