
Event.observe( window, 'load', onload_webmasters_searchbox );

/*
var code_template = new Template('<div style="width: #{width}px; height: #{height}px; margin: 0; padding: 0; border: 0;">\n\
    <script type="text/javascript" src="http://dev.billiardsearch.net/extsb/js/searchbox.php.js?type=#{width}x#{height}&new_window=#{new_window}&focus=#{focus}"></script>\n\
    <noscript>\n\
        <a href="http://dev.billiardsearch.net/" target="_parent"><img src="http://dev.billiardsearch.net/extsb/images/#{width}x#{height}_searchbox_noscript.jpg" alt="BilliardSearch.net (dev)" style="border: 0 none;"/></a>\n\
    </noscript>\n\
</div>');
*/

function onload_webmasters_searchbox()
{
	update_searchboxes();

	$('sel-target').onchange = update_searchboxes;
	$('chk-focus').onchange = update_searchboxes;
}

function update_searchboxes()
{
	var new_window = ($F('sel-target') != '_parent') ? '1' : '0';
	var target = new_window === '1' ? '_blank' : '_parent';
	var focus = $F('chk-focus') ? '1' : '0';
//alert( 'size = ' + size + ', target = ' + target + ', focus = ' + focus );

	$$('textarea.code-js').each(
		function(el)
		{
			var aSize = el.id.replace( /^code-/, '' ).split( /x/ );
			var w = aSize[0];
			var h = aSize[1];
//alert('w = ' + w + ', h = ' + h);
//alert( 'target = ' + target );
			var hRepl = { width: w, height: h, new_window: new_window, focus: focus,
							domain: AWC_SITE_DOMAIN, target: target };

			var code = code_template.evaluate(hRepl);
//alert( 'code = ' + code );
			el.setValue(code);
		});

}




