
// JavaScript Document


function loginFormJSHandling()
{
    $('.jNiceInputInner .psw').before('<span class="hidden">Passwort</span>');
    $('.jNiceInput').focus( function() {
        /*psw*/
        if ($(this).hasClass('psw')) {
            valueInpP = $(this).attr('value');
            $(this).attr('value','');
            $('.login span.hidden').css({
                display: 'none'
            });
            $('.login input.psw').css({
                paddingTop: '0',
                height: '14px',
                color: '#355A2B'
            });
        }
        /*input*/
        else {
            valueInp = $(this).attr('value');
            $(this).attr('value','');
            $(this).blur( function() {
                if ($(this).attr('value') == '') {
                    $(this).attr('value',valueInp);
                }
            });
        }
    });
    $('.psw').blur( function() {
        if ($(this).attr('value') == '') {
            $(this).attr('value',valueInpP);
            $('.login span.hidden').css({
                display: 'block'
            });
            $('.login input.psw').css({
                paddingTop: '5px',
                height: '9px',
                color: '#FFFFFF'
            });
        }
    });
}


/*  ListArticles  */
$(document).ready( function() {
       loginFormJSHandling();
       
       /*HideShow-ArtCont*/
       $('.articlesCont .box').hover(
		    function () {
		    	$(this).addClass('boxHover');
		        $(this).find('.openClose').click(function(){
		        	if(!$(this).parents('.box').hasClass('boxActive'))
		        	{
		        		$('.articlesCont .box').each(function(){
			        		$(this).find('p').hide('slow');
			        		$(this).removeClass('boxActive');
					    	$(this).find('.openClose').css({
					    		opacity: '1',
					    		cursor: 'pointer'
					    	});
		        		});
		        		$(this).parents('.box').find('p').show('slow');
				    	$(this).parents('.box').addClass('boxActive');
				    	$(this).parents('.box').find('.openClose').css({
				    		opacity: '0.3',
				    		cursor: 'default'
				    	});
		        	}
		        });
		    }, 
			function () {
		    	$(this).removeClass('boxHover');
			}
		);
	   
        
       
       	/*Link CME*/
       var url = '/page/Fortbildung_CME_/136';
       $('.specialCME').click(function(){
    	   self.location='http://'+location.host+url;
       });
        var url = '/page/142';
       $('.specialNews').click(function(){
    	   self.location='http://'+location.host+url;
       });
       $('.specialAktAusg').click(function(){
           $('#piazfa').submit();
       });
       
       $('.specialQuest').click(function(){
           $('#piazfaQuest').submit();
       });
	   
	   /*Close Open Category*/
       $('a.closeCat').click(function(){
    	   var catId = $(this).parent('h6').attr('class');
    	   $(this).css('display','none');
    	   $(this).parent('h6').find('.openCat').css('display','block');
    	   $('.box'+catId).hide(200);
       });
       $('a.openCat').click(function(){
    	   var catId = $(this).parent('h6').attr('class');
    	   $(this).css('display','none');
    	   $(this).parent('h6').find('.closeCat').css('display','block');
    	   $('.box'+catId).show(200);
       });
       

       /*Overlay*/
       $('a.layerYear').overlay({effect: 'apple'});
       

       /*Carousel Ausgaben*/
       if($('.smallCoversList li').length > '6')
       {
           $("#carousel").jCarouselLite({
               btnNext: ".next",
               btnPrev: ".prev",
               scroll: 6
           });
       }
       else
       {
           $('.IssueList .prev').css('display','none');
           $('.IssueList .next').css('display','none');
       }

       /*DropDown*/
       $('.filterPullDown').hover(
    		function(){
    			$('.filterPullDown ul').show(1);
    		},
    		function(){
    			$('.filterPullDown ul').hide(1);
    		}
       );
       
	/*  Footer Bottom  */ /*Leave me at the end*/
	footerbottom();
	$(window).resize( function() {
		footerbottom();				
	});
});
/*  ListArticles  */
$(document).ready( function() {
       loginFormJSHandling();
       
       /*HideShow-ArtCont*/
       $('.bigTextBox .box').hover(
		    function () {
		    	$(this).find('a.buttonStyled').css('visibility','visible');
		    	$(this).css('background','#e5e8e2');
		        $(this).find('.openClose').mouseover(function(){
		        	$(this).parents('.box').find('p').show(200)
		        });
		    }, 
			function () {
		    	$(this).find('a.buttonStyled').css('visibility','hidden');
		    	$(this).css('background','none');
	        	$(this).find('p').hide(100)
			}
		);


	
});
/*  ListArticles  */
$(document).ready( function() {
       loginFormJSHandling();
       
       /*HideShow-ArtCont*/
       $('.sucheCont').hover(
		    function () {
		    	$(this).find('a.buttonStyled').css('visibility','visible');
		    	$(this).css('background','#e5e8e2');
		        $(this).find('.openClose').mouseover(function(){
		        	$(this).parents('.textHolder').find('p').show(200)
		        });
		    }, 
			function () {
		    	$(this).find('a.buttonStyled').css('visibility','hidden');
		    	$(this).css('background','none');
	        	$(this).find('p').hide(100)
			}
		);


	
});

