/*
CSS Browser Selector v0.4.0 (Nov 02, 2010)
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);
		

$(function(){
	
	// Slideshow
	if ($('#slideshow img').length > 1) {
		$('#slideshow').cycle({
			fx: 'fade'
		});
	}
	
	// Newsletter text value replacement
	$('.newsletter input.text')
		.blur(function() {
			if (jQuery.trim($(this).val()) == '') {
				$(this).val('Newsletter abonnieren');
			}
		})
		.focus(function() {
			$(this).val(($(this).val() == 'Newsletter abonnieren') ? '' : $(this).val());
		});
		
		
	// Newsletter text value replacement
	$('#stichwort')
		.blur(function() {
			if (jQuery.trim($(this).val()) == '') {
				$(this).val('Stichwortsuche');
			}
		})
		.focus(function() {
			$(this).val(($(this).val() == 'Stichwortsuche') ? '' : $(this).val());
		});
		
	// Newsletter text value replacement
	$('.kontakt #vorname')
		.blur(function() {
			if (jQuery.trim($(this).val()) == '') {
				$(this).val('Vorname*');
			}
		})
		.focus(function() {
			$(this).val(($(this).val() == 'Vorname*') ? '' : $(this).val());
		});
		
	// Newsletter text value replacement
	$('.kontakt #nachname')
		.blur(function() {
			if (jQuery.trim($(this).val()) == '') {
				$(this).val('Nachname*');
			}
		})
		.focus(function() {
			$(this).val(($(this).val() == 'Nachname*') ? '' : $(this).val());
		});
		
	// Newsletter text value replacement
	$('.kontakt #email')
		.blur(function() {
			if (jQuery.trim($(this).val()) == '') {
				$(this).val('E-Mail*');
			}
		})
		.focus(function() {
			$(this).val(($(this).val() == 'E-Mail*') ? '' : $(this).val());
		});
		
	/* navigation hover handle
		hides the active navigation if you hover over an other link with subnav
	*/
	$(".navigation > li:has(ul):not('.on')").hover(
		function () {
			$('.navigation > li.on ul').hide();
		},
		function () {
			$('.navigation > li.on ul').show();
		}
	);
	
	// Accordion 
	
	//Set default open/close settings
	$('.acc_container').hide();
	$('.acc_trigger:first').addClass('active').next().show(); 
 
	//On Click
	$('.acc_trigger').click(function(){

		$(this).toggleClass('active').next().slideToggle(); 
		that = this;
		$('.acc_trigger.active').each(function(){
			if (this != that) {
				$(this).removeClass('active').next().slideUp();
			}
		});
		
		return false;
	});
	
	
	if ($(".rezept #sidebar select").length) {
		$(".rezept #sidebar select").styleSelect({
			styleClass: "select"
		});
	}
	
	$(".rezept-detail .tabbed li").click(function(){
		if (!$(this).hasClass('on')) {
			$(".rezept-detail .tabbed li.on").removeClass('on');
			$(this).addClass('on');
			$(".rezept-detail .content").hide();
			$($(this).find('a').attr('href')).fadeIn();
		}
		return false;

	});
	
	$('.kontakt .disclaimer').click(function(){
		$($(this).attr('href')).show();
	});
	
	$('.kontakt #disclaimer').click(function(){
		$(this).hide();
	});
	
	$('#einkaufsliste_link').click(function(){

		$.ajax({
		  type: 'POST',
		  url: '/rezeptsuche/einkaufslisteajax',
		  data: 'id='+$('#einkaufsliste_link').attr('model_id'),
		  success: function(msg)
		  { 
			var v = eval("(" + msg + ")");
			$('#einkaufsliste_count').html(v.count); 
		  
			if(v.count < 1) 
			{
				if($('.buying-list a[href]'))
				{
					$('.buying-list a').attr('href_disabled', $('.buying-list a').attr('href')); 	
					$('.buying-list a').removeAttr('href');
				}
			
				$('.buying-list a').fadeTo(100, 0.4);
				$('.buying-list a').addClass('nounderline');
				
			}
			else
			{
				if($('.buying-list a[href_disabled]'))
				{
					$('.buying-list a').attr('href', $('.buying-list a').attr('href_disabled')); 	
					$('.buying-list a').removeAttr('href_disabled');
				}
			
				$('.buying-list a').fadeTo(100, 1);
				$('.buying-list a').removeClass('nounderline');
			}
			
			if(v.added == true)
				$('#einkaufsliste_link').html('wieder entfernen');
			else
				$('#einkaufsliste_link').html('auf die Einkaufsliste');
			
		  }
		}); 
		return false;
	});

	$('.rating_wrapper').mouseenter(function()
	{
		if($(this).children(".subrating").attr("rated") == 0)
		{
			$(this).children(".rating2").hide();
			$(this).children(".subrating").show();
		}
	});


	$('.rating_wrapper').mouseleave(function()
	{
		if($(this).children(".subrating").attr("rated") == 0)
		{
			$(this).children(".rating2").show();
			$(this).children(".subrating").hide();
		}
	}) 
	
	
	if ($('.product-choose')) {
		$(".product-choose input:not(:checked)").parent().find('label').addClass('inactive');

		$('.product-choose input[type="checkbox"]').each(function(){
			$(this).change(function(){
				$(this).parent().find('label').toggleClass('inactive');
			})
		})
	}
	
});

function ratebyid(id, val, url)
{
	$("#rating"+id+" .star-rating-control").rating("disable") ;
	$("#rating"+id).attr("rated", "1");
	$.ajax({
		type: "POST",
		url: url,
		data: "id="+id+"&rate=" + val
	});
}



$(document).ready(function() { 
    



    }); 






