﻿// JavaScript Document

function doSiteSearch( sender )
{
	var f = document.formSearch;
	var targ = "search_frame";
	var sif = document.getElementById( targ );

	if( !f.q || ( f.q.value == "" ) ) return false;
	if( !sif ) return false;

	sif.style.width = "675px";
	sif.style.height = "375px";
	
	showSearch();
	f.target = targ;
	f.submit();
}

function showSearch()
{
	showPicPanel( "searchpicpanel", "searchbd" );
}

function showPicPanel( thePanel, theBody )
{
	// Setup constants
	// QUIRKS FLAG, FOR BOX MODEL
	var IE_QUIRKS = (YAHOO.env.ua.ie && document.compatMode == "BackCompat");
	// UNDERLAY/IFRAME SYNC REQUIRED
	var IE_SYNC = (YAHOO.env.ua.ie == 6 || (YAHOO.env.ua.ie == 7 && IE_QUIRKS));
	// PADDING USED FOR BODY ELEMENT
	var PANEL_BODY_PADDING = (10*2) // 10px top/bottom padding applied to Panel body element. The top/bottom border width is 0

	var b = document.getElementById( theBody );
	b.style.height = "400px";

	// Initialize the temporary Panel to display while waiting for external content to load
	var panel = 
			new YAHOO.widget.Panel( thePanel,  
										{ width: "700px",
										  fixedcenter: true,
										  underlay: "shadow",
										  draggable: true,
										  close: true
										} 
	);
	panel.render();

	// Create Resize instance, binding it to the 'picpanel' DIV 
	var resize = new YAHOO.util.Resize( thePanel,
		{
			handles: ['br'],
			autoRatio: false,
			minWidth: 300,
			minHeight: 100,
			status: true
		}
	);

	// Setup resize handler to update the size of the Panel's body element
	// whenever the size of the 'resizablepanel' DIV changes
	resize.on( 'resize', function( args )
		{
			var panelHeight = args.height;

			var headerHeight = this.header.offsetHeight; // Content + Padding + Border
			var footerHeight = this.footer.offsetHeight; // Content + Padding + Border

			var bodyHeight = (panelHeight - headerHeight - footerHeight);
			var bodyContentHeight = (IE_QUIRKS) ? bodyHeight : bodyHeight - PANEL_BODY_PADDING;

			YAHOO.util.Dom.setStyle( this.body, 'height', bodyContentHeight + 'px' );

			if( IE_SYNC )
			{
				// Keep the underlay and iframe size in sync.
				this.sizeUnderlay();

				// Syncing the iframe can be expensive. Disable iframe if you don't need it.
				this.syncIframe();
			}
		}, panel, true
	);

	// Show the Panel
	panel.show();
	panel.center();
}
