
////////////////////////////////////////////////////////////////
//
//JQuery-Funktionen
//
////////////////////////////////////////////////////////////////

jQuery.noConflict();

// Use jQuery via jQuery(...)
jQuery(document).ready(function(){




//Fancybox auf Bilder in group2 legen
if(jQuery("a.group").length >  0){	

jQuery("a.group").fancybox({
'hideOnContentClick': true,
'zoomOpacity': true, 
'zoomSpeedChange': 200,
'zoomSpeedIn': 400, 
'zoomSpeedOut': 400, 
'overlayShow': false, 
'overlayOpacity': 1
});

}

//Bilderstrecke starten
jQuery("a#slideshow").css('cursor', 'pointer');
jQuery("a#slideshow").click(function() {
jQuery("a.group:first").click();
});

//Tickertext einblenden
window.setTimeout("jQuery('#tickerInline marquee').css('visibility', 'visible')", 2000);
window.setTimeout("jQuery('#tickerPage marquee').css('visibility', 'visible')", 2000);
window.setTimeout("jQuery('#tickerContent marquee').css('visibility', 'visible')", 2000);
});





//////////////////////////BISTUMSKARTE///////////////////////////
function changeImages() {
if (document.images) {

for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
}
}
}




//////////////////////Tabset Mini //////////////////////////////

jQuery(document).ready(function(){

jQuery(".minitabset .tab_content").hide();

var tabsets = jQuery(".minitabset"); //alle tabsets finden
for(i=0;i<tabsets.length;i++){
jQuery(tabsets[i]).find("ul li:first").addClass('active').show(); // erstes li finden und aktiv setzen
jQuery(tabsets[i]).find(".tab_content:first").show(); // ersten content finden und aktiv setzen
}


jQuery(".minitabset ul li").click(function() { // Action auf jeden link setzen
var parentTag = jQuery(this).parent().parent(); 
parentTag.children("ul").children("li").removeClass("active");
jQuery(this).addClass("active");
parentTag.children("div .tab_content").hide();
var activeTab = jQuery(this).find("a").attr("href");
parentTag.children(activeTab).show();
return false;
});

});


//////////////////////Tabset Mini //////////////////////////////

jQuery(document).ready(function(){

jQuery(".bigtabset .tab_content").hide();

var tabsets = jQuery(".bigtabset"); //alle tabsets finden
for(i=0;i<tabsets.length;i++){
jQuery(tabsets[i]).find("ul li:first").addClass('active').show(); // erstes li finden und aktiv setzen
jQuery(tabsets[i]).find(".tab_content:first").show(); // ersten content finden und aktiv setzen
}


jQuery(".bigtabset ul li").click(function() { // Action auf jeden link setzen
var parentTag = jQuery(this).parent().parent(); 
parentTag.children("ul").children("li").removeClass("active");
jQuery(this).addClass("active");
parentTag.children("div .tab_content").hide();
var activeTab = jQuery(this).find("a").attr("href");
parentTag.children(activeTab).show();
return false;
});

});


//////////////////////////ACCORDION ///////////////////////
var accordionFunction = function(){

jQuery(".accordion_title").unbind('mouseenter');

jQuery(".accordion_content:visible").each(function(){
jQuery(this).slideUp('fast');
});

jQuery(".accordion_title_active").each(function(){
this.className="accordion_title";
});

this.className ="accordion_title_active";
jQuery(this).next(".accordion_content").slideDown('fast', function(){jQuery(".accordion_title").bind('mouseenter', accordionFunction);});
};

jQuery(document).ready(function () {
jQuery(".accordion_title").bind('mouseenter', accordionFunction);
});



/////////////////////scroll horizontal

var activeItemNr;
var maxScrollItems;

//am Anfang alle li's ausblenden und nur die ersten beiden anzeigen
jQuery(document).ready(function() {

activeItemNr = new Object();
maxScrollItems = new Object();

jQuery("ul.scroll3ditems").each(function() {
var tableElement = jQuery(this).parents('table').get(0).id;

activeItemNr[tableElement] = 1;
maxScrollItems[tableElement] = jQuery(this).find('li').size();

showScrollHorizontal(tableElement);
});

jQuery(".scroll3ditemsRight").click(function() {
var tableElement = jQuery(this).parents('table').get(0).id;

activeItemNr[tableElement]++;
if (activeItemNr[tableElement] > maxScrollItems[tableElement]) {
activeItemNr[tableElement] = maxScrollItems[tableElement];
}

showScrollHorizontal(tableElement);
});

jQuery(".scroll3ditemsLeft").click(function() {
var tableElement = jQuery(this).parents('table').get(0).id;

activeItemNr[tableElement]--;
if (activeItemNr[tableElement] < 1) {
activeItemNr[tableElement] = 1;
}

showScrollHorizontal(tableElement);
});
});

