// TODO: move fns as to not pollute global namespace
$ = $ || jQuery;

    var isNotEmpty = function (e) {
            var $el = $(this),
                str = $.trim($el.val());

            if (str.length === 0) {
                $el.css('border-color', 'red');

                if ($el.prev('div.error').length === 0) {
                    $el.before('<div class="error" style="color: red;">This is a required field</div>');
                }
                return false;
            }

            $el.css('border-color', '#ddd');
            $el.prev('div.error').remove();
            return true;
        },
        isEmail = function (e) {
            var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,
                $el = $(this),
                str = $el.val();

            if (regex.test(str) === false) {
                $el.css('border-color', 'red');

                if ($el.prev('div.error').length === 0) {
                    $el.before('<div class="error" style="color: red;">A valid email is required (ex. name@domain.com)</div>');
                }
                return false;
            }

            $el.css('border-color', '#ddd');
            $el.prev('div.error').remove();
            return true;
    },
        isChecked = function () {
            var $el = $(this);

            if ($el.is(':checked') === false) {
                $el.css('border-color', 'red');

                if ($el.prev('div.error').length === 0) {
                    $el.before('<div class="error" style="color: red;">This is a required field</div>');
                }
                return false;

            }

            $el.css('border-color', '#ddd');
            $el.prev('div.error').remove();
            return true;
        };

function selectElement(shID) {
    var oldOption =  $("#inquiry_list li.selected");

    
    oldOption.removeClass('selected');

    if (shID == 'sales_inquiry_form') {
        $("#inquiry_type").val('sales');
	document.getElementById(shID).style.display = 'inline';
	$("#sales_anchor").addClass('selected');
	document.getElementById('exec_inquiry_form').style.display = 'none';
	document.getElementById('press_inquiry_form').style.display = 'none';
	document.getElementById('hr_inquiry_form').style.display = 'none';
    }
    else if (shID == 'exec_inquiry_form') {
        $("#inquiry_type").val('executive');
	document.getElementById(shID).style.display = 'inline';
	$("#exec_anchor").addClass('selected');
	document.getElementById('sales_inquiry_form').style.display = 'none';
	document.getElementById('press_inquiry_form').style.display = 'none';
	document.getElementById('hr_inquiry_form').style.display = 'none';
    }
    else if (shID == 'press_inquiry_form') {
        $("#inquiry_type").val('press');
	document.getElementById(shID).style.display = 'inline';
	$("#press_anchor").addClass('selected');
	document.getElementById('sales_inquiry_form').style.display = 'none';
	document.getElementById('exec_inquiry_form').style.display = 'none';
	document.getElementById('hr_inquiry_form').style.display = 'none';
    }
    else if (shID == 'hr_inquiry_form') {
        $("#inquiry_type").val('human_resources');
	document.getElementById(shID).style.display = 'inline';
	$("#hr_anchor").addClass('selected');
	document.getElementById('sales_inquiry_form').style.display = 'none';
	document.getElementById('exec_inquiry_form').style.display = 'none';
	document.getElementById('press_inquiry_form').style.display = 'none';
    }

/*     document.getElementById('recaptcha').style.display = ''; */
    document.getElementById('submit_button').style.display = 'inline';
/*     document.getElementById('your_info_header').style.display = 'inline'; */
    document.getElementById('thank_you').style.display = 'none';
  }


function mousePosition(){

function doSomething(e) {
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
}
}


function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
} 

function prefillFooterEmail () {
document.getElementById("cc_email").value = 'enter email address' ;
}


function showTooltip(id) {

/*
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
*/

document.getElementById(id).style.display = "block" ;

/*
posx=posx - 250;
posy=posy - 90;

var leftPos = posx + "px";
var topPos = posy + "px";
document.getElementById(id).style.left = leftPos ;
document.getElementById(id).style.top =  topPos ;
*/

}

function hideTooltip(id) {
document.getElementById(id).style.display = "none" ;
}