/*Navigation*/
$(function(){
        $('.naviHauptnavigation').superfish({
                delay: 500,
                autoArrows: false,
                dropShadows: false
        });
});

function footerbottom() {
	if($('#cmsEditor').length == 0)
	{
		var heightPage = $('#page').attr('clientHeight');
		var heightContent = $('#content').attr('clientHeight');
		var heightHtml = $('html').attr('clientHeight');
		if ( heightPage < heightHtml) {
			$('#content').attr('style','min-height:'+(heightHtml-(heightPage-heightContent+1))+'px');
		}
		else {
			$('#content').removeAttr('style');
			var heightPage = $('#page').attr('clientHeight');
			var heightContent = $('#content').attr('clientHeight');
			var heightHtml = $('html').attr('clientHeight');
			if ( heightPage < heightHtml) {
				$('#content').attr('style','min-height:'+(heightHtml-(heightPage-heightContent+1))+'px');
			}
		}
	}
	else
	{
		var heightPage = $('#page').attr('clientHeight');
		var heightContent = $('#content').attr('clientHeight');
		var heightHtml = ($('html').attr('clientHeight')-70);
		if ( heightPage < heightHtml) {
			$('#content').attr('style','min-height:'+(heightHtml-(heightPage-heightContent+1))+'px');
		}
		else {
			$('#content').removeAttr('style');
			var heightPage = $('#page').attr('clientHeight');
			var heightContent = $('#content').attr('clientHeight');
			var heightHtml = ($('html').attr('clientHeight')-70);
			if ( heightPage < heightHtml) {
				$('#content').attr('style','min-height:'+(heightHtml-(heightPage-heightContent+1))+'px');
			}
		}
	}
}
/****browse button style****/
(function($) {
    
    $.fn.filestyle = function(options) {
                
        /* TODO: This should not override CSS. */
        var settings = {
            width : 250
        };
                
        if(options) {
            $.extend(settings, options);
        };
                        
        return this.each(function() {
            
            var self = this;
            var wrapper = $("<div>")
                            .css({
                                "width": settings.imagewidth + "px",
                                "height": settings.imageheight + "px",
                                "background": "url(" + settings.image + ") 0 0 no-repeat",
                                "background-position": "right",
                                "display": "inline",
                                "position": "absolute",
                                "overflow": "hidden"
                            });
                            
            var filename = $('<input class="file">')
                             .addClass($(self).attr("class"))
                             .css({
                                 "display": "inline",
                                 "width": settings.width + "px"
                             });

            $(self).before(filename);
            $(self).wrap(wrapper);

            $(self).css({
                        "position": "relative",
                        "height": settings.imageheight + "px",
                        "width": settings.width + "px",
                        "display": "inline",
                        "cursor": "pointer",
                        "opacity": "0.0"
                    });

            if ($.browser.mozilla) {
                if (/Win/.test(navigator.platform)) {
                    $(self).css("margin-left", "-142px");                    
                } else {
                    $(self).css("margin-left", "-168px");                    
                };
            } else {
                $(self).css("margin-left", settings.imagewidth - settings.width + "px");                
            };

            $(self).bind("change", function() {
                filename.val($(self).val());
            });
      
        });
        

    };
	
    
})(jQuery);

   