function showScrollHorizontal(context) {
counter = 1;
jQuery("#" + context + " .scroll3ditems li").each(
function() {
jQuery(this).hide();
if (counter == activeItemNr[context]
|| counter == activeItemNr[context] + 1) {
jQuery(this).show();
}
counter++;
});

}



/////////////////////scroll gallerie
jQuery(document).ready(function() {

jQuery("div.galeriescroll").each(function() {
var divElement = this.id;

activeItemNr[divElement] = 1;
maxScrollItems[divElement] = jQuery(this).find('div').size();

showScrollHorizontalGallery(divElement);
});


jQuery(".scrollgalleryitemsRight").click(function() {
var divElement = jQuery(this).parents('div').get(0).id;


activeItemNr[divElement]++;
if (activeItemNr[divElement] > maxScrollItems[divElement]) {
activeItemNr[divElement] = maxScrollItems[divElement];
}

showScrollHorizontalGallery(divElement);
});

jQuery(".scrollgalleryitemsLeft").click(function() {
var divElement = jQuery(this).parents('div').get(0).id;

activeItemNr[divElement]--;
if (activeItemNr[divElement] < 1) {
activeItemNr[divElement] = 1;
}

showScrollHorizontalGallery(divElement);
});


});


function showScrollHorizontalGallery(context) {
counter = 1;

jQuery("#" + context + " div.galleryPicFloat").each(
function() {
jQuery(this).hide();
if (counter == activeItemNr[context] || counter == activeItemNr[context] + 1 || counter == activeItemNr[context] + 2 || counter == activeItemNr[context] + 3) {
jQuery(this).show();
}
counter++;
});
}



/////////////////////JS Blättern

function paginateJS(id){

	//how much items per page to show
	var show_per_page = 1;
	var parentElement = "#"+id;
	
	//getting the amount of elements inside content div
	var number_of_items = jQuery(parentElement).children().size();
	
	//calculate the number of pages we are going to have
	var number_of_pages = Math.ceil(number_of_items/show_per_page);

	//set the value of our hidden input fields
	jQuery('#current_page'+id).val(0);
	jQuery('#show_per_page'+id).val(show_per_page);

	//now when we got all we need for the navigation let's make it '

	/*
	what are we going to have in the navigation?
		- link to previous page
		- links to specific pages
		- link to next page
	*/
	var navigation_html = '<a class="previous_link" href="javascript:previous(\''+id+'\');"><img src="/wGlobal-2011/wGlobal/layout/images/news_back.png" border="0"/></a>';
	var current_link = 0;
	navigation_html += '<div class="nrs">';
	while(number_of_pages > current_link){
		//navigation_html += '<a class="page_link" href="javascript:go_to_page(' + current_link +',\''+id+'\')" longdesc="' + current_link +'">'+ (current_link + 1) +'</a>';
		navigation_html += '<a class="page_link" href="javascript:go_to_page(' + current_link +',\''+id+'\')" longdesc="' + current_link +'">&nbsp;</a>';
		
		
		current_link++;
	}
	navigation_html += '</div>';
	navigation_html += '<a class="next_link" href="javascript:next(\''+id+'\');"><img src="/wGlobal-2011/wGlobal/layout/images/news_next.png" border="0"/></a>';

	jQuery('#page_navigation'+id).html(navigation_html);

	//add active_page class to the first page link
	jQuery('#page_navigation'+id+' .page_link:first').addClass('active_page');

	//hide all the elements inside content div
	jQuery(parentElement).children().css('display', 'none');

	//and show the first n (show_per_page) elements
	jQuery(parentElement).children().slice(0, show_per_page).css('display', 'block');

}


function previous(id){

	new_page = parseInt(jQuery('#current_page'+id).val()) - 1;
	//if there is an item before the current active link run the function
	if(jQuery('.active_page').prev('.page_link').length==true){
		go_to_page(new_page,id);
	}

}

function next(id){
	new_page = parseInt(jQuery('#current_page'+id).val()) + 1;
	//if there is an item after the current active link run the function
	if(jQuery('.active_page').next('.page_link').length==true){
		go_to_page(new_page,id);
	}

}
function go_to_page(page_num,id){
	//get the number of items shown per page
	
	var show_per_page = parseInt(jQuery('#show_per_page'+id).val());
	var parentElement = "#"+id;

	//get the element number where to start the slice from
	start_from = page_num * show_per_page;

	//get the element number where to end the slice
	end_on = start_from + show_per_page;

	//hide all children elements of content div, get specific items and show them
	jQuery(parentElement).children().css('display', 'none').slice(start_from, end_on).css('display', 'block');

	/*get the page link that has longdesc attribute of the current page and add active_page class to it
	and remove that class from previously active page link*/
	jQuery('.page_link[longdesc=' + page_num +']').addClass('active_page').siblings('.active_page').removeClass('active_page');

	//update the current page input field
	jQuery('#current_page'+id).val(page_num);
}


