$(document).ready(function(){
	

	$("a.single_image").fancybox({
		'zoomSpeedIn': 300,
		'zoomSpeedOut': 300,
		'overlayOpacity': 0.8,
		'overlayColor': '#000000',
		'titlePosition': 'inside',
		'scrolling': 'no'
	}); 


function formatTitle(title, currentArray, currentIndex, currentOpts) {
	if(title)
	{
		var newtitle = '';
		var titleob = title.split("'");
		if(titleob[1]) newtitle+= '<span>'+titleob[1]+'</span><br />';
		if(titleob[2]) newtitle+= titleob[2];
		if(titleob[0]) newtitle = titleob[0];
		newtitle = newtitle.replace(/ — /g, "<br />");
		if(newtitle) return '<div id="bild-title">'+ newtitle +'</div>';
	}
}


	$("a.group").fancybox({
		'zoomSpeedIn': 300,
		'zoomSpeedOut': 300,
		'overlayOpacity': 0.8,
		'overlayColor': '#000000',
		'titlePosition': 'outside',
		'margin': 100,
		'scrolling': 'no',
		'titleFormat'	: formatTitle
	});
	
	
	$("a.iframe").fancybox({
		'zoomSpeedIn': 300,
		'zoomSpeedOut': 300,
		'overlayOpacity': 0.8,
		'overlayColor': '#000000',
		'titlePosition': 'outside',
		'width' : 800,
		'height' : 510
	});
		
		
		
	$(document).pngFix();
	
	$('.BOXcontent').css('opacity', '0');
	$('.BOXcontent').hide();
	$('.BOX_link').css('opacity', '0');
	
	$(".BOX").hover(function(){
		$(this).children('.BOXcontent').show();
		var hei = $(this).children('.BOXcontent').height();
		$(this).animate({top: '-'+(Number(hei)-17)+'px'}, 300,function(){ $(this).children('.BOXcontent').animate({opacity: '1'},300); $('.BOX_link').css('opacity', '1'); });
	},function(){
		
		$(this).stop(true, true).css({'top': '-29px'});
		$(this).children('.BOXcontent').stop(true, true).css('opacity', '0');
		$('.BOX_link').css('opacity', '0');
		$(this).children('.BOXcontent').hide();
		});

});

$(window).resize(function(){
proportion();
});


function launch_fancybox(id) {
   $("#"+id).trigger('click');
} 


function proportion(){
	imgrel = 1400 / 988;
	bodyrel = $('body').width() / $('body').height();

	if (bodyrel < imgrel){
	$('#bg').height($('body').height());
	$('#bg').width($('body').height()*imgrel);
}
else {
	$('#bg').width($('body').width());
	$('#bg').height($('body').width()/imgrel);
 }
}

function checkbetrag(formu,feld,stellen)	{
	
	var plu = 1+stellen;
	var komma1 = '.';
	var komma2 = '';
	
	for(i=1; i<= stellen; i++){
			komma1 = komma1+'0';
			komma2 = komma2+'0';
	}
	
	pfad = eval('document.'+formu+'.'+feld);
	x = pfad.value;
	x = x.replace(/\./g,"");
	x = x.replace(" ", "")
	x = x.replace(",", ".")
	x = parseFloat(x); if(isNaN(x)){x = 0;}
  var k = (Math.round(x * 100) / 100).toString();
  k += (k.indexOf('.') == -1)? komma1 : komma2;
  var p = k.indexOf('.'), m = k.indexOf('-.');
  var f = (p == 0 || m == 0)? '0,' : ',';
  x = k.substring(0, p) + f + k.substring(p+1, p+plu);
  x = x.replace(",", ";");
  while(x.match(/^(\d+)(\d{3}\b)/)) {
		x = x.replace(/^(\d+)(\d{3}\b)/,RegExp.$1+','+RegExp.$2);
	}	
	x = x.replace(/\,/g,".");
	pfad.value = x.replace(";", ",");
}

var win = null;
function WindowZentriert(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=0,toolbar=0,location=0,directories=0,status=0,menuBar=0'
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}


















