var last = 0;
$(function(){
	$('td.menuitem').hover(function(){
		var id = $(this).attr('id');
		$('div#sub_'+id).show();
	},
	function(){
		var id = $(this).attr('id');
		setTimeout (function(){
			if(last != 'sub_'+id){
				$('div#sub_'+id).hide();
			}
		}
		,100, id);
	});
	
	$('td.menuitem_act').hover(function(){
		var id = $(this).attr('id');
		$('div#sub_'+id).show();
	},
	function(){
		var id = $(this).attr('id');
		setTimeout (function(){
			if(last != 'sub_'+id){
				$('div#sub_'+id).hide();
			}
		}
		,100, id);
	});

	$('div.submenu').hover(function(){
		var id = $(this).attr('id');
		last = id;
		//$('div#'+id).show();
	},
	function(){
		var id = $(this).attr('id');
		last = 0;
		$('div#'+id).hide();
	});
	

	$('img.moveleft').click(function(){
		nr--;
		arrowsImages(nr);
		return false;	
	});

	$('img.moveright').click(function(){
		nr++;
		arrowsImages(nr);
		return false;	
	});

	$('div.locationitem').hover(function(){
		$(this).children(':first-child').animate({'marginTop':'-55px'},300);
	},
	function(){
		$(this).children(':first-child').animate({'marginTop':'0px'},300);
	});

	$('div.slideritem').hover(function(){
		$(this).animate({
			marginTop: "150px"
		  }, 500);
	}); 

	$('div.slideritemover').hover('',function(){
		$(this).children(':first-child').animate({
			marginTop: "0px"
		},500);
	});
	arrowsImages(0);
	$('a.lightbox').lightBox({fixedNavigation:true});
	$('.fade').innerfade({
		speed: 'slow',
		timeout: 5000,
		type: 'sequence',
		containerheight: '300px'
	});
	$('.fader').innerfade({
		speed: 2500,
		timeout: 5000,
		type: 'sequence',
		containerheight: '420px'
	});
});

var max = 5;
var nr = 0;

function arrowsImages(nr){
	var t = $('div.slideritem').length;
	$("#slidercontent").animate({ "marginLeft": '-'+(nr*890)+'px' }, 300);
	if((nr >= 0) && ((t-max) > nr)){
		$('#right img').show();
	} else {
		$('#right img').hide();
	}

	if ((nr > 0)){
		$('#left img').show();
	} else {
		$('#left img').hide();
	}
}
