$(document).ready(function() {

	$("a#single_image").fancybox();
	
	/* Using custom settings */
	
	$("a#inline").fancybox({
		'hideOnContentClick': true
	});

	$("a.group").fancybox({
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'titlePosition':'inside'
	});
$("a.illu, a.ifr").fancybox({
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'titlePosition':'inside'
	});
	$(".img, .th, .txtlnk, #imre").fancybox({
        'autoScale'     	: true,
        'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true
	});

$("a.ifa, a.shilfe").fancybox({
		'width'			: 620,
		'height'		: 520,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true,
		'type'			: 'iframe'
	});
		$("a[rel=lightbox[raum]]").fancybox({
		'speedIn'		:	800, 
		'speedOut'		:	800, 
		'overlayShow'	:	true,
		'overlayOpacity': .8,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over'/*,
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">'+title+'Bild ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
		}*/
	});
	$("a.friedhof").fancybox({
		'width'				: 750,
		'height'			: 650,
        'autoScale'     	: true,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true,
		'type'				: 'iframe'
	});
	$("a[rel=video]").fancybox({
		'width'				: 500,
		'height'			: 390,
        'autoScale'     	: true,
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true,
		'type'				: 'iframe'
	});
	
	$("a[rel=lightbox-dia],a[rel=li2]").fancybox({
		'speedIn'		:	800, 
		'speedOut'		:	800, 
		'overlayShow'	:	true,
		'overlayOpacity': .8,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">'+title+' <span class="anz">Bild ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span></span>';
		}
	});
	$("a[rel=lightbox],a[rel=li],a[rel=li2]").fancybox({
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayOpacity': .8,
		'titlePosition' 	: 'over'
	});
	$("a.t_link").fancybox({
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayOpacity': .8,
		'titlePosition' 	: 'over'
	});
$("a.produkte,a[rel=produkte]").fancybox({
		'width'				: 750,
		'height'			: 520,
        'autoScale'     	: true,
        'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'centerOnScroll': true,
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">'+title+' <span class="anz">Bild ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span></span>';
		}
		
	});
$("a.weg9").fancybox({
		'width'				: "90%",
		'height'			: "90%",
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true,
		'type'				: 'iframe'
	});
	$("a.thickbox").fancybox({
		'width'				: 820,
		'height'			: 590,
        'autoScale'     	: true,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true,
		'type'				: 'iframe'
	});
$("a.thickbox_rechner").fancybox({
		'width'				: 820,
		'height'			: 590,
        'autoScale'     	: true,
        'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true,
		'type'				: 'iframe'
	});
	$("a.umsicht").fancybox({
		'width'				: 750,
		'height'			: 560,
		'speedIn'		:	600, 
		'speedOut'		:	200, 
        'autoScale'     	: false,
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true,
		'type'				: 'iframe'
	});
	
	$("a.amazon").fancybox({
		'width'				: 750,
		'height'			: '90%',
        'autoScale'     	: true,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true,
		'type'				: 'iframe'
	});
	$("a.thickbox2").fancybox({
		'width'				: '75%',
		'height'			: '75%',
        'autoScale'     	: true,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'overlayOpacity': .8,
		'centerOnScroll': true,
		'overlayColor': '#000',
		'type'				: 'iframe'
	});
	
	$("a.overlay-flash").fancybox({ 
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'titlePosition':'inside'
}); 
		
		$("a.thickbox-slide").fancybox({
		'width'				: 700,
		'height'			: 500,
        'autoScale'     	: true,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'scrolling'			: 'no',
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true,
		'type'				: 'iframe'
	});
	
	$("a.scroll").fancybox({
		'width'				: 640,
		'height'			: 500,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'scrolling'			: 'auto',
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true,
		'type'				: 'iframe'
	});
	
		$("a[rel=lightbox_slide],a[rel=lightbox3],a[rel=lightbox4],a[rel=lightbox5],a[rel=lightbox6],a[rel=lightbox7]" ).fancybox({
		'speedIn'		:	800, 
		'speedOut'		:	800, 
		'overlayShow'	:	true,
		'overlayOpacity': .8,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'showNavArrows'		: true,
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">'+title+'  (' +  (currentIndex + 1) + '/' + currentArray.length + ')</span>';
		}
	});
	
});



$(document).ready(function() {
		$('div.links').bind("click", function(event) {
		  window.open($(this).attr("url"));
		});
	
	
	$('a[href*=#navi],a[href*=#map]').bind("click", function(event) {
			event.preventDefault();
			var ziel = $(this).attr("href");
	
			$('html,body').animate({
				scrollTop: $(ziel).offset().top
			}, 500 , function (){location.hash = ziel;});
	});
		
		
	
	$('div.hdiv, div.buch, .bs p, div.down, .links').hover(function() {
			$(this).addClass('hover');
			}, function() {
			$(this).removeClass('hover');
	});	
	
	$('.unter a').hover(function() {
			$(this).parent().parent().addClass('hoverbg');
			$(this).parents(".ueber").addClass('hover');
			}, function() {
			$(this).parents(".ueber").removeClass('hover');
			$(this).parent().parent().removeClass('hoverbg');
	});
	
	
	$('.ueber a').hover(function() {
			$(this).next().addClass('hoverbg');
			}, function() {
			$(this).next().removeClass('hoverbg');
	});	
	$('.musik').hover(function() {
			$(this).addClass('hoverbg');
			}, function() {
			$(this).removeClass('hoverbg');
	});	
	$('#musik p').hover(function() {
			$(this).addClass('hoverbg');
			}, function() {
			$(this).removeClass('hoverbg');
	});	
	
	$('.down, .hdiv2, .buch').hover(function() {
			$(this).addClass('hoverbg');
			}, function() {
			$(this).removeClass('hoverbg');
	});
	
	
$(".unav").hide();
 var alteNav = null;
	$(".usel,.sel").click(function(){
		if ($('.unav:visible').length) {
				$('.unav').slideUp("slow");
	    } else {}
	
		var slide = $(this).next().attr("id");
		if ($('#'+slide).is(":hidden")) {
			$('#'+slide).slideDown("slow");
			
			$(this).addClass('tsel');
			$('#'+alteNav).removeClass('tsel');
			alteNav = $(this).attr("id");
		}
		else{
		
		}
            return false;
	});	
	

});


