// JavaScript Document


$().ready(function() {
			$('.searchBox').click(
				function() {
					if (this.value == this.defaultValue) {
					this.value = '';
					}
				}
			);
			
			$('.searchBox').blur(
				function() {
					if (this.value == '') {
					this.value = this.defaultValue;
					}
				}
			);
			
			$("#searchStr").autocomplete("/ac.php", {
				width: 320,
				max: 30, 
				highlight: false,
				scroll: true,
				scrollHeight: 400,
				formatItem: function(data, i, n, value) {
					return "<img align='left' style='width:20px;height:40px;' src='" + data[2] + "'/>" + value.split(".")[0] + "<br /><em>" + data[3] +"</em>";
				},
				formatResult: function(data, value) {
					return value.split(".")[0];
				}
				/*width: 185,
				scroll: false,
				selectFirst: false*/
			});
			
			$("#searchStr").result(function(event, data, formatted) {
				if (data)
				window.location = "/?_a=viewCat&catId="+data[4]+"#"+data[1];
			});
				
				
			/* animate the scrolling */
			var id = window.location.hash.slice(1);
			if(id!=0) {
				$('html,body').animate({scrollTop: $('#id_'+ id).offset().top}, 2500);
			}
			
		

							
});	

