google.load('jquery', '1.3.2');
google.load('search', '1');
google.setOnLoadCallback(function() {
	// for search layer
	var layer = document.createElement('div');
	layer.id = 'layer';
	document.body.appendChild(layer);
	// for search
	var searchControl = new google.search.SearchControl();
	var options = new google.search.DrawOptions();
	options.setSearchFormRoot(document.getElementById("search-form"));
	var restriction = ['palito.blog79.fc2.com', 'palito.jp'];
	for (var i = 0, len = restriction.length; i < len; i++) {
		var siteSearch = new google.search.WebSearch();
		siteSearch.setSiteRestriction(restriction[i]);
		var so = new google.search.SearcherOptions();
		so.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
		if (i == 0) so.setRoot(document.getElementById('blog-results'));
		else if (i == 1) so.setRoot(document.getElementById('palito-results'));
		searchControl.addSearcher(siteSearch, so);
	}
	searchControl.setSearchCompleteCallback(null, function() {
		$('#layer')
			.css('opacity', 0.5)
			.css('width', $(window).width() + 'px')
			.css('height', $(document).height() + 'px')
			.show('slow');
		$('#search-results')
			.css('opacity', 0.9)
			.show('slow');
	});
	searchControl.draw(document.getElementById("search-form-dummy"), options);
	$('#search-close-button').click(function() {
		$('#layer').hide('slow');
		$('#search-results').hide('slow');
	});
	$('#layer').click(function() {
		$('#layer').hide('slow');
		$('#search-results').hide('slow');
	});
});


