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

window.onload = init;

function init( ) {
	check_for_javascript_support( );
	check_for_cookie_support( );
}

function check_for_javascript_support( ) {
	// looks for a div on each page called javascript_warning which will be shown by default
	js_warn = document.getElementById( "javascript_warning" );
	if( js_warn != null ) {
		// if the javascript_warning div is found, hide it indicating javascript support
		js_warn.style.display = "none";
	} 
}

function check_for_cookie_support( ) {
	if( ! cookie_test( ) ) {
		c_warn = document.getElementById( "cookie_warning" );
		c_warn.style.display = "block";
	}
}

function hide_submit_button(  ) {
	$('submit_button').style.display = 'none';
	$('waiting').style.display = "block";
}

function focus_field( field, text ) {
	if( field.value == text ) {
		field.value = "";
	}
}

function blur_field( field, text ) {
	if( field.value == "" ) {
		field.value = text;
	}
}

function cookie_test( ) {
	var expires = new Date( );
	expires.setSeconds( expires.getSeconds( ) - 1 );
	document.cookie = "cookies_enabled2345=true";
	if( document.cookie.indexOf( "cookies_enabled2345=true" ) != -1 ) {
		document.cookie = "cookies_enabled2345=true; " + expires.toUTCString( );
		return true;
	} else {
		return false;
	}
}
