// JavaScript Document
$(document).ready(function() {
	// Safely inject CSS3 and give the search results a shadow
	var cssObj = { 'box-shadow' : '#888 5px 10px 10px', // Added when CSS3 is standard
	'-webkit-box-shadow' : '#888 5px 10px 10px', // Safari
	'-moz-box-shadow' : '#888 5px 10px 10px'}; // Firefox 3.5+
	$("#suggestions").css(cssObj);
	
	// Fade out the suggestions box when not active
	$("input").blur(function(){
	$('#suggestions').fadeOut();
							 });
});

function WatermarkFocus(txtElem, strWatermark) 
{     
	if (txtElem.value == strWatermark) txtElem.value='';
}
function WatermarkBlur(txtElem, strWatermark) 
{     
	if (txtElem.value == '') txtElem.value=strWatermark;
}
function suggestionLookup(inputString, feedUrl) {
	if(inputString.length ==0) {
		$('#suggestions').fadeOut();
	} else {
		$.getFeed({
		   url: feedUrl + '?k=' + inputString,
		   success: function(feed) {
			  var html = '<p id="searchsuggestions">';
					  for(var i = 0; i < feed.items.length && i < 5; i++) {
						  var item = feed.items[i];
						  html += '<a href="'
						  + item.link
						  + '">'
						  + '<span class="searchheading">'
						  + item.title
						  + '</span>'
						  + '<span>'
						  + item.description
						  + '</span>'
						  + '</a>';
						  
						}
					  html += '</p>';
					  if (html != '<p id="searchsuggestions"></p>') {
					      $('#suggestions').html(html);
					      $('#suggestions').fadeIn();
					  }
		   }
		});
	}
}
