//Namespace
if(typeof PM == 'undefined') {
    PM = {};
}

$(document).ready(function(){


	$("#login-selector").click(function() {
		var visibility = $('#login-box-container').css("display");
		if(visibility == 'none') {
			$("#login-box-container").show("slow");   
		} else {
			$("#login-box-container").hide("slow");
		}
		return false;
	});
    
    
    	var num_li = $(".fce-navbox-link li").length;
	
   	for(var i = 0; i < num_li; i++) {
		$(".fce-navbox-link li:eq("+i+")").attr("id", 'fce-navbox-link-tab-'+i);
		$(".fce-navbox .fce-navbox-content:eq("+i+")").attr("id", 'fce-navbox-content-'+i);
		if(i > 0) {
			$('#fce-navbox-content-'+i).hide();
		}
		if(i == 0) {
			$('#fce-navbox-link-tab-'+i).addClass('cur');	
		}
	}
	
	$('.fce-navbox-link a').click(function() {
		$('.fce-navbox-link li').removeClass('cur');
		$('.fce-navbox-content').hide();
			
		var id = $(this).parent("li").attr("id").replace('fce-navbox-link-tab-', '');
		$("#fce-navbox-content-"+ id).fadeIn('slow');
		$('#fce-navbox-link-tab-'+ id).addClass('cur');
		
		return false;
		})

	$('.fce-navbox-text > div h1:first').show();
	$('.fce-navbox-text > div .news-latest-morelink:first').show();
	$('.fce-navbox-image > .news-latest-image:first').show();
	
	$('.news-latest-teaser').bind("mouseenter", function(){
		var id = $(this).attr("id").replace('news-teaser-', '');
		
		$('.fce-navbox-text .news-latest-teaser h1').hide();
		$('.fce-navbox-text .news-latest-morelink').hide();
		$('.fce-navbox-image .news-latest-image').hide();
			
		$('#news-teaser-'+id+' h1').show();
		$('#news-teaser-'+id+' .news-latest-morelink').show();
		$('#latest-image-'+id).show();
	});

		$('#accordion').accordion({
			autoheight: false,
		    navigation: true, 
			active: false,
			header: '.pmscrecipedd-filter-head'
		});
		
		
		
		

		$("body").prepend('<div id="dialog_adventskalender" />');
		 $("#dialog_adventskalender").dialog({
		     autoOpen : false,
		     dialogClass : "sc_dialog_adventskalender",
		     resizable : false,
		     draggable : true,
		     position: 'top',
		     width: "555px",
		     height: "500px",
		     modal: true,
		     overlay: {
		       backgroundColor : "#000000",
		       opacity : 0.5
		     }
		   });
		
		 $('.ui-resizable-w, .ui-resizable-n, .ui-resizable-nw, .ui-resizable-ne,\n\
		     .ui-resizable-e, .ui-resizable-es, .ui-resizable-s, .ui-resizable-sw').remove();

			$('.fce-adv-calendar-link').bind('click',function () {
			
				$.ajax({
		     		type: "GET",
		     		url: $(this).attr('href'),
		     		success: function(html) {
		       			$('#dialog_adventskalender').empty().html(html);
		       			$('#dialog_adventskalender').dialog('open');
		     		}
		   		});
		   		
	       			
				return false; 
			});
		
    var default_search_val = '';
 $('#search .search-word').bind('focus', function() {
   default_search_val = $(this).val();
   $(this).val('');
 }).bind('blur', function() {
   $(this).val(default_search_val);
 })
});
