// no conflicts with other libraries
jQuery.noConflict();

// adjust background
(function(jQuery){
	jQuery.fn.backdrop = function() {
		jQuery(document).ready(function() {
			jQuery('#backdrop').resizenow();
		});
		jQuery(window).bind("resize", function() {
		jQuery('#backdrop').resizenow();
		});
	};
	jQuery.fn.resizenow = function() {
		// GROESSE DER BILDDATEI EINTRAGEN - ZUM SEITENVERHAELTNIS-ERHALT
		var startwidth = 1250;
		var startheight = 925;
		var ratio = startheight/startwidth;

		var browserwidth = jQuery(window).width();
		var browserheight = jQuery(window).height();

		if ((browserheight/browserwidth) > ratio) {
				jQuery(this).height(browserheight);
				jQuery(this).width(browserheight / ratio);
				jQuery(this).children().height(browserheight);
				jQuery(this).children().width(browserheight / ratio);
		} else {
				jQuery(this).width(browserwidth);
				jQuery(this).height(browserwidth * ratio);
				jQuery(this).children().width(browserwidth);
				jQuery(this).children().height(browserwidth * ratio);
		}
		//POSITIONIERUNG IN SEITENMITTE
		jQuery(this).children().css('left', (browserwidth - jQuery(this).width())/2);
		//jQuery(this).children().css('top', (browserheight - jQuery(this).height())/2);
		jQuery(this).children().css('top', 0);
	};
})(jQuery);

// when document is loaded
jQuery(document).ready(function(){

	// *** adjust background ***
	jQuery("div#backdrop").backdrop(); 


	// *** teaser box ***

	// hide (Collapse) the toggle containers on load
	jQuery(".teaserbox-body").hide(); 

	// switch the "Open" and "Close" state per click
	jQuery("h3.teaser-trigger").toggle(function(){
		jQuery(this).addClass("active");
		}, function () {
		jQuery(this).removeClass("active");
	});

	// slide up and down on click
	jQuery("h3.teaser-trigger").click(function(){
		jQuery(this).next(".teaserbox-body").slideToggle("slow");
	});


	// *** phone numbers ***

	// enlarge phone numbers
	jQuery("ul.phone li").hover(function() {
		jQuery(this).css({'z-index' : '10'});
		jQuery(this).find('img').addClass("hover").stop()
			.animate({
				marginTop: '-22px', 
				marginLeft: '-18px', 
				top: '50%', 
				left: '50%', 
				width: '32px', 
				height: '48px',
				padding: '0px' 
			}, 200);
		
		} , function() {
		jQuery(this).css({'z-index' : '0'});
		jQuery(this).find('img').removeClass("hover").stop()
			.animate({
				marginTop: '0', 
				marginLeft: '0',
				top: '0', 
				left: '0', 
				width: '16px', 
				height: '24px', 
				padding: '0'
			}, 400);
	});
 
	// swap Image on Click
	jQuery("ul.phone li a").click(function() {
		/*
		var mainImage = jQuery(this).attr("href"); //Find Image Name
		jQuery("#main_view img").attr({ src: mainImage });
		*/
		startStopMusic();
		return false;		
	});
});