var xmlDoc;
var fil = null;
var i = 0;
var u = 0;
var writ = "";
var obj;



var xmlDoc;
var fil = null;
var i = 0;
var writ;
function importXML(file, art){
if (window.ActiveXObject)
        {
        xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async=false;
        xmlDoc.load(file);
        getmessage();
			if(art==1){
					getmessageBox();
			}
			else{
					getmessage();
			}
        }
      else if (document.implementation && document.implementation.createDocument)
        {
        xmlDoc=document.implementation.createDocument("","",null);
        xmlDoc.load(file);
		
			if(art==1){
				xmlDoc.onload=getmessageBox;
			}
			else{
				xmlDoc.onload=getmessage;
			}
        }
      else
        {
        alert('Script wird nicht unterstuetzt');
        }
}
/*
function getmessage(){
	var anzahl;
	var bild;
	var writ="";
	anzahl = xmlDoc.getElementsByTagName("slide").length;
	while (i < anzahl){
		bild = xmlDoc.getElementsByTagName("slide")[i].attributes[1].value;
		writ += "<a href='images/gr/"+bild+".jpg' rel='lightbox_slide' id='"+bild+"' target='_blank'></a>";
		i++;
	}
		document.getElementById("slide").innerHTML = writ;
		$("a[rel=lightbox_slide]").fancybox({
		'speedIn'		:	800, 
		'speedOut'		:	800, 
		'overlayShow'	:	true,
		'overlayOpacity': .8,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">Bild ' +  (currentIndex + 1) + '/' + currentArray.length + '</span>';
		}
	});
}
*/

function getmessage(xml, dnamed){
	var bild;
	var title;
	var writ="";
	var i= 0;
$(xml).find("item").each(function()
  {
	 title =  $(this).find("title").text();
	 bild =  $(this).find("imagelink").text();
	 writ += "<a href=\""+bild+"\" rel=\"slide"+dnamed+"\" id=\""+bild+"\" target=\"_blank\" title=\""+title+"\"></a>";
	i++;
  });
	var slideName = "slide"+dnamed;
	var gg = "a[rel="+slideName+"]";
	//alert(writ);
	document.getElementById(slideName).innerHTML = writ;
$(gg).fancybox({
		'speedIn'		:	800, 
		'speedOut'		:	800, 
		'overlayShow'	:	true,
		'overlayOpacity': .8,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    //return '<span id="fancybox-title-over">'+title+' Bild ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
			return '<span id="fancybox-title-over">'+title+ '<span style="font-size:80%;color:#333;margin-left:10px;"> Bild ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span></span>';
		}
	});
}


function getmessageBox(){
	var anzahl= 0;;
	var bild;
	var tit;
	var writ="";
	var x;
	var y;
	anzahl = xmlDoc.getElementsByTagName("item").length;
	var i = 0;
	while (i < anzahl){
		bild = xmlDoc.getElementsByTagName("imagelink")[i].childNodes[0].nodeValue;
		tit = xmlDoc.getElementsByTagName('title')[i].childNodes[0].nodeValue;
		writ += "<a href='"+bild+"' rel='lightbox_slide' id='"+bild+"' title='"+tit+"' target='_blank' >"+i+"</a>";
		i++;
	}
		document.getElementById("slideBox").innerHTML = writ;
		$("a[rel=lightbox_slide]").fancybox({
		'speedIn'		:	800, 
		'speedOut'		:	800, 
		'overlayShow'	:	true,
		'overlayOpacity': .8,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">'+title+' <span style="font-size:80%;color:#999">Bild ' +  (currentIndex + 1) + '/' + currentArray.length + '</span></span>';
		}
	});
}

function callFancy(m_href,titel) { 
	var j1 = document.getElementById(m_href); 
	//j1.href = m_href; 
	//j1.title = titel;
	$(j1).trigger('click'); 
} 

function sb(nr){
	var j1 = document.getElementById('imre'); 
	j1.href = "images/gr/"+nr; 
	$(j1).trigger('click'); 
	}

var sit;
function setNav(nid){
	sit = nid;
	document.getElementById(nid).className = 'top_parent_n';
}
function in_n(nid) {
	if( document.getElementById(nid).className == 'top_parent_n'){
  		document.getElementById(nid).className = 'top_parent_n';
	}
	else{
		document.getElementById(nid).className = 'top_parent_n';
	}
}
function out_n(nid) {	
	if(sit==nid){
		 document.getElementById(nid).className = 'top_parent_n';
	}
	else{
	 	 document.getElementById(nid).className = 'top_parent';
	}
}
