var MCInlineSearch = {
	Version			: 1.0,
	form			: null,
	observer		: null,
	results			: null,
	
	initialize: function(){
		var upload_path = '/bin/search/';
		
		// local testing
	/*	if (String(window.location).match(/localhost/))
			{
			upload_path = '/mec/bin/search/';
			}*/
			
		MCInlineSearch.results = $('search_results');	
		MCInlineSearch.results.hide();

	/*	
		style test
			new Ajax.Updater(MCInlineSearch.results, 	upload_path+'search.cgi', {
								parameters: { q: 'wedding' }  });
			*/
			
			
		new Form.Element.Observer(
			  'search_field',
			  1.5,  // every 2 secs
			  function(element, value){
				if (value && value.length > 1 && value != 'Search site') // placeholder value
					{
					if (!MCInlineSearch.results.visible())
						{
						//MCInlineSearch.results.show();
						new Effect.Appear(MCInlineSearch.results, {from:0, duration : 1.0});	
						}
						
					
					// show the search results div
					new Ajax.Updater(MCInlineSearch.results, 	upload_path+'search.cgi', {
									parameters: { q: value, type: 'partial'}  });	
					}
				else
					{
					// clear the search results div
					new Effect.Fade(MCInlineSearch.results, { duration : 0.5});
					
				/*	setTimeout(function(){
						MCInlineSearch.results.innerHTML = "<p>No results</p>";
					},3000);*/
					
					}
			
			  }
			)	

	}
		
			
};

Event.observe(window,'load',MCInlineSearch.initialize,false);

