


jQuery(document).ready(function(){
    buildLoginBox();
    buildSearchBox();


    


    $('#loginFormDialog').dialog({
        autoOpen: false,
        width: 400,
        title: 'Login',
        buttons: {

            "Login": function() {

                var ajaxUrl = '/index.php?id=95&no_cache=1&type=96&'+decodeURIComponent($('#loginForm').serialize());
                $.ajax({
                    url: ajaxUrl,
                    dataType: 'xml',
                    success: function(data, textStatus, XMLHttpRequest){
                        var message = $(data).find('message').text();
                        if (message.search('success')>=0) {
                            $('#loginFormDialog').dialog("close");
                            location.reload();
                        }
                        else {
                            alert('Email-Adresse oder Passwort sind nicht korrekt. Bitte &uuml;berpr&uuml;fen Sie die Eingaben.');
                        }
                    },
                    error: function(jqXHR, textStatus, errorThrown) {
                        alert(errorThrown);
                    }
                });
                $(this).dialog("close");


            },
            "Cancel": function() {
                $(this).dialog("close");
            }
        },
        open: function()  {
            $(this).parent().find('.ui-dialog-buttonpane button:contains("Cancel")').button({
                icons: {
                    primary: 'ui-icon-locked'
                }
            });
            $(this).parent().find('.ui-dialog-buttonpane button:contains("Login")').button({
                icons: {
                    primary: 'ui-icon-unlocked'
                }
            });
        }


    });

    $('#loginButton, #loginButtonInContent').click(function(event){
        event.preventDefault();
        $('#loginFormDialog').dialog('open');
        return false;
    });


    $('#logoutDialog').dialog({
        autoOpen: false,
        width: 400,

        open: function()  {
            $('#logoutDialog').html('<p>Sie werden ausgeloggt...</p>');
            var ajaxUrl = location.href;
            $.ajax({
                url: ajaxUrl,
                dataType: 'html',
                data: {
                    logintype: 'logout',
                    pid: 50,
                    'tx_felogin_pi1[noredirect]': 0,
                    redirect_url: '/sie-wurden-ausgeloggt.html'
                },
                success: function(data, textStatus, XMLHttpRequest){
                    $('#logoutDialog').dialog('close');
                    location.href = '/sie-wurden-ausgeloggt.html';
                }
            });
        }
    });
    $('#logoutButton, #userInfo-logout').click(function(event){
        event.preventDefault();
        $('#logoutDialog').dialog('open');
        return false;
    });

    $('#captcha').bind('loaded.simpleCaptcha', function() {

        $('.captchaImages img').click(function() {
            $('.simpleCaptchaInput').val($(this).attr('title'));
            $(this).parents('form').submit();
        });
    })
    .simpleCaptcha({
        numImages: 8,
        introText: '<p>Zum Absenden klicken Sie bitte auf <strong class="captchaText"></strong></p>'
    });


    jQuery("textarea[class*=expand]").TextAreaExpander();
    // infinitescroll();

    //standards
    $('a').click(function(){
        this.blur();
    });
    $('a[href^="http://"]')
    .attr({
        target: "_blank",
        title: "öffnet in neuem Fenster"
    });
    /*
 *$('.magicBox').ahover({
 toggleSpeed: 75,
                toggleEffect: 'both',
                hoverEffect: null,
                moveSpeed: 250,
                easing: 'swing'
             ,   className: 'contentMouseOver'
    
});


*/
    /* ### img effect #### */
/*
    $(".thumb").insetBorder({
        inset: 10
    });
    */
    /* ########## tabs ############ */

    $('#tabsComments').tabs();

    /*#### buttons '*/


$( ".liRSS").button({
       text: true,
        icons: {

            primary: "ui-icon-signal-diag"
        }
    });
    $( ".liTwitter").button({
       text: true,
        icons: {

            primary: "ui-icon-social-twitter"
        }
    });
     $( ".liFacebook").button({
        text: true,
        icons: {

            primary: "ui-icon-social-facebook"
        }
    });
       $( ".liXing").button({
        text: true,
        icons: {

            primary: "ui-icon-social-xing"
        }
    });

    
     $( "#myAccountContactForm  .button").button({
        text: true,
        icons: {
primary: "ui-icon-pencil"
    }
    });

$( ".videoLink ").button({
        text: true,
        icons: {
primary: "ui-icon-video"
    }
    });
   
   $( "#updateCustomerData ").button({
        text: true,
        icons: {
primary: "ui-icon-pencil"
    }
    });




$( "#loginForm .type-button ").button({
        text: true,
        icons: {

    }
    });

    $( "#loginButtonInContent").button({
        text: true,
        icons: {

    }
    });
    $( "#insertDialogButton").button({
        text: true,
        icons: {
       primary: "ui-icon-comment"
    }
    });
    $( ".dialogAnswerButton").button({
        text: true,
        icons: {
primary: "ui-icon-arrow-1-n"
    }
    });

    $( "#userInfo-myAccount").button({
        text: true,
        icons: {

    }
    });
    $( "#userInfo-logout").button({
        text: true,
        icons: {

    }
    });
    /*
    $( "#buttonSuche ").button({
        text: true,
        icons: {
 primary: "ui-icon-search"
    }
    });
*/
    $( "#comments_form .ajaxFormSubmit ").button({
        text: true,
        icons: {

    }
    });


    $( ".backlink a").button({
        icons: {

            primary: "ui-icon-arrowreturn-1-w"
        }
    });

    $( ".browseMenu .c50l a").button({
        text: true,
        icons: {

            primary: "ui-icon-arrow-1-w"
        }
    });


    $( ".browseMenu .c50r a").button({
        text: true,
        icons: {

            secondary: "ui-icon-arrow-1-e"
        }
    });
    $( ".news-single-files dd").button({
        text: true,
        icons: {

            primary: "ui-icon-arrowthickstop-1-s"
        }
    });
    $( ".boxNewsHome a").button({
        text: true,
        icons: {

            primary: "ui-icon-document"
        }
    });
    $( ".tx-cal-controller a").button({
        text: true,
        icons: {

    }
    });

    $( ".vlist.navigation a").button({
        text: true,
        icons: {

            primary: "ui-icon-arrowthick-1-e"
        }
    });
   

     $( ".preview h2 a").button({

        text: true,
        icons: {
            primary: "ui-icon-document",
            secondary: "ui-icon-arrowthick-1-e"
        }
    });

    $( ".box h2 a").button({

        text: true,
        icons: {
            primary: "ui-icon-document",
            secondary: "ui-icon-arrowthick-1-e"
        }
    });
    $( "#tx-indexedsearch-searchbox-button-submit").button({

        text: true,
        icons: {
            primary: "ui-icon-search"
        }
    });

    $( ".ajaxFormSubmiXXt").button({
        text: true,
        icons: {
            primary: "ui-icon-mail-open",
            secondary: "ui-icon-arrowthick-1-e"
        }
    });
    $( "#newsletterAddForm-submit").button({
        text: true,
        icons: {
            primary: "ui-icon-plusthick"
        }
    });
    $( "#newsletterEditForm-submit").button({
        text: true,
        icons: {
            primary: "ui-icon-pencil"
        }
    });
    $( "#newsletterUpdateForm-submit").button({
        text: true,
        icons: {

        }
    });
    $( "#newsletterDeleteForm-submit").button({
        text: true,
        icons: {
        }
    });
    

    $('#magicWrap').masonry({

        singleMode: false,
        // Disables measuring the width of each floated element.
        // Set to true if floated elements have the same width.
        // default: false

        columnWidth: 1,
        // Width in pixels of 1 column of your grid.
        // default: outer width of the first floated element.

        itemSelector: '.magicBoxContainer',
        // Additional selector to specify which elements inside
        // the wrapping element will be rearranged.
        // Required for Infinite Scroll with window resizing.

        resizeable: true,
        // Binds a Masonry call to window resizes
        // so layout appears fluid.
        // default: true

        // animate: true,
        // Animates layout rearrangements.
        // default: false

        // animationOptions: {},
        // A map of options for animation.

        // appendedContent: $('.new_content'),
        // Additional container element for appended content.
        // Useful for Infinite Scroll integration.

        saveOptions: true
    // Masonry will use the options from previous Masonry
    // calls by default, so you only have to enter in options once
    // default: true

    }//,  function() {}
    // Optional callback.
    // 'this' will refer to the applicable elements Masonry just rearranged

    );

    /*var $newsWall = $('#magicWrap');

$newsWall.masonry({
   singleMode: false,
        // Disables measuring the width of each floated element.
        // Set to true if floated elements have the same width.
        // default: false

        columnWidth: 1,
        // Width in pixels of 1 column of your grid.
        // default: outer width of the first floated element.

        itemSelector: '.magicBoxContainer',
        // Additional selector to specify which elements inside
        // the wrapping element will be rearranged.
        // Required for Infinite Scroll with window resizing.

        resizeable: true,
        // Binds a Masonry call to window resizes
        // so layout appears fluid.
        // default: true

        // animate: true,
        // Animates layout rearrangements.
        // default: false

        // animationOptions: {},
        // A map of options for animation.

        // appendedContent: $('.new_content'),
        // Additional container element for appended content.
        // Useful for Infinite Scroll integration.

        saveOptions: true
    // Masonry will use the options from previous Masonry
    // calls by default, so you only have to enter in options once
    // default: true

    }//,  function() {}
    // Optional callback.
    // 'this' will refer to the applicable elements Masonry just rearranged

    );
});

 */
if ($('#magicWrap').length>0) {
    $('#magicWrap').infinitescroll({
        navSelector  : '.news-list-browse',  // selector for the paged navigation
        nextSelector : '.news-list-browse a',  // selector for the NEXT link (to page 2)
        itemSelector : '#magicWrap .magicBoxContainer',     // selector for all items you'll retrieve
        loadingText  : "Lade 10 weitere Nachrichten...",    // text accompanying loading image
        // default: "<em>Loading the next set of posts...</em>"
       /* loadingImg : 'fileadmin/stylesheets/yaml/screen/images/fancy_loading.png',*/
        donetext  : 'Keine weiteren Nachrichten vorhanden.',
        debug: false,
        animate: true,
        errorCallback: function() {
            // fade out the error message after 2 seconds
            $('#infscr-loading').animate({
                opacity: .8
            },200).fadeOut('normal');
        }
    },
    // call masonry as a callback
    function( newElements ) {
          $('#infscr-loading').animate({opacity: .8},100).fadeOut('normal');
        $( ".preview h2 a").button({
            text: true,
            icons: {
                primary: "ui-icon-document",
                secondary: "ui-icon-arrowthick-1-e"
            }
        });

  
        //  zoomBox();

        $.mask.close();
        $(this).masonry({
            appendedContent: $( newElements )
        });

    // setTimeout(function() {}, 1000);


    }
    );    
}
    
  
 
    // zoomBox();


    /* ############### menu ###### */

    $("ul.sf-menu").supersubs({
        minWidth:    12,   // minimum width of sub-menus in em units
        maxWidth:    50,   // maximum width of sub-menus in em units
        extraWidth:  1     // extra width can ensure lines don't sometimes turn over
    // due to slight rounding differences and font-family
    }).superfish({
        delay:       10,                            // one second delay on mouseout
        //  animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation
        animation:   {
            opacity:'show'
        },  // fade-in and slide-down animation
        speed:       50,                          // faster animation speed
        autoArrows:  true,                           // disable generation of arrow mark-up
        dropShadows: true

    });  // call supersubs first, then superfish, so that subs are
    // not display:none when measuring. Call before initialising
    // containing tabs for same reason.

    if ($('#slider').length > 0 && $('.sliderElement').length > 0) {
        $('#slider').navSlider({
            elementClass: 'sliderElement',
            menuClass: 'sliderNavElement',
            rootId: 'slider',
            navId: 'sliderNav'
        });
    }

    if ($('.ajaxRegForm').length > 0) {

        $(".ajaxRegForm").each(function(index, item) {

            $(item).attr('title', $(item).attr('href'));
            $(item).attr('href', 'javascript:void(0)');
            $(item).attr('rel', '#downloadForm');
            $(item).overlay({

                // some mask tweaks suitable for modal dialogs
                mask: {
                    color: '#ebecff',
                    loadSpeed: 200,
                    opacity: 0.9
                },

                closeOnClick: true
            });
            $(item).bind('onBeforeLoad', {
                item:item
            }, function(event) {
                //'http://c00105.web2.server.meshmedia.de/index.php?eID=tx_nawsecuredl&u=2&file=fileadmin/documents-secure/mandantenrundbriefe/blitzlicht_11-2010.pdf&t=1290594059&hash=51a848b040f91d3a1fd8d044a0876516d6feab3f'
                $('#redirectUrlAfterLogin').val($(event.data.item).attr('title'));
                $('#filenameNawSecureDL').val($(event.data.item).attr('title'));
            });

        });


    }

    $.tools.dateinput.localize("de",  {
        months:        'Januar,Februar,M&auml;rz,April,Mai,Juni,Juli,August,' +
        'September,Oktober,November,Dezember',
        shortMonths:   'Jan,Feb,M&auml;r,Apr,Mai,Jun,Jul,Aug,Sep,Okt,Nov,Dez',
        days:          'Sonntag,Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag',
        shortDays:     'So,Mo,Di,Mi,Do,Fr,Sa'
    });



    $(".dateInput").dateinput({
        lang: 'de',
        format: 'dd.mm.yyyy'
    });
	


    $("a[class~=imgPop]").fancybox({
        //$("a:has(img)").fancybox({
        'transitionIn'		: 'fade',
        'transitionOut'		: 'elastic',
        'titlePosition' 	: 'inside',
        'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
        /*
		return '<span id="fancybox-title-inside">Bild ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		*/
        },
        'onComplete'	:	function() {
            $("#fancybox-wrap").hover(function() {
                $("#fancybox-title").show();
            }, function() {
                $("#fancybox-title").hide();
            });
        }

    });


/* ############# video ####### */
       
/*

	var videoclip;
	var player;
	var vidid;
	var captions;
	var capShow;
	var ccbutShow;

	$(".videoLink").hover(function(){
		vidid = $(".videoLink").index(this);
                videoclip = $(".videoLink").eq(vidid).attr("name");
		//videoclip = $(".videoLink").eq(vidid).attr("name");
		if ($(".videoLink").eq(vidid).hasClass('captions')) {
		captions = $(".videoLink").eq(vidid).attr("name")+'.srt';
		capShow = true;
		ccbutShow = { width: 20, height: 15, right: 5, bottom: 32, label: 'SUBS' };
		} else {
		captions = 'empty.srt';
		capShow = false;
		ccbutShow = null;
		}
	});

	$(".videoLink").fancybox({
		'hideOnContentClick':false,
		'overlayOpacity' :.6,
		'zoomSpeedIn'    :400,
		'zoomSpeedOut'   :400,
		'easingIn'		 : 'easeOutBack',
		'easingOut'		 : 'easeInBack',

		'callbackOnShow' :function(){

			if (videoclip == 'image') {

				$("#fancy_right, #fancy_left").css({height:$("#fancy_div").height(), bottom: '0'});

				} else {

				player = $f("fancy_content",{src: swfplayer, wmode: 'opaque'},{

				play:{opacity:0},
			  //key: '#$flowplayerkeycode',

				plugins: {


				captions: {
					url: swfcaptions,
					// pointer to a content plugin (see below)
					captionTarget: 'content',
					showCaptions: capShow,
					button: ccbutShow
				},
				
				content: {
					url:swfcontent,
					bottom: 25,
					height:40,
					backgroundColor: 'transparent',
					backgroundGradient: 'none',
					border: 0,
					textDecoration: 'outline',
					style: {
						body: {
							fontSize: 16,
							fontFamily: 'Arial',
							textAlign: 'center',
							color: '#ffffff'
						}
					}
				},

				controls:  {
				backgroundColor: 'transparent',
				progressColor: 'transparent',
				bufferColor: 'transparent',
				all:false,
                                //fullscreen:true,
				scrubber:true,
				volume:true,
				mute:true,
				play:true,
				height:30,
				autoHide: 'always'

				}

				},
				clip:{
					autoPlay:true,
					autoBuffering:true,
					url:videopath+videoclip+'',
					captionUrl: videopath+captions+'',
					onStart:function(clip){
						var wrap=jQuery(this.getParent());
						var clipwidth = clip.metaData.width;
						var clipheight= clip.metaData.height;
						var pos = $.fn.fancybox.getViewport();
						$("#fancy_outer").css({width:clipwidth+20,height:clipheight+20});
						$("#fancy_outer").css('left', ((clipwidth + 36) > pos[0] ? pos[2] : pos[2] + Math.round((pos[0] - clipwidth	- 36)	/ 2)));
						$("#fancy_outer").css('top',  ((clipheight + 50) > pos[1] ? pos[3] : pos[3] + Math.round((pos[1] - clipheight - 50)	/ 2)));
						$("#fancy_right, #fancy_left").css({height:clipheight-60, bottom: '70px'});

					},
					onFinish:function(){
						$('#fancy_close').trigger('click');
					}
				}
			});



			player.load();

		}

			$('#fancy_right, #fancy_right_ico').click(function(){
				vidid++;
				videoclip = $(".videoLink").eq(vidid).attr("name");
				if ($(".videoLink").eq(vidid).hasClass('captions')) {
				captions = $(".videoLink").eq(vidid).attr("name")+'.srt';
				capShow = true;
				ccbutShow = { width: 20, height: 15, right: 5, bottom: 32, label: 'CC' };
				} else {
				captions = videopath + 'empty.srt';
				capShow = false;
				ccbutShow = null;
				}
			});

			$('#fancy_left, #fancy_left_ico').click(function(){
				vidid--;
				videoclip = $(".videoLink").eq(vidid).attr("name");
				if ($(".videoLink").eq(vidid).hasClass('captions')) {
				captions = $(".videoLink").eq(vidid).attr("name")+'.srt';
				capShow = true;
				ccbutShow = { width: 20, height: 15, right: 5, bottom: 32, label: 'SUBS' };
				} else {
				captions = videopath + 'empty.srt';
				capShow = false;
				ccbutShow = null;
				}
			});
		},
		'callbackOnClose':function(){
			$("#fancy_content_api").remove();
		}
	});
	
 var videopath = "../../fileadmin/Video_Clips/";
	var swfplayer = videopath + "flowplayer-3.1.5.swf";
	var swfcontent = videopath + "flowplayer.content-3.1.0.swf";
	var swfcaptions = videopath + "flowplayer.captions-3.1.4.swf";
*/

$("a.videoLink").click(function() {
                 $.fancybox({
                 'padding'     	    : '10',
        'margin'     	    : '10',
        'opacity'		: true,
        'transitionIn'      : 'elastic',
        'transitionOut'     : 'elastic',
        'speedIn'           : 600,
        'speedOut'          : 300,
        'overlayShow'       : false,
        'hideOnContentClick': false,
                  'autoScale'   : false,
                  'title'               : this.title,
                  'width'               : 680,
               //   'height'              : 495,
                  'height'              : 410,
                //  'href'                : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
                  'href'                :this.href = this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1',
                  'type'                : 'swf',
                  'swf'                 : {'allowfullscreen':'true', 'wmode':'transparent'}
                  });
                 return false;

            });


/* ####### video ende # */



    $('.ajaxContent').each(function(index,item) {
       idElements = $(item).attr('id').split('-');
       ajaxUrl = '/index.php?id='+idElements[1];
        jQuery.ajax({url: ajaxUrl, dataType: 'html', success: function(data, textStatus, XMLHttpRequest){
            $(item).html(data);
        }});
    });


    if ($('#myAccountTabs').length>0) {


        currentIntDay = false;
        currentIntMonth = false;
        currentIntYear = false;
        currentDay = false;
        currentMonth = false;
        currentYear = false;
        currentHour = false;
        currentMinute = false;
        renderedEvents = new Array();
        daysWithEvents = new Array();
        fetchedMonths = new Array();

        datePickerOptions = {
            dateFormat: 'dd.mm.yy',
            monthNames: ['Januar', 'Februar', 'M&auml;rz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
            monthNamesShort: ['Jan', 'Feb', 'M&auml;r', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
            dayNames: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch','Donnerstag', 'Freitag', 'Samstag'],
            dayNamesMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
            firstDay: 1,
            showWeek: true,
            weekHeader: 'W',
            showOtherMonths: true,
            selectOtherMonths: true
        };

        timePickerOptions = {
            hourText: 'Stunde',
            minuteText: 'Minute',
            amPmText: ['', '']
        };


        $('#myAccountTabs').tabs({

        });

        smallMonthOptions = {
            dateFormat: 'dd.mm.yy',
            monthNames: ['Januar', 'Februar', 'M&auml;rz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
            monthNamesShort: ['Jan', 'Feb', 'M&auml;r', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
            dayNames: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch','Donnerstag', 'Freitag', 'Samstag'],
            dayNamesMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
            firstDay: 1,
            showWeek: true,
            weekHeader: 'W',
            showOtherMonths: true,
            selectOtherMonths: true
        };
        smallMonthOptions.numberOfMonths = [2, 1];
        smallMonthOptions.onSelect = function(dateText, inst) {
            dateElements = dateText.split('.');
            $('#fullCalendar').fullCalendar( 'changeView', 'agendaDay' );
            $('#fullCalendar').fullCalendar( 'gotoDate', parseInt(dateElements[2]),  parseInt(dateElements[1])-1,  parseInt(dateElements[0]));

        };
        smallMonthOptions.onChangeMonthYear = function(year, month, inst) {
            bindMonthTitles();
            year =  parseInt(smallMonthCurrentDate.getFullYear());
            month = (smallMonthCurrentDate.getMonth()+1);
            month = (month<10?'0':'')+String(month);
            nextMonth = smallMonthCurrentDate.getMonth()+1;
            if (nextMonth==11) {
                nextMonth = 0;
                year++;
            }
            else {
                nextMonth++;
            }
            nextMonth = (nextMonth<10?'0':'')+String(nextMonth);
            year = String(year);
            /*
            alert(fetchedMonths);
            alert(year+'-'+month);
            alert(in_array(year+'-'+month,fetchedMonths));
            alert(year+'-'+nextMonth);
            alert(in_array(year+'-'+nextMonth,fetchedMonths));
            
            alert(daysWithEvents);
            */
            

        };
        smallMonthOptions.beforeShowDay = function(date) {
            month = (date.getMonth()+1);
            month = (month<10?'0':'')+String(month);
            day = date.getDate();
            day = (day<10?'0':'')+String(day);
            fullDay = date.getFullYear()+'-'+month+'-'+day;
            return new Array(
                true,
                (in_array(fullDay, daysWithEvents)?'dayWithEvent':''),
                ''
            );
        };


        smallMonthOptions.beforeShow = function(input, inst) {
            
        };




        $('#smallMonthCurrent').datepicker(smallMonthOptions);
        

        bindMonthTitles = function() {
            
            smallMonthCurrentDate = $('#smallMonthCurrent').datepicker( "getDate" );
            $('#smallMonthCurrent .ui-datepicker-title').each(function (index,item) {
                $(item).wrapInner('<a class="monthSelector" href="#" />');
                //alert($(item).html());
                $(item).find('a.monthSelector').click(function(event) {
                    event.preventDefault();
                    selectorDate = smallMonthCurrentDate;
                    month = selectorDate.getMonth();
                    year = selectorDate.getFullYear();
                    if (month==11) {
                        month = 0;
                        year++;
                    }
                    else {
                        month+=index;
                    }
                    selectorDate.setMonth(month);
                    selectorDate.setFullYear(year);
                    $('#fullCalendar').fullCalendar( 'changeView', 'month' );
                    $('#fullCalendar').fullCalendar( 'gotoDate', selectorDate.getFullYear(),  selectorDate.getMonth(), 1);

                });
            });
        }
        bindMonthTitles();

        $('#myAccount-mediaCenter-menu').accordion({
                   collapsible: true,
                   autoHeight: false,
		   navigation: true,
                   animated: false
        });
        $('#myAccount-mediaCenter-menu>h3.ui-accordion-header a').each(function(index,item) {
            
            $(item).click(function() {
                $('#mediaCenterMainContent>div').each(function(cIndex,cItem) {
                     
                    if (index==cIndex) {
                        $(cItem).show();
                    }
                    else {
                        $(cItem).hide();
                    }
                });
            });
        });
        $('#mediaCenterMainContent>div').each(function(cIndex,cItem) {
            if (cIndex) {
                $(cItem).hide();
            }
        });


        jQuery('#dialogUpdateAccountData').dialog({
            drag: function(event, ui) {
                jQuery(this).parent().css('opacity', .9)
            },
            dragStop: function(event, ui) {
                jQuery(this).parent().css('opacity', 1)
            },
            title: 'Meine Daten bearbeiten',
            autoOpen: false,
            width: 700,
            open: function() {

            },
            buttons: {
                "Abbrechen": function() {
                    jQuery('#dialogUpdateAccountData').dialog('close');
                },
                "Daten speichern": function() {
                    ajaxUrl = 'index.php';
                    ajaxUrl += '?id=115&no_cache=1&';
                    ajaxUrl += decodeURIComponent(jQuery('#updateAccountForm').serialize());
                    jQuery.ajax({url: ajaxUrl, dataType: 'html', success: function(data, textStatus, XMLHttpRequest){

                        $('#accountData-fieldsList').html(data);
                        $('.fieldsList li').each(function(index,item) {
                            fieldValue = $(item).find('.fieldValue').html();
                            if (fieldValue=='' || fieldValue==' ') {
                                $(item).hide();
                            }
                        });
                        jQuery('#dialogUpdateAccountData').dialog('close');
                        
                    }});
                }


            }
        });

        $('#updateCustomerData').click(function(event) {
            event.preventDefault();
            jQuery('#dialogUpdateAccountData').dialog('open');
        });

        $('.fieldsList li').each(function(index,item) {
            fieldValue = $(item).find('.fieldValue').html();
            if (fieldValue=='' || fieldValue==' ') {
                $(item).hide();
            }
        });

        $('#myAccountContactForm').submit(function (event) {
            event.preventDefault();
            ajaxUrl = 'index.php?';
            ajaxUrl += decodeURIComponent(jQuery('#myAccountContactForm').serialize());
            jQuery.ajax({url: ajaxUrl, dataType: 'html', success: function(data, textStatus, XMLHttpRequest) {
                returncode = parseInt($(data).find('.code').html());
                message = $(data).find('.message').html();
                $('#myAccountContactFormMessage').html(message);
                if (returncode) {
                    $('#myAccountContactFormMessage').removeClass('info');
                    $('#myAccountContactFormMessage').addClass('warning');
                }
                else {
                    $('#myAccountContactFormMessage').removeClass('warning');
                    $('#myAccountContactFormMessage').addClass('info');
                }

            }});
        });


        jQuery('#dialogInsertForm').dialog({
            drag: function(event, ui) {
                jQuery(this).parent().css('opacity', .9)
            },
            dragStop: function(event, ui) {
                jQuery(this).parent().css('opacity', 1)
            },
            title: 'Neue Nachricht erstellen...',
            autoOpen: false,
            width: 700,
            open: function() {
                jQuery.ajax({
                    url: 'index.php',
                    dataType: 'html',
                    data: {
                        id: 111,
                        no_cache: 1
                    },
                    success: function(doc) {
                        
                        jQuery('#dialogInsertForm').html(doc);
                    },
                    error: function(jqXHR, textStatus, errorThrown) {
                        alert(errorThrown);
                    }
                });
            },
            buttons: {
                "Abbrechen": function() {
                    jQuery('#dialogInsertForm').dialog('close');
                },
                "Nachricht absenden": function() {
                    ajaxUrl = 'index.php';
                    ajaxUrl += '?id=112&no_cache=1&type=96&';
                    ajaxUrl += decodeURIComponent(jQuery('#dialog-insertForm').serialize());
                    jQuery.ajax({url: ajaxUrl, dataType: 'xml', success: function(data, textStatus, XMLHttpRequest){
                        jQuery('#dialogContent').html(data);
                        $('.dialogAnswerButton').each(function(index,item) {
                            $(item).click(function(event) {
                                event.preventDefault();
                                idElements = $(item).attr('id').split('-');
                                currentAnswerId = idElements[1];
                                jQuery('#dialogAnswerForm').dialog('open');
                            });
                        });
                        $( ".dialogAnswerButton").button({
                            text: true,
                            icons: {

                        }
                        });
                        $('.dialogElement').accordion({
                           collapsible: true,
                           autoHeight: false,
                           navigation: true,
                           animated: false
                        });
                        jQuery('#dialogInsertForm').dialog('close');

                    }});
                }


            }
        });

        $('#insertDialogButton').click(function(event) {
            event.preventDefault();
            jQuery('#dialogInsertForm').dialog('open');
        });

        currentAnswerId = false;
        jQuery('#dialogAnswerForm').dialog({
            drag: function(event, ui) {
                jQuery(this).parent().css('opacity', .9)
            },
            dragStop: function(event, ui) {
                jQuery(this).parent().css('opacity', 1)
            },
            title: 'Auf diese Nachricht antworten...',
            autoOpen: false,
            width: 700,
            open: function() {
                jQuery.ajax({
                    url: 'index.php',
                    dataType: 'html',
                    data: {
                        id: 111,
                        no_cache: 1
                    },
                    success: function(doc) {

                        jQuery('#dialogAnswerForm').html(doc);
                    },
                    error: function(jqXHR, textStatus, errorThrown) {
                        alert(errorThrown);
                    }
                });
            },
            buttons: {
                "Abbrechen": function() {
                    jQuery('#dialogAnswerForm').dialog('close');
                },
                "Nachricht absenden": function() {
                    ajaxUrl = 'index.php';
                    ajaxUrl += '?id=112&no_cache=1&';
                    ajaxUrl += 'tx_ddcontactform_pi1[answer2uid]='+currentAnswerId+'&';
                    ajaxUrl += decodeURIComponent(jQuery('#dialog-insertForm').serialize());
                    jQuery.ajax({url: ajaxUrl, dataType: 'html', success: function(data, textStatus, XMLHttpRequest){
                        jQuery('#dialogContent').html(data);
                        $('.dialogAnswerButton').each(function(index,item) {
                            $(item).click(function(event) {
                                event.preventDefault();
                                idElements = $(item).attr('id').split('-');
                                currentAnswerId = idElements[1];
                                jQuery('#dialogAnswerForm').dialog('open');
                            });
                        });
                        $( ".dialogAnswerButton").button({
                            text: true,
                            icons: {

                        }
                        });
                        $('.dialogElement').accordion({
                           collapsible: true,
                           autoHeight: false,
                           navigation: true,
                           animated: false
                        });
                        jQuery('#dialogAnswerForm').dialog('close');

                    }});
                }


            }
        });

        $('.dialogAnswerButton').each(function(index,item) {
            $(item).click(function(event) {
                event.preventDefault();
                idElements = $(item).attr('id').split('-');
                currentAnswerId = idElements[1];
                jQuery('#dialogAnswerForm').dialog('open');
            });
        });

        $('.dialogElement').accordion({
           collapsible: true,
           autoHeight: false,
           navigation: true,
           animated: false
        });



        $('#fullCalendar').append(
            '<div id="dialogInsertEvent"></div>'+
            '<div id="dialogOpenEvent"></div>'
            );



        $('#fullCalendar').fullCalendar({
               

            viewDisplay: function(view) {


                var d = $('#fullCalendar').fullCalendar('getDate');
                getdateParam = String(d.getFullYear());
                month = d.getMonth()+1;
                month = (month<10?'0':'')+String(month);
                if (!in_array(getdateParam+'-'+month,fetchedMonths)) {
                    fetchedMonths.push(getdateParam+'-'+month);
                }
                getdateParam += month;
                getdateParam += '01';

                $.ajax({
                    url: 'index.php',
                    dataType: 'xml',
                    data: {
                        id: 91,
                        no_cache: 1,
                        type: 96,
                        'tx_cal_controller[getdate]': getdateParam
                    },
                    success: function(doc) {
                        
                        $(doc).find('event').each(function(index,item) {

                            eventId = $(item).attr('uid');

                            if (!in_array(eventId, renderedEvents)) {
                                renderedEvents.push(eventId);
                                if (!in_array($(item).attr('startdate'),daysWithEvents)) {
                                    daysWithEvents.push($(item).attr('startdate'));
                                }
                                
                                $('#fullCalendar').fullCalendar('renderEvent', {
                                    id: eventId,
                                    className: 'category-'+($(item).attr('category')?$(item).attr('category'):'0')+' '+($(item).attr('pid')=='50'?'global-event':'personal-event'),
                                    title: $(item).attr('title'),
                                    start: $(item).attr('startdate')+'T'+($(item).attr('starttime')?$(item).attr('starttime'):'00:00:00')+'Z',
                                    end: ($(item).attr('enddate')?$(item).attr('enddate'):$(item).attr('startdate'))+'T'+($(item).attr('endtime')?$(item).attr('endtime'):'00:00:00')+'Z',
                                    allDay: ($(item).attr('allday')=='1'?true:false),
                                    editable: ($(item).attr('pid')=='50'?false:true)
                                }, true);

                            }

                            $('#smallMonthCurrent').datepicker( "setDate" , d );

                        });

                    },
                    error: function(jqXHR, textStatus, errorThrown) {
                        alert(errorThrown);
                    }
                });

                if (view.name=='agendaWeek') {
                    $('.fc-header-title').html($('.fc-header-title').html().replace('%W',d.getWeek(1)));
                }



            },

            eventDrop: function( event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view ) {

                $.ajax({
                    url: 'index.php',
                    dataType: 'xml',
                    data: {
                        id: 93,
                        no_cache: 1,
                        type: 96,
                        'tx_ddcontactform_pi1[uid]': event.id,
                        'tx_ddcontactform_pi1[dayDelta]': dayDelta,
                        'tx_ddcontactform_pi1[minuteDelta]': minuteDelta
                    },
                    success: function(doc) {

                    },
                    error: function(jqXHR, textStatus, errorThrown) {
                        alert(errorThrown);
                    }
                });

            },
            eventResize: function( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ) {

                $.ajax({
                    url: 'index.php',
                    dataType: 'xml',
                    data: {
                        id: 100,
                        no_cache: 1,
                        type: 96,
                        'tx_ddcontactform_pi1[uid]': event.id,
                        'tx_ddcontactform_pi1[dayDelta]': dayDelta,
                        'tx_ddcontactform_pi1[minuteDelta]': minuteDelta
                    },
                    success: function(doc) {

                    },
                    error: function(jqXHR, textStatus, errorThrown) {
                        alert(errorThrown);
                    }
                });

            },

            dayClick: function( date, allDay, jsEvent, view ) {

                if ($('#usergroup-2').length>0) {
                    
                    currentIntDay = date.getDate();
                    currentDay = ((date.getDate()<10)?'0':'')+String(date.getDate());
                    month = date.getMonth()+1;
                    currentIntMonth = date.getMonth();
                    currentMonth = ((month<10)?'0':'')+String(month);
                    currentIntYear = date.getFullYear();
                    currentYear = String(date.getFullYear());
                    currentHour = date.getHours();
                    currentMinute = date.getMinutes();
                    selectedDay = this;

                    jQuery('#dialogInsertEvent').dialog({
                        drag: function(event, ui) {
                            jQuery(this).parent().css('opacity', .9)
                        },
                        dragStop: function(event, ui) {
                            jQuery(this).parent().css('opacity', 1)
                        },
                        title: 'Neuer Kalendereintrag...',
                        autoOpen: false,
                        width: 700,
                        open: function() {


                            jQuery.ajax({
                                url: 'index.php',
                                dataType: 'html',
                                data: {
                                    id: 94,
                                    no_cache: 1,

                                    'tx_ddcontactform_pi1[day]': currentDay,
                                    'tx_ddcontactform_pi1[month]': currentMonth,
                                    'tx_ddcontactform_pi1[year]': currentYear,
                                    'tx_ddcontactform_pi1[hour]': currentHour,
                                    'tx_ddcontactform_pi1[minute]': currentMinute
                                },
                                success: function(doc) {
                                    jQuery('#dialogInsertEvent').html(jQuery(doc).html());
                                    pickerDate = new Date();
                                    pickerDate.setDate(currentIntDay);
                                    pickerDate.setMonth(currentIntMonth);
                                    pickerDate.setFullYear(currentIntYear);
                                    jQuery('.dateInput').datepicker(datePickerOptions);

                                    jQuery('#start_date').datepicker( "setDate" , pickerDate );
                                    jQuery('#dialogInsertEvent').dialog().parents('.ui-dialog').css('top',jsEvent.pageY-200);
                                    //jQuery('#dialogInsertEvent').dialog( "option", "position", [200,jsEvent.pageY+200] );
                                    jQuery('.timeInput').timepicker(timePickerOptions);
                                    jQuery('#allday').click(function() {
                                        jQuery(this).attr('checked')?jQuery('.timeInput').hide():jQuery('.timeInput').show();
                                    });
                                },
                                error: function(jqXHR, textStatus, errorThrown) {
                                    alert(errorThrown);
                                }
                            });
                        },
                        close: function() {
                            jQuery('.dateInput').datepicker('destroy');
                        },
                        buttons: {
                            "Abbrechen": function() {
                                jQuery('#dialogInsertEvent').dialog('close');
                                jQuery('.dateInput').datepicker('destroy');
                            },
                            "Eintrag speichern": function() {
                                ajaxUrl = 'index.php';
                                ajaxUrl += '?id=101&no_cache=1&type=96&';
                                ajaxUrl += decodeURIComponent(jQuery('#insertEventForm').serialize());

                                jQuery.ajax({url: ajaxUrl, dataType: 'xml', success: function(data, textStatus, XMLHttpRequest){

                                    resultCode = parseInt(jQuery(data).find('code').text());
                                    if (!resultCode) {
                                        jQuery(data).find('event').each(function(index,item) {

                                            eventId = $(item).attr('uid');
                                            renderedEvents.push(eventId);
                                            jQuery('#fullCalendar').fullCalendar('renderEvent', {
                                                id: eventId,
                                                className: 'category-'+($(item).attr('category')?$(item).attr('category'):'0')+' '+($(item).attr('pid')=='50'?'global-event':'personal-event'),
                                                title: $(item).attr('title'),
                                                start: $(item).attr('startdate')+'T'+($(item).attr('starttime')?$(item).attr('starttime'):'00:00:00')+'Z',
                                                end: ($(item).attr('enddate')?$(item).attr('enddate'):$(item).attr('startdate'))+'T'+($(item).attr('endtime')?$(item).attr('endtime'):'00:00:00')+'Z',
                                                allDay: ($(item).attr('allday')=='1'?true:false),
                                                editable: ($(item).attr('pid')=='50'?false:true)
                                            }, true);



                                        });

                                        jQuery('#dialogInsertEvent').dialog('close');
                                        jQuery('.dateInput').datepicker('destroy');
                                    }
                                    else {
                                        alert('error: insert event');
                                    }

                                }});
                            }


                        }
                    });

                    jQuery('#dialogInsertEvent').dialog( "option", "position", 'center' );
                    jQuery('#dialogInsertEvent').dialog("open");
                }
            },


            eventClick: function(calEvent, jsEvent, view) {


                jQuery('#dialogOpenEvent').dialog({
                    drag: function(event, ui) {
                        jQuery(this).parent().css('opacity', .9)
                    },
                    dragStop: function(event, ui) {
                        jQuery(this).parent().css('opacity', 1)
                    },
                    title: calEvent.title,
                    autoOpen: false,
                    width: 700,
                    open: function() {
                        
                        jQuery.ajax({
                            url: 'index.php',
                            dataType: 'html',
                            data: {
                                id: 102,
                                no_cache: 1,
                                
                                'tx_cal_controller[uid]': calEvent.id,
                                'tx_cal_controller[view]': 'event',
                                'tx_cal_controller[type]': 'tx_cal_phpicalendar'
                            },
                            success: function(doc) {
                                jQuery('#dialogOpenEvent').html(jQuery(doc).html());

                                $('.fieldsList li').each(function(index,item) {
                                    fieldValue = $(item).find('.fieldValue').html();
                                    if (fieldValue=='' || fieldValue==' ') {
                                        $(item).hide();
                                    }
                                });
                                $('#eventDetailTabs').tabs({
                                    show: function(event, ui) {
                                        var selectedTab = $('#eventDetailTabs').tabs('option', 'selected');

                                        switch (selectedTab) {
                                            case 0:
                                                $('#dialogOpenEvent').dialog('option', 'buttons', {
                                                    "Abbrechen": function() {
                                                        jQuery('#dialogOpenEvent').dialog('close');
                                                        jQuery('.dateInput').datepicker('destroy');
                                                    }
                                                });
                                                break;
                                            case 1:

                                                $('#dialogOpenEvent').dialog('option', 'buttons', {
                                                    "Abbrechen": function() {
                                                        jQuery('#dialogOpenEvent').dialog('close');
                                                        jQuery('.dateInput').datepicker('destroy');
                                                    },
                                                    "OK": function() {
                                                        ajaxUrl = 'index.php';
                                                        ajaxUrl += '?id=104&no_cache=1&type=96&';
                                                        ajaxUrl += decodeURIComponent(jQuery('#updateEventForm').serialize());

                                                        jQuery.ajax({url: ajaxUrl, dataType: 'xml', success: function(data, textStatus, XMLHttpRequest){

                                                            jQuery(data).find('event').each(function(index,item) {
                                                                eventId = jQuery(item).attr('uid');
                                                                jQuery('#fullCalendar').fullCalendar('removeEvents' , eventId);

                                                                jQuery('#fullCalendar').fullCalendar('renderEvent', {
                                                                    id: eventId,
                                                                    className: 'category-'+($(item).attr('category')?$(item).attr('category'):'0')+' '+($(item).attr('pid')=='50'?'global-event':'personal-event'),
                                                                    title: $(item).attr('title'),
                                                                    start: $(item).attr('startdate')+'T'+($(item).attr('starttime')?$(item).attr('starttime'):'00:00:00')+'Z',
                                                                    end: ($(item).attr('enddate')?$(item).attr('enddate'):$(item).attr('startdate'))+'T'+($(item).attr('endtime')?$(item).attr('endtime'):'00:00:00')+'Z',
                                                                    allDay: ($(item).attr('allday')=='1'?true:false),
                                                                    editable: ($(item).attr('pid')=='50'?false:true)
                                                                }, true);
                                                            });


                                                            jQuery('#dialogOpenEvent').dialog('close');
                                                            jQuery('.dateInput').datepicker('destroy');


                                                        }});
                                                    }
                                                });
                                                break;
                                            case 2:
                                                $('#dialogOpenEvent').dialog('option', 'buttons', {
                                                    "Abbrechen": function() {
                                                        jQuery('#dialogOpenEvent').dialog('close');
                                                        jQuery('.dateInput').datepicker('destroy');
                                                    },
                                                    "OK": function() {
                                                        ajaxUrl = 'index.php';
                                                        ajaxUrl += '?id=105&no_cache=1&type=96&';
                                                        ajaxUrl += decodeURIComponent(jQuery('#deleteEventForm').serialize());

                                                        jQuery.ajax({url: ajaxUrl, dataType: 'xml', success: function(data, textStatus, XMLHttpRequest){

                                                            jQuery(data).find('event').each(function(index,item) {
                                                                eventId = jQuery(item).attr('uid');
                                                                jQuery('#fullCalendar').fullCalendar('removeEvents' , eventId);


                                                            });

                                                            jQuery('#dialogOpenEvent').dialog('close');

                                                        }});
                                                    }
                                                });
                                                break;
                                        }
                                    }

                                });
                                if (!calEvent.editable) {
                                    $('#eventDetailTabs').tabs( "remove" , 1 );
                                    $('#eventDetailTabs').tabs( "remove" , 1 );
                                }
                                
                                jQuery('.dateInput').datepicker(datePickerOptions);
                                jQuery('.timeInput').timepicker(timePickerOptions);

                                jQuery('#updateEventForm-allday').click(function() {
                                    jQuery(this).attr('checked')?jQuery('.timeInput').hide():jQuery('.timeInput').show();
                                });
                                

                            },
                            error: function(jqXHR, textStatus, errorThrown) {
                                alert(errorThrown);
                            }
                        });
                        
                    },
                    buttons: {
                        "Abbrechen": function() {
                            jQuery('#dialogOpenEvent').dialog('close');
                            jQuery('#dialogOpenEvent').dialog('destroy');
                            jQuery('.dateInput').datepicker('destroy');
                        }
                    }
                });

                jQuery('#dialogOpenEvent').dialog( "option", "position", 'center' );
                jQuery('#dialogOpenEvent').dialog("open");
            },

 

            editable: true,
            modal: true,
            monthNames: ['Januar', 'Februar', 'M&auml;rz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
            monthNamesShort: ['Jan', 'Feb', 'M&auml;r', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
            dayNames: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch','Donnerstag', 'Freitag', 'Samstag'],
            dayNamesShort: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
            firstDay: 1,
            buttonText: {
                prev:     '&nbsp;&#9668;&nbsp;',  // left triangle
                next:     '&nbsp;&#9658;&nbsp;',  // right triangle
                prevYear: '&nbsp;&lt;&lt;&nbsp;', // <<
                nextYear: '&nbsp;&gt;&gt;&nbsp;', // >>
                today:    'heute',
                month:    'Monat',
                week:     'Woche',
                day:      'Tag'
            },
            theme: true,
            header: {
                left:   'agendaDay,agendaWeek,month',
                center: '',
                right:  'today prev,next'
            },
            defaultView: 'agendaWeek',
            timeFormat: {
                agenda: 'HH:mm{ - HH:mm}',
                month: "HH:mm 'Uhr': ",
                '': 'HH(:mm)'
            },
            columnFormat: {
                month: 'ddd',    // Mon
                week: 'ddd d.M.', // Mon 9/7
                day: 'dddd d.M.'  // Monday 9/7
            },
            titleFormat: {
                month: 'MMMM yyyy',                             // September 2009
                week: "'KW' %W, d.[ MMMM][ yyyy]{ '&#8212;' d. MMMM yyyy}", // Sep 7 - 13 2009
                day: 'dddd, d. MMMM, yyyy'                  // Tuesday, Sep 8, 2009
            },
            allDayText: 'ganzt&auml;gig',
            axisFormat: 'HH:mm',
            slotMinutes: 15
        });
    }

    if ($('#box139').length>0) {
        eventId = false;
        $('#box139').append('<div id="dialogHomeEvent"></div>');
        $('#box139 .title a').each(function(index,item) {

            jQuery('#dialogHomeEvent').dialog({
                drag: function(event, ui) {
                    jQuery(this).parent().css('opacity', .9)
                },
                dragStop: function(event, ui) {
                    jQuery(this).parent().css('opacity', 1)
                },
                title: 'Was Sie nicht verpassen sollten...',
                autoOpen: false,
                width: 700,
                open: function() {
                    
                    jQuery.ajax({
                        url: 'index.php',
                        dataType: 'html',
                        data: {
                            id: 102,
                            no_cache: 1,

                            'tx_cal_controller[uid]': eventId,
                            'tx_cal_controller[view]': 'event',
                            'tx_cal_controller[type]': 'tx_cal_phpicalendar'
                        },
                        success: function(doc) {

                            jQuery('#dialogHomeEvent').html(doc);

                            $('.fieldsList li').each(function(index,item) {
                                fieldValue = $(item).find('.fieldValue').html();
                                if (fieldValue=='' || fieldValue==' ') {
                                    $(item).hide();
                                }
                            });
                            $('#eventDetailTabs').tabs({


                            });

                            $('#eventDetailTabs').tabs( "remove" , 1 );
                            $('#eventDetailTabs').tabs( "remove" , 1 );

                        },
                        error: function(jqXHR, textStatus, errorThrown) {
                            alert(errorThrown);
                        }
                    });

                },
                buttons: {
                    "OK": function() {
                        jQuery('#dialogHomeEvent').dialog('close');
                        //jQuery('#dialogHomeEvent').dialog('destroy');

                    }
                }
            });
            $(item).click(function(event) {
                idElements = $(this).parents('.title').attr('id').split('-');
                eventId = idElements[1];
                event.preventDefault();
                jQuery('#dialogHomeEvent').dialog('open');
            });
        });
    }


    if ($('.ajaxForm').length > 0)  {
        $('.ajaxForm').each( function (formIndex, form) {
            $(form).bind('submit', function (event) {
                event.preventDefault();
                
                ajaxUrl = $(form).attr('action');
                ajaxUrl += (ajaxUrl.search('/\?/')>0?'&':'?');
                ajaxUrl += decodeURIComponent($(form).serialize());

                $.ajax({
                    url: ajaxUrl,
                    dataType: 'xml',
                    success: function(doc) {
                        resultCode = parseInt($(doc).find('code').text());
                        message = $(doc).find('message').text();
                        switch (resultCode) {
                            case 1:
                                $(form).find('.formMessage').html(message);
                                break;
                            case 2:
                                alert('Das war das falsche Symbol');
                                break;
                            default:
                                $(form).html(message);
                                break;
                        }
                    },
                    error: function(jqXHR, textStatus, errorThrown) {
                        alert(errorThrown);
                    }
                });
            });
        });
    }

    if ($('#newsletterAddForm').length > 0)  {
        $('#newsletterAddForm').bind('submit', function (event) {
            event.preventDefault();

            ajaxUrl = $('#newsletterAddForm').attr('action');
            ajaxUrl += '?id=120&no_cache=1&type=96&';
            ajaxUrl += decodeURIComponent($('#newsletterAddForm').serialize());

            $.ajax({
                url: ajaxUrl,
                dataType: 'xml',
                success: function(doc) {
 
                    
                    resultCode = parseInt($(doc).find('code').text());
                    message = $(doc).find('message').text();
                    switch (resultCode) {
                        case 1:
                            $('#newsletterAddForm-message').html(message);
                            $('#newsletterAddForm-message').addClass('warning');
                            break;
                        case 2:
                            alert('Das war das falsche Symbol');
                            break;
                        default:
                            $('#newsletterAddForm-form').html(message);
                            $('#newsletterAddForm-form').addClass('info');
                            break;
                    }
                    
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    alert(errorThrown);
                }
            });
        });

    }
    if ($('#newsletterEditForm').length > 0)  {
        $('#newsletterEditForm').bind('submit', function (event) {
            event.preventDefault();

            ajaxUrl = $('#newsletterEditForm').attr('action');
            ajaxUrl += '?id=122&no_cache=1&type=96&';
            ajaxUrl += decodeURIComponent($('#newsletterEditForm').serialize());
            $.ajax({
                url: ajaxUrl,
                dataType: 'xml',
                success: function(doc) {


                    resultCode = parseInt($(doc).find('code').text());
                    message = $(doc).find('message').text();

                    switch (resultCode) {
                        case 1:
                            $('#newsletterEditForm-message').html(message);
                            $('#newsletterEditForm-message').addClass('warning');
                            break;
                        case 2:
                            alert('Das war das falsche Symbol');
                            break;
                        default:
                            $('#newsletterEditForm-form').html(message);
                            $('#newsletterEditForm-form').addClass('info');
                            break;
                    }

                },
                error: function(jqXHR, textStatus, errorThrown) {
                    alert(errorThrown);
                }
            });
        });

    }
    if ($('#newsletterUpdateForm').length > 0)  {
        $('#newsletterUpdateForm').bind('submit', function (event) {
            event.preventDefault();

            ajaxUrl = $('#newsletterUpdateForm').attr('action');
            ajaxUrl += '?id=124&no_cache=1&type=96&';
            ajaxUrl += decodeURIComponent($('#newsletterUpdateForm').serialize());
            $.ajax({
                url: ajaxUrl,
                dataType: 'xml',
                success: function(doc) {


                    resultCode = parseInt($(doc).find('code').text());
                    message = $(doc).find('message').text();

                    switch (resultCode) {
                        case 1:
                            $('#newsletterUpdateForm-message').html(message);
                            $('#newsletterUpdateForm-message').addClass('warning');
                            break;
                        case 2:
                            alert('Das war das falsche Symbol');
                            break;
                        default:
                            $('#newsletterUpdateForm-message').html(message);
                            $('#newsletterUpdateForm-message').addClass('info');
                            break;
                    }

                },
                error: function(jqXHR, textStatus, errorThrown) {
                    alert(errorThrown);
                }
            });
        });

    }

    if ($('#newsletterDeleteForm').length > 0)  {
        $('#newsletterDeleteForm').bind('submit', function (event) {
            event.preventDefault();

            ajaxUrl = $('#newsletterDeleteForm').attr('action');
            ajaxUrl += '?id=125&no_cache=1&type=96&';
            ajaxUrl += decodeURIComponent($('#newsletterDeleteForm').serialize());
            $.ajax({
                url: ajaxUrl,
                dataType: 'xml',
                success: function(doc) {


                    resultCode = parseInt($(doc).find('code').text());
                    message = $(doc).find('message').text();

                    switch (resultCode) {
                        case 1:
                            $('#newsletterDeleteForm-message').html(message);
                            $('#newsletterDeleteForm-message').addClass('warning');
                            break;
                        case 2:
                            alert('Das war das falsche Symbol');
                            break;
                        default:
                            $('#newsletterManage').html(message);
                            $('#newsletterManage').addClass('info');
                            break;
                    }

                },
                error: function(jqXHR, textStatus, errorThrown) {
                    alert(errorThrown);
                }
            });
        });

    }
/*
$(' .fc-agenda-body').hoverIntent(function() {

        $(this).css('-moz-box-shadow','0px 0px 10px #000');
         $(this).css('background','#ff0000');



    }, function () {
        $(this).css('-moz-box-shadow','0px 0px 0px #000');



    });
    */
});
