/************************* Search *********************/

function setupSearch(button, text){
var default_message = "Search";
	btn = document.getElementById(button);
	txt = document.getElementById(text);
	txt.value = default_message;

	txt.onclick = function(){
		if(this.value==default_message){
		this.value='';
		//this.style.color='red';
		}
	}

	btn.onclick = function(){
		txt = document.getElementById(text);  
		var val = trim(txt.value, ' ');
		if(val==default_message|val==""){
			alert("Please enter a search text");
			txt.value = '';
			txt.focus();
			return false;
		}
	}
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}  






/************************* Mouse hover image *********************/
$hs(function() {
    $hs('.rolloverbtn').hover(function() {
        $hs(this).attr('src', $hs(this).attr('src').toString().replace(".gif", "_h.gif"));
    }).mouseout(function() {
		$hs(this).attr('src', $hs(this).attr('src').toString().replace("_h.gif", ".gif"));
	});
});

/************************* Tab functionality *********************/
$hs(function(){
			var tabImg = $hs('div#homeBanner > div');
			tabImg.hide().filter(':first').show();
			
			$hs('div#homeBanner ul#tabBtn a').click(function () {
				tabImg.hide();
				tabImg.filter(this.hash).show();
				//tabImg.filter(this.hash).fadeIn( 'slow');
				$hs('div#homeBanner ul#tabBtn a').removeClass('on');
				$hs(this).addClass('on');
				return false;
			}).filter(':first').click();
});

$hs(function(){
			var tabList = $hs('#tabBox div.eachSection');
			var tabYear = $hs('#tabYear div.yearBox');
			tabList.hide().filter(':first').show();
			tabYear.hide().filter(':first').show();
			
			$hs('ul.tabList a').click(function () {
				tabList.hide();
				tabYear.hide();
				tabList.filter(this.hash).show();
				tabYear.filter(this.hash).show();
				$hs('ul.tabList a').removeClass('on');
				$hs(this).addClass('on');
				return false;
			}).filter(':first').click();
});


/************************* Tooltip functionality *********************/
$hs(function() {
	$hs('div.tooltip p').css('display', 'none');
	$hs('div.tooltip img').hover(function() {
			$hs(this).siblings("p:first").show();
		}).mouseout(function() {
			$hs(this).siblings("p:first").hide();
		});
	});
