/**
 * Vigothek Javascript functions
 *
 * @author			Marcel Fahle
 * @version         0.5
 */

$(document).ready(function() { 
 
	
 
	$(".scrollable").scrollable({
		size:1,
		loop:true,
		speed: 500,
		clickable: false,
		circular: true,
		keyboard: false,
		next: '.nextPage',
		prev: '.prevPage'
	}).autoscroll({autoplay: true, interval:5000, autopause: true}).navigator();;
	
	 
		
	/*$(".search-area #browse").tooltip({
		tip: '#browsetip',
		lazy: true,
		position: "center right",
		offset : [90, 10],
		effect: 'slide',
		predelay: 1500
	
	});
	
	$(".search-area #search").tooltip({
		tip: '#searchtip',
		lazy: true,
		position: "center right",
		offset : [90, 50],
		effect: 'slide',
		predelay: 1500
	
	});*/
	
	// tooltip firefox hack!
	$('.form-holder #regions').each(function(index) {
		if(this.href) {
			$(this).data('href', this.href).removeAttr('href').addClass('link');
			$(this).click(function() {
				$(this).attr('href', $(this).data('href'));
			});
		}
	});
	$('.info a[title]').each(function(index) {
		if(this.href) {
			$(this).data('href', this.href).removeAttr('href').addClass('link');
			$(this).click(function() {
				$(this).attr('href', $(this).data('href'));
			});
		}
	});
	
	
	$(".info a[title]").tooltip({
		tip: '#infotip',
		position: "center right",
		offset : [47, 15],
		effect: 'slide'
	});
	
	$(".form-holder #regions").tooltip({
		tip: '#regionbox',
		lazy: true,
		position: "bottom right",
		offset : [14, -254],
		effect: 'slide',
		delay: 2000
		
	});
	
	/*
var options = {
		script:"php/inc/SuggestSearch.php?",
		varname:"queryString",
		json: true
		
	};
	var as = new AutoSuggest('searchbox', options);
*/
	

});

function lookup(inputString) {
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$('#suggestions').hide();
	} else {
		$.post("php/inc/SuggestSearch.php", {queryString: ""+inputString+""}, function(data){
			
			if(data.length >0) {

				$('#suggestions').show();
				$('#autoSuggestionsList').html(data);
			}
		});
	}
} // lookup
	
function fill(thisValue, id) {
	$('#searchbox').val(thisValue);
	$('#t').val(id);
	setTimeout("$('#suggestions').hide();", 200);
	setTimeout("$('form#sitesearch').submit();", 200);
}
