$(document).ready(function(){
	$("#yla_navi_haku").autocomplete("yla_navi_autocomplete.php",{
		minChars:1,	max:20,
		formatItem: function(data,i,n,value){
			if(value.indexOf('/')>0)return '<img align="absmiddle" src="jquery/pikkumokki.gif" border="0"> <font style="color:green;font-weight:bold;">'+value.split('/')[1]+'</font>';
			else					return value;
		},
		formatResult: function(data,value){ return (value.indexOf('/')!=-1) ? value.split('/')[1] : value; }		 
	}).result(function(event, data, formatted){ if(formatted.indexOf('/')!=-1) document.location = 'http://www.mokkihaku.fi/'+formatted+'/esittely'; });
	
	$('#mokki_kuva').hover(function(){
		var bigimg2 = new Image();
		bigimg2.src = 'mokki_kuvat/original/'+$(this).attr("src").split('/')[1];
		test = bigimg2.width;
	},function(){});
	
	$('#mokki_kuva').click(function(){
		var bigimg2 = new Image();
		bigimg2.src = 'mokki_kuvat/original/'+$(this).attr("src").split('/')[1];
		test = bigimg2.width;				
		if ( test > 0 ) $(this).prev().trigger('click');							
	});
	
	$('a[rel*=facebox]').facebox();
		
	$('.custom_tooltip').tooltip({
		track: false,
		delay: 0,
		showURL: false,
		showBody: " - ",
		extraClass: "pretty",
		fixPNG: true,
		left: 0,
		top:0		
	});
	
	$('#a_pvm,#l_pvm,#a_a_pvm,#a_l_pvm').datepicker({showWeeks:true});
    $('#a_pvm,#l_pvm,#a_a_pvm,#a_l_pvm').datepicker($.datepicker.regional['fi']);
    
    $("#a_a_pvm").change(function(){
        $("#a_l_pvm").val($("#a_a_pvm").val()); 
    });

    $("#a_pvm").change(function(){
        $("#l_pvm").val($("#a_pvm").val()); 
    });
});
