
(function($){$.fn.lazyload=function(options){var settings={threshold:0,failurelimit:0,event:"scroll",effect:"show",container:window};if(options){$.extend(settings,options);}
var elements=this;if("scroll"==settings.event){$(settings.container).bind("scroll",function(event){var counter=0;elements.each(function(){if($.abovethetop(this,settings)||$.leftofbegin(this,settings)){}else if(!$.belowthefold(this,settings)&&!$.rightoffold(this,settings)){$(this).trigger("appear");}else{if(counter++>settings.failurelimit){return false;}}});var temp=$.grep(elements,function(element){return!element.loaded;});elements=$(temp);});}
this.each(function(){var self=this;if(undefined==$(self).attr("original")){$(self).attr("original",$(self).attr("src"));}
if("scroll"!=settings.event||undefined==$(self).attr("src")||settings.placeholder==$(self).attr("src")||($.abovethetop(self,settings)||$.leftofbegin(self,settings)||$.belowthefold(self,settings)||$.rightoffold(self,settings))){if(settings.placeholder){$(self).attr("src",settings.placeholder);}else{$(self).removeAttr("src");}
self.loaded=false;}else{self.loaded=true;}
$(self).one("appear",function(){if(!this.loaded){$("<img />").bind("load",function(){$(self).hide().attr("src",$(self).attr("original"))
[settings.effect](settings.effectspeed);self.loaded=true;}).attr("src",$(self).attr("original"));};});if("scroll"!=settings.event){$(self).bind(settings.event,function(event){if(!self.loaded){$(self).trigger("appear");}});}});$(settings.container).trigger(settings.event);return this;};$.belowthefold=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).height()+$(window).scrollTop();}else{var fold=$(settings.container).offset().top+$(settings.container).height();}
return fold<=$(element).offset().top-settings.threshold;};$.rightoffold=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).width()+$(window).scrollLeft();}else{var fold=$(settings.container).offset().left+$(settings.container).width();}
return fold<=$(element).offset().left-settings.threshold;};$.abovethetop=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).scrollTop();}else{var fold=$(settings.container).offset().top;}
return fold>=$(element).offset().top+settings.threshold+$(element).height();};$.leftofbegin=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).scrollLeft();}else{var fold=$(settings.container).offset().left;}
return fold>=$(element).offset().left+settings.threshold+$(element).width();};$.extend($.expr[':'],{"below-the-fold":"$.belowthefold(a, {threshold : 0, container: window})","above-the-fold":"!$.belowthefold(a, {threshold : 0, container: window})","right-of-fold":"$.rightoffold(a, {threshold : 0, container: window})","left-of-fold":"!$.rightoffold(a, {threshold : 0, container: window})"});})(jQuery);

Console = function() {
	return {
		log: function(msg, args) { if (typeof console == 'undefined') return false; if (!args) args = ''; console.log(msg, args) },
		info: function(msg, args) { if (typeof console == 'undefined') return false; if (!args) args = ''; console.info(msg, args) },
		warn: function(msg, args) { if (typeof console == 'undefined') return false; if (!args) args = ''; console.warn(msg, args) },
		error: function(msg, args) { if (typeof console == 'undefined') return false; if (!args) args = ''; console.error(msg, args) }
	}
} ();

/* This function extends jQuery: 
* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. */
(function($) {
	$.fn.BgIframe = $.fn.Bgiframe = function(s) {
		s = $.extend({
			top: 'auto', // auto == .currentStyle.borderTopWidth
			left: 'auto', // auto == .currentStyle.borderLeftWidth
			width: 'auto', // auto == offsetWidth
			height: 'auto', // auto == offsetHeight
			opacity: true,
			src: 'javascript:false;'
		}, s || {});
		var prop = function(n) { return n && n.constructor == Number ? n + 'px' : n; },
                html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="' + s.src + '"' +
                            'style="display:block;position:absolute;z-index:-1;' +
                            (s.opacity !== false ? 'filter:Alpha(Opacity=\'0\');' : '') +
                            'top:' + (s.top == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')' : prop(s.top)) + ';' +
                            'left:' + (s.left == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')' : prop(s.left)) + ';' +
                            'width:' + (s.width == 'auto' ? 'expression(this.parentNode.offsetWidth+\'px\')' : prop(s.width)) + ';' +
                            'height:' + (s.height == 'auto' ? 'expression(this.parentNode.offsetHeight+\'px\')' : prop(s.height)) + ';' +
                            '"/>';
		return this.each(function() {
			if ($('> iframe.bgiframe', this).length == 0)
			this.insertBefore(document.createElement(html), this.firstChild);
		});
	}
})(jQuery);

var wp ={};

wp.msie = function() {
    return {
        ie7: false,
        ie6: false,
        init: function() {
			if ($.browser.version < 7) {
                $(document).ready(wp.msie.initIE6);
			}
        },
        initIE6: function() {
			$('#nav li').hover(function() {
				$(this).addClass('visible');
			}, function() {
				$(this).removeClass('visible');
			});
        }
    }
} ();
if($.browser.msie) { $(document).ready(wp.msie.init); }

wp.initial = function() {
	return {
		init: function() {
			var x = 0;
			$('#imgContent img').each(function(i) {
				x += parseFloat($(this).width());
			});
			if(x != 0){
			$('#imgContent').width(x+20);
			}
			else {
				$('#imgContent').width(700);
			}
			$("#imgContent img").lazyload({         
				placeholder : "../images/grey.gif",
				effect : 'fadeIn'
			});

			$('p.link a').each(function(i) {
				if(i == 0){
					$(this).click(function() {
						$('#impressum').removeClass('visible');
						$('#contact').toggleClass('visible');
						return false;
					})
				}
				else {
					$(this).click(function() {
						$('#contact').removeClass('visible');
						$('#impressum').toggleClass('visible');
						return false;
					})
				}
			});
			$('#nav ul:last-child').last().addClass('fashion-show');
		}
	}
}();
$(document).ready(wp.initial.init);

wp.scrolling = function() {
	return {
		init: function() {
			var width = $(window).width() - 30;
			var cHolder = $('#imgContent').width();
			var props = {};
			props['scrollLeft'] = '+=' + width;
			props2 = {};
			props2['left'] = '+=' + width;
			$('body').prepend('<div id="arrow-l"><img src="/public/themes/wilfried/img/arrows-right.png" alt="" width="22" height="12" /></div>');
			
			$('#arrow-l').css('left', width).click(function() {
				var currentLeft = $(window).scrollLeft();
				var difference = cHolder - currentLeft - width;

				if(difference < (width + 30)) {
					props['scrollLeft'] = '+=' + difference;
					props2['left'] = '+=' + difference;
					$(this).remove();
				}
				$(this).animate(props2, 1500);
				$('html').animate(props, 1500);
				
			return false;
			});		
		}
	}
}();
//$(document).ready(wp.scrolling.init);

