$(document).ready(function(){
	
	//Animate special links in  header
	$('#header-links-special a').hover(function() {
		
		if($(this).css('bottom') == "0px"){
			$(this).animate({ "bottom": "40px"}, 150 );
		}
	}, function() {
		$(this).delay(500).animate({ "bottom": "0px"}, 150 );
	});
	
	/*$('.twitter-bird a#bell').hover(function() {
		if($('#footer a#tag').css('bottom') == "80px"){
			$('#footer a#tag').animate({ "bottom": "60px", "opacity" : '1'}, 150 );
		}
	}, function() {
		
		$('#footer a#tag').delay(2000).animate({ "bottom": "80px", "opacity" : '0'}, 150 );
		
	});*/
	
	$('#inside.menu').each(function(){
	
		$('.menu-list p').hover(function() {
			$('#hover-img').hide();
			$('#hover-img').css('top', -5000);
			var imgsrc = $(this).find('strong').text().replace(/[^\w]/gi, "-");
			imgsrc = imgsrc.replace(/-/gi, '').toLowerCase();
			$('#hover-img').attr('src', '/websites/goodstuffeatery/templates/gse/images/food/' + imgsrc + '.jpg');
			
			var pos = $(this).position();
			$('#hover-img').removeClass('ls rs');
			if(pos.left > 200){
				$('#hover-img').css('left', pos.left - 296);
				$('#hover-img').addClass('rs');
			} else {
				$('#hover-img').css('left', pos.left + 250);
				$('#hover-img').addClass('ls');
			}
			
				
			$('#hover-img').load(function(){	
				$('#hover-img').css('top', pos.top + 50);
				$('#hover-img').fadeIn('fast');				
			});
			
		}, function(){
			$('#hover-img').hide();
		});
	
	});
	
	$('.globalMenu li a[href="#"]').each(function(){
		$(this).attr('onclick','');
		var son = $(this).next().find('li:first a').attr('href');
		$(this).attr('href',son);
	});
	
	$('.split .photoGalleryElement').each(function(){
	
		$(this).after('<div id="pager"></div>');
		$('#pager').append('<div id="large"></div>');
		
		$(this).find('div.thumbTight img').each(function(){
			var imgsrc = $(this).attr('src');
			$('#pager').append('<a href="#"><img src="' + imgsrc.replace(/&m=150/gi, "&m=46") + '" /></a>');
		});
		
		activateSlide($('#pager a:first'));
		
	});
	
	$('#pager a').click(function(){
		activateSlide(this);
	});
	
	function activateSlide(slide) {
		var imgsrc = $(slide).find('img').attr('src');
		$('#pager a').removeClass('active');
		$(slide).addClass('active');
		$('#pager #large').css('background-image', 'url(' + imgsrc.replace(/&m=46/gi, "&m=300").replace(/&m=150/gi, "&m=300") + ')');
	}
	
	$('#element2672927_1035062').each(function(){
	
		$('select[name="field_80248_884327"] option').each(function(){
			$(this).text($(this).text().split(';')[0]);
		});
		
		$('input[name="field_80248_884328"]').val($('select[name="field_80248_884327"]').val().split(';')[1]);
		
		$('select[name="field_80248_884327"]').change(function(){
			var input = $('input[name="field_80248_884328"]');
			var data = $(this).val().split(';');
			$(input).val(data[1]);
		});
	
	});
	
	
});	
