	// IE font-face ClearType fix - V0.1
	// Authord by Michael Strand of Allcreatives.net
	// Usage, changes, FAQ etc. see - http://allcreatives.net/2009/12/05/jquery-plugin-ie-font-face-cleartype-fix/
	// The IE font-face ClearType fix plugin is dual licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php) and 
	// [GPL](http://www.opensource.org/licenses/gpl-license.php) licenses.
	
	// There is one configuration setting to be changed below if you have the PNG image in different location from this file.
	
	(function($) {
	    $.fn.ieffembedfix = function() {
			
			// CONFIGURE THE PATH TO YOUR 1BY1 PNG HERE, RELATIVE TO THE LOCATION OF THIS JS FILE.
			
			var pngimgurl = "/js/hIEfix.png";
			
	    return this.each(function() {
	        //check for IE7/8
	        if ($.browser.msie) {
	            $(this).css({
							
							filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + pngimgurl + ",sizingMethod=crop',
							zoom: '1'
							});
	        }
	        });
	    }
	})(jQuery);

	
	// Google WebFont Loader
	
	WebFontConfig = {
		google: { families: [ 'Copse:400', 'Cabin:400,700' ] }
	};
	
	(function() {
		var wf = document.createElement('script');
		wf.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
		wf.type = 'text/javascript';
		wf.async = 'true';
		var s = document.getElementsByTagName('script')[0];
		s.parentNode.insertBefore(wf, s);
	})();

	
	// jQuery on DOM Ready
	
	$(document).ready(function(){

		// External Links

		$('a.external').attr('target','_blank');

		// Pulldown Menu

			// size and position by longest submenu
	
			var t=0;
			var t_elem;
			
			$("#nav-main .sub").each(function () {
			    $this = $(this);
			    if ( $this.outerHeight() > t ) {
			        t_elem=this;
			        t=$this.outerHeight();
			    }
			});
			
			em_val = t/10;
			em_height = em_val - 4;
			
			// Append menu background
	
			$('#nav-main').append('<div class="submenu" style="height:'+em_val+'em; bottom:-'+em_val+'em;"></div>');
			
			// Set same height to all sub entries
			
			$('#nav-main .sub').css('height',em_height+'em');

			// Open on tab hover
	
			$('#nav-main .top').hover(function(){
				$('#nav-main').addClass('showmenu');
				$(this).addClass('hover');
			}, function(){
				$('#nav-main').removeClass('showmenu');
				$(this).removeClass('hover');
			});


			// Galery
			var gallery = $('.pictures-thumbs');
			var gal_thumbs;
			var page_size = 3;
			var picture_count;
			var total_pages;

			gallery.each(function(index, item) {

				gal_thumbs = $('.thumb', this);
				picture_count = $(gal_thumbs).length;

				// scrolling pages

				if(picture_count > page_size)
				{
					// total pages
					total_pages = Math.ceil(picture_count / page_size);

					// gallery wrap width
					$('.slider', this).css('width',(total_pages * 64.5)+'em');

					// add pagination div
					$(this).append('<div class="image-pagination"></div>');

					// create links
					for(i=0;i<total_pages;i++) {
						$('.image-pagination', this).append('<a href="#">&bull;</a>');
					}

					// make first active
					$('.image-pagination a:first', this).addClass('active');

					// pagination buttons click
					var page_links = $('.image-pagination a', this);

					$(page_links).click(function(event){

						event.preventDefault();

						var gotopage = ($(page_links).index(this)+1);
						var index = $(page_links).index(this);

						$(page_links).removeClass('active');
						$(page_links[index]).addClass('active');

						$(this).parent().parent().find('.slider').animate({left: (index * (-64.5)+'em')}, 500);

					});
				}

			});





			// Fancybox
			$("a.thumb").fancybox({
				'speedIn'		:	0, 
				'speedOut'		:	0, 
				'overlayShow'	:	true,
				'titlePosition' :   'inside',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
						return '<span>Bild ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ':&nbsp; ' + title : '') + '</span>';
					}
			});

		// Cleartype fix IE
		$('.col628 p').ieffembedfix();

	});

