// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults


//show error messages for textareas (or fields) that get too long
var is_msg_warning = [];
function showMessage(element_name, length, max_length)
{
    if (length >= max_length) {
        $(element_name).innerHTML = '<br>Warning, you have typed ' + length + ' of the allowed '+max_length+' total characters.';
        is_msg_warning[element_name] = true;
    } else if (is_msg_warning[element_name] && length <= 50) { 
        $('msg_size').innerHTML = ''; 
        is_msg_warning[element_name] = false;
    }
}


function show(id) {
	var style2 = document.getElementById(id).style;
	style2.display = "block"
}
function hide(id) {
	var style2 = document.getElementById(id).style;
	style2.display = "none"
}

function toggleLayer(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
}


function agree(id) {
    //alert('agree?'+document.getElementById('agree').checked);
    return (document.getElementById(id).checked);
}

function submitAgreement(agreementid, hideButton, appearText) {
    if (agree(agreementid)) {
        hide(hideButton); 
        Effect.Appear(appearText);
    } else {
        return false;
    }
}