jQuery.fn.supersleight = function(settings) {
	settings = jQuery.extend({
		imgs: true,
		backgrounds: true,
		shim: 'x.gif',
		apply_positioning: true
	}, settings);
	
	return this.each(function(){
		if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
			jQuery(this).find('*').andSelf().each(function(i,obj) {
				var self = jQuery(obj);
				// background pngs
				if (settings.backgrounds && self.css('background-image').match(/\.png/i) !== null) {
					var bg = self.css('background-image');
					var src = bg.substring(5,bg.length-2);
					var mode = (self.css('background-repeat') == 'no-repeat' ? 'crop' : 'scale');
					var styles = {
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')",
						'background-image': 'url('+settings.shim+')'
					};
					self.css(styles);
				};
				// image elements
				if (settings.imgs && self.is('img[src$=png]')){
					var styles = {
						'width': self.width() + 'px',
						'height': self.height() + 'px',
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + self.attr('src') + "', sizingMethod='scale')"
					};
					self.css(styles).attr('src', settings.shim);
				};
				// apply position to 'active' elements
				if (settings.apply_positioning && self.is('a, input') && (self.css('position') === '' || self.css('position') == 'static')){
					self.css('position', 'relative');
				};
			});
		};
	});
};

(function($) {
	
	$(function() {
		// farid design specific
		$(window).bind('resize', function(){
			$.overflow();
		});
		$.overflow();
		
		$('#commentform input.text')
		.each(function(){
			$(this).data('val', $(this).val());
		})
		.bind('focus', function(){
			if ($(this).val() == $(this).data('val')) {
				$(this).val('');
			}
		})
		.bind('blur', function(){
			if ($(this).val().length < 1) {
				$(this).val($(this).data('val'));
			}
		});
		
		$('.twitter-chat .tweets .text a:not([href*=twitter.com])').live('click', function() {
			window.open(this.href);
			return false;
		});
		
		$('.welcome.tr, .welcome.de').live('click', function() {
			if ($(this).hasClass('tr')) {
				$('.hallo-text .de').fadeOut('slow');
				$('.hallo-text .tr').fadeIn('slow');
				$('.welcome.tr').addClass('active');
				$('.welcome.de').removeClass('active');
			} else {
				$('.hallo-text .de').fadeIn('slow');
				$('.hallo-text .tr').fadeOut('slow');
				$('.welcome.de').addClass('active');
				$('.welcome.tr').removeClass('active');
			}
			return false;

		});
		
		// Slideshow für Stadtteile
		var $slideshow = $('#slideshow');
		var fadetime = 1000;
		var staytime = 3000;
		if ($.browser.msie) {
			staytime = fadetime+staytime;
			fadetime = 1;
			if ($.browser.version < 7) {
				$('#slideshow').supersleight();
			}
		}
		$.fadeNext = function() {
			var index = $slideshow.data('index');
			if (!index) {
				index = 0;
			}
			var count = $slideshow.data('count');
			if (!count) {
				count = $slideshow.find('li').length;
				$slideshow.data('count', count);
			}
			if (index == count) {
				$slideshow.data('index', 0);
				$slideshow.find('li').fadeOut(fadetime);
				return;
			}
			$slideshow.data('index', (index+1));
			$slideshow.find('li:eq('+index+')').fadeIn(fadetime);
		}
		var show = window.setInterval(function() {
			$.fadeNext();
		}, fadetime+staytime);
	});

	$.overflow = function(url) {
		var bwidth = $('body').width();
		if (bwidth < 1072 && bwidth > 1000) {
			$('body').css('overflow-x', 'hidden');
		} else {
			$('body').css('overflow-x', 'visible');
		}
	}

	window.pr = function() {
		if (!$.browser.mozilla) {
			return;
		}
		if (typeof window.console !== 'undefined') { //  && typeof window.console.log === 'function'
			window.loadFirebugConsole();
			console.log(pr.arguments);
		}
	}
  
  $(document).ready(function(){
    $('object').each(function(){
      if($(this).hasClass("nofloat")===false) {
        var div = $('<div/>');
        var parent = $(this).parent();
        div.css("float","left").css("margin-right","10px");
        $(this).appendTo(div);
        div.appendTo(parent);
        $(this).attr("width","167").attr("height","125");
        $(this).find("embed").attr("width","167").attr("height","125");
      }
    });
  });
  
  
  
})(jQuery);

