

jQuery.noConflict();
jQuery(document).ready(function(){

/*
*  hover-effect "News"
*
********************************* */

 	// Hide the tooglebox when page load
	// jQuery(".news-list-item").find("p").hide();
	// jQuery(".cal-list-item").find("p").hide();

	jQuery(function() {
                jQuery( ".news-list-container" ).accordion({
                        event: "mouseover",
                        autoHeight: "false",
                        active: "false",
                	change: function(event, ui) {
				jQuery(this).find('p').mouseover(function () {
					jQuery(this).prev().addClass('ui-focus');
				});

				jQuery(this).find('h3').mouseover(function () {
                                        jQuery(this).addClass('ui-focus');
                                });

				jQuery(this).find('p').mouseout(function () {
					 jQuery(this).prev().removeClass('ui-focus');
				}); 
				
				jQuery(this).find('h3').mouseout(function () {
                                         jQuery(this).removeClass('ui-focus');
                                }); 
	
				//if(!(jQuery('.news-list-container').find('h3').hasClass('ui-state-hover'))) {
				//	jQuery(this).find('p').hide();
                                //}
			}
		});
	});


	jQuery(function() {
                jQuery( ".list-view" ).accordion({
                        event: "mouseover",
                        autoHeight: "false",
                        active: "false",
                        /*collapsible: "true"*/
                });
        });


/*	jQuery(".news-list-container").mouseout(function () {
		if(jQuery('.news-list-container').children("h3.ui-state-hover").length == 0) {
			jQuery(".news-list-container").find("p").hide();
		        jQuery(".cal-list-item").find("p").hide();
		}
	});
*/	

	// SlideToggle News-Section
	/*jQuery(".news-list-item").hover(function () {
         	if(jQuery(this).find("p").is(":hidden")) {
			jQuery(".news-list-item").find("p").slideUp("100");
			jQuery(this).find("p").slideDown('10');
                } else {
                        jQuery(this).find("p").slideUp("fast");
                }

        });*/

	// SlideToggle Cal-Section
	/*jQuery(".cal-list-item").hover(function () {
              	if(jQuery(this).find("p").is(":hidden")) {
                        jQuery(".cal-list-item").find("p").slideUp("100");
			jQuery(this).find("p").slideDown("10");
                } else {
                	jQuery(this).find("p").slideUp("fast");
                }

        });*/


/*
*  hover-effect "Standortkarte"
*
********************************* */

        jQuery("img[src|='/fileadmin/Benutzer/Bilder/Abteilungen/Standort-Karte.jpg']").wrap("<div id='img-location'></div>");
        jQuery("img[src|='/fileadmin/Benutzer/Bilder/Abteilungen/Standort-Karte.jpg']").after("<div class='retina'></div>");
        jQuery(".retina").append("<div class='lupe'></div>");

        jQuery('#img-location').mousemove(function(e){

        // init
        var location     = jQuery('#img-location').offset();
        var rounds               = 4
        var pos                  = new Array(4);

                // position-top, -bottom, -left, -right, name, address)
                pos[0] = new Array('70','90','140','240','schwedt','laborverbund/laborstandorte/schwedt/');
                pos[1] = new Array('170','190','120','260','bernau','laborverbund/laborstandorte/bernau/');
                pos[2] = new Array('220','240','150','250','ruedersdorf','laborverbund/laborstandorte/ruedersdorf/');
                pos[3] = new Array('190','220','20','80','hennigsdorf','#');
                pos[4] = new Array('240','270','20','100','zehlendorf','laborverbund/laborstandorte/zehlendorf/');

        if(!(e.pageY <= ((location.top)+65) || e.pageY >= ((location.top)+310) ||
             e.pageX <= ((location.left)+27) || e.pageX >= ((location.left)+280) )) {

                //set CSS
                var positionTop  = (e.pageX-location.left)-40;
                var positionLeft = (e.pageY-location.top)-60;

                jQuery(".retina").css({
                  'left': (e.pageX-location.left),
                  'top' : (e.pageY-location.top),
                  'backgroundPosition':'-'+ positionTop +'px -'+ positionLeft +'px'
                });

                //show element
                //$('.lupe').css("background-image", "url(../images/lupe_v4.png)");
                jQuery(".retina").show();
        } else {

                //hide element
                jQuery(".retina").hide();
        }

        for(var i=0; i<=rounds; i++) {
                var place = jQuery("."+ pos[i][4] +"");

                if(!(e.pageY <= location.top +parseInt(pos[i][0]) || e.pageY >= location.top +parseInt(pos[i][1]) ||
                         e.pageX <= location.left+parseInt(pos[i][2]) || e.pageX >= location.left+parseInt(pos[i][3]) )) {

                        //$('.lupe').css("background-image", "none");
                        jQuery('.lupe').html('<a class="'+ pos[i][4] +'" href="http://www.hospital-laborverbund.de/'+ pos[i][5] +'"></a>');
                        place.show();
                } else {
                        jQuery('.lupe').children().empty();
                        place.hide();
                        //$('.lupe').css("background-image", "url(../images/lupe_v4.png)");
                }
         }
        });

/*
*  Slider-Menu "Standortkarte"
*
********************************* */

	// jQuery("#subnav li:nth-child(4) a").attr('href','#');

	jQuery("#subnav li:nth-child(4)").click(function () { 
		// jQuery("#subnav ul ul").children().slideToggle();
		 
		if(jQuery("#subnav li:nth-child(4) ul").is(":visible")) {
                       // jQuery("#subnav li:nth-child(4)").next(a).removeClass("act");
		} else {
                       //  jQuery("#subnav li:nth-child(4)").next(a).addClass("act");
                }
	});

});


