$(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").fancybox({
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'titlePosition':'inside'
	});
	
		$("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.video2, a.video3").fancybox({
		'width'				: 550,
		'height'			: 360,
        'autoScale'     	: true,
        'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true,
		'type'				: 'iframe'
	});

	$("a[rel=lightbox]").fancybox({
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayOpacity': .8,
		'titlePosition' 	: 'over'
	});

	$("a.thickbox").fancybox({
		'width'				: '98%',
		'height'			: '98%',
        'autoScale'     	: true,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true,
		'type'				: 'iframe'
	});

		$("a.thickboxrechner").fancybox({
		'width'				: 740,
		'height'			: 520,
        'autoScale'     	: true,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true,
		'type'				: 'iframe'
	});
	$("a.sofort").fancybox({
        'autoScale'     	: true,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true,
		'titleShow':false,
		'type'				: 'iframe'
	});

		$("a.thickboxM").fancybox({
		'width'				: 680,
		'height'			: 500,
        'autoScale'     	: true,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'overlayOpacity': .8,
		'overlayColor': '#000',
		'centerOnScroll': true,
		'type'				: 'iframe'
	});
	
	$("a.amazon").fancybox({
		'width'				: 750,
		'height'			: 600,
        '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'
}); 
	
});



$(document).ready(function() {
	$('a[href*=#holder]').bind("click", function(event) {
		event.preventDefault();
		var ziel = $(this).attr("href");

		$('html,body').animate({
			scrollTop: $(ziel).offset().top
		}, 500 , function (){location.hash = ziel;});
});

	$('a[href*=#artenp]').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, .down').hover(function() {
  		$(this).addClass('hover');
		}, function() {
		$(this).removeClass('hover');
});	
/*$('.sofort').hover(function() {
  		$(this).addClass('hover');
		}, function() {
		$(this).removeClass('hover');
});	*/

	$('a[href*=#grab]').bind("click", function(event) {
		event.preventDefault();
		var ziel = $(this).attr("href");

		$('html,body').animate({
			scrollTop: $(ziel).offset().top
		}, 500 , function (){location.hash = ziel;});
});
return false;
});

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 getmessageBox(){
	var anzahl;
	var bild;
	var tit;
	var writ="";
						
	anzahl = xmlDoc.getElementsByTagName("item").length;
	while (i < anzahl){
		bild = xmlDoc.getElementsByTagName("bild")[i].childNodes[0].nodeValue;
		tit = xmlDoc.getElementsByTagName("title")[i].childNodes[0].nodeValue;
		writ += "<a href='images/gr/"+bild+".jpg' rel='lightbox_slide' id='"+bild+"' title='"+tit+"' target='_blank' ></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+' Bild ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
		}
	});
}
/*
function callFancy(m_href,titel, id) { 
	//var j1 = document.getElementById(id); 
	//j1.href = m_href; 
	//j1.title = titel;
	//alert(m_href+"   "+titel+"   "+  id);
	var ff = "#"+id;
	$(ff).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>';
		}
	}).trigger('click'); 
} */


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

function sb(nr){
	var did = "#"+nr;
	$(did).trigger('click'); 
	}