jQuery(document).ready(function(){
	
	jQuery('.hiddenresult').each(function(index){
		paginateJS(jQuery(this).attr('id'));
		});
	
	
});




///ENDE JS Blätter


jQuery(document).ready(function($) {


jQuery('div.gallerificnavigation').each(function(){

// We only want these styles applied when javascript is enabled
jQuery('div.gallerificnavigation').css({'width' : '200px', 'float' : 'left'});
jQuery('div.content').css('display', 'block');

// Initially set opacity on thumbs and add
// additional styling for hover effect on thumbs
var onMouseOutOpacity = 0.67;
jQuery('#thumbs ul.thumbs li').opacityrollover({
mouseOutOpacity:   onMouseOutOpacity,
mouseOverOpacity:  1.0,
fadeSpeed:         'fast',
exemptionSelector: '.selected'
});

// Enable toggling of the caption
var captionOpacity = 0.0;
jQuery('#captionToggle a').click(function(e) {
var link = $(this);

var isOff = link.hasClass('off');
var removeClass = isOff ? 'off' : 'on';
var addClass = isOff ? 'on' : 'off';
var linkText = isOff ? 'Beschreibung ausblenden' : 'Beschreibung anzeigen';
captionOpacity = isOff ? 0.7 : 0.0;

link.removeClass(removeClass).addClass(addClass).text(linkText).attr('title', linkText);
jQuery('#caption span.image-caption').fadeTo(1000, captionOpacity);

e.preventDefault();
});

// Initialize Advanced Galleriffic Gallery
var gallery = jQuery('#thumbs').galleriffic({
delay:                     2500,
numThumbs:                 10,
preloadAhead:              10,
enableTopPager:            true,
enableBottomPager:         true,
maxPagesToShow:            2,
imageContainerSel:         '#slideshow',
controlsContainerSel:      '#controls',
captionContainerSel:       '#caption',
loadingContainerSel:       '#loading',
renderSSControls:          true,
renderNavControls:         true,
playLinkText:              'Play Slideshow',
pauseLinkText:             'Pause Slideshow',
prevLinkText:              '&lsaquo; zurück',
nextLinkText:              'weiter &rsaquo;',
nextPageLinkText:          '&rsaquo;&rsaquo;',
prevPageLinkText:          '&lsaquo;&lsaquo;',
enableHistory:             true,
autoStart:                 false,
syncTransitions:           true,
defaultTransitionDuration: 900,
onSlideChange:             function(prevIndex, nextIndex) {
// 'this' refers to the gallery, which is an extension of $('#thumbs')
this.find('ul.thumbs').children()
.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
.eq(nextIndex).fadeTo('fast', 1.0);
},
onTransitionOut:           function(slide, caption, isSync, callback) {
slide.fadeTo(this.getDefaultTransitionDuration(isSync), 0.0, callback);
caption.fadeTo(this.getDefaultTransitionDuration(isSync), 0.0);
},
onTransitionIn:            function(slide, caption, isSync) {
var duration = this.getDefaultTransitionDuration(isSync);
slide.fadeTo(duration, 1.0);

// Position the caption at the bottom of the image and set its opacity
var slideImage = slide.find('img');
caption.width(slideImage.width())
.css({
'bottom' : Math.floor((slide.height() - slideImage.outerHeight()) / 2),
'left' : Math.floor((slide.width() - slideImage.width()) / 2) + slideImage.outerWidth() - slideImage.width()
})
.fadeTo(duration, captionOpacity);
},
onPageTransitionOut:       function(callback) {
this.fadeTo('fast', 0.0, callback);
},
onPageTransitionIn:        function() {
this.fadeTo('fast', 1.0);
},
onImageAdded:              function(imageData, $li) {
$li.opacityrollover({
mouseOutOpacity:   onMouseOutOpacity,
mouseOverOpacity:  1.0,
fadeSpeed:         'fast',
exemptionSelector: '.selected'
});
}
});


});

/****************************************************************************************/
});



function goTellAFriend(path){
	document.location.href = path + "/seite-empfehlen/index.php?page="+window.location.pathname;
} 

function clearSearchField(searchfield){
	
	if(searchfield.value == "Suchbegriff eingeben..."){
		searchfield.value = "";
	}
} 


///////////////////Seite kommentieren

function getBistumCommentForm(searchfield){
	
	if (jQuery("#commentsFormArea").is(":hidden")) {
		jQuery("#commentsFormArea").slideDown("slow");
	} 
	//else {
	//	jQuery("#commentsFormArea").hide("slow");
	//}
	
} 



function getBistumGuestBookForm(searchfield){
	
	if (jQuery("#guestbookFormArea").is(":hidden")) {
		jQuery("#guestbookFormArea").slideDown("slow");
	} 
	//else {
	//	jQuery("#commentsFormArea").hide("slow");
	//}
	
} 

	


