function gs_q_h_b_c( chkBt, id ) {
	chk = document.getElementById( chkBt );
	f = document.getElementById( id );
	if ( chk.checked ) {
		f.setAttribute( "target", "_blank" );

	} else {
		f.removeAttribute( "target" );
	}
}
function reset_all() {
	for ( i = 0; i < document.forms.length; ++ i ) {
		document.forms[i].reset();
	}
}
function one_to_rule_them_all() {
	rule = document.getElementById( "one-rule-all" );
	if ( rule.checked ) {
		gsq = document.getElementById( "gs-q" );
		ggsq = document.getElementById( "query-for-groups" );
		wiki = document.getElementById( "wiki" );
		imdb = document.getElementById( "imdb-q" );
		imdb.value = wiki.value = ggsq.value = gsq.value;
	}
}
function one_search() {
	rule = document.getElementById( "one-rule-all" );
	if ( rule.checked ) {
		document.forms["ggs_f"].submit();
		document.forms["searchform"].submit();
		document.forms["imdb"].submit();
	}
}
function handle_icons() {
	try {
		transform( document.body, handle_icon );
		var conf = get_cookie( "codestation-client-switch" );
		var services = [ "gs_f", "ggs_f", "searchform", "imdb" ];
		for ( var i in services ) {
			if ( conf[i] == '0' ) {
				minimize( services[i] );
			}
		}
	} catch ( e ) {
		add_note( "Exception: " + e );
	}
}
function switch_update_conf() {
	try {
		var conf = get_state( "window", "gs_f" ) + get_state( "window", "ggs_f" ) + get_state( "window", "searchform" ) + get_state( "window", "imdb" );
		set_cookie( "codestation-client-switch", conf );
	} catch ( e ) {
		add_note( "Exception: " + e );
	}
}

(function() {
	register_post_load_function( reset_all );
	register_post_load_function( handle_icons );
	register_conf_updater( "switch", switch_update_conf );
})(); 

