(function(a) {
	a.fn.touchwipe = function(c) {
		var b = {
			min_move_x : 20,
			min_move_y : 20,
			wipeLeft : function() {
			},
			wipeRight : function() {
			},
			wipeUp : function() {
			},
			wipeDown : function() {
			},
			preventDefaultEvents : true
		};
		if(c) {
			a.extend(b, c)
		}
		this.each(function() {
			var e;
			var d;
			var i = false;
			function h() {
				this.removeEventListener("touchmove", f);
				e = null;
				i = false
			}

			function f(m) {
				if(i) {
					var j = m.touches[0].pageX;
					var n = m.touches[0].pageY;
					var l = e - j;
					var k = d - n;
					if(Math.abs(l) >= b.min_move_x) {h();
						if(b.preventDefaultEvents) {
							m.preventDefault()
						}
						if(l > 0) {
							b.wipeLeft()
						} else {
							b.wipeRight()
						}
					} else {
						if(Math.abs(k) >= b.min_move_y) {h();
							if(k > 0) {
								b.wipeDown()
							} else {
								b.wipeUp()
							}
						}
					}
				}
			}

			function g(j) {
				if(j.touches.length == 1) {
					e = j.touches[0].pageX;
					d = j.touches[0].pageY;
					i = true;
					this.addEventListener("touchmove", f, false)
				}
			}

			if("ontouchstart" in document.documentElement) {
				this.addEventListener("touchstart", g, false)
			}
		});
		return this
	}
})(jQuery);
$.fn.cycle.transitions.scrollVertGMP = function(b, c, a) {
	b.css("overflow", "hidden");
	a.before.push(function(g, e, f, d) {
		if(f.rev) {
			d = !d
		}
		$.fn.cycle.commonReset(g, e, f);
		f.cssBefore.top = d ? -itemHeight : itemHeight;
		f.animOut.top = d ? itemHeight : -itemHeight
	});
	a.cssFirst.top = 0;
	a.cssBefore.left = 0;
	a.animIn.top = 0;
	a.animOut.left = 0
};
$.fn.cycle.transitions.scrollHorzGMP = function(b, c, a) {
	b.css("overflow", "hidden").width();
	a.before.push(function(g, e, f, d) {
		if(f.rev) {
			d = !d
		}
		$.fn.cycle.commonReset(g, e, f);
		f.cssBefore.left = d ? itemWidth : -itemWidth;
		f.animOut.left = d ? -itemWidth : itemWidth
	});
	a.cssFirst.left = 0;
	a.cssBefore.top = 0;
	a.animIn.left = 0;
	a.animOut.top = 0
};
var slideItem = 0;
var itemWidth;
var itemHeight;

function clicknow(a) {
	window.location = a
}
$(function() {
	bheight = $(window).height();
	bwidth = $(window).width();
	$(".blende").width(bwidth).height(bheight);
	$(".blende").fadeOut(1500, function() {
	});
	$("a").click(function() {
		thishref = $(this).attr("href");
		$(".blende").fadeIn(750, function() {
		});
		setTimeout("clicknow(thishref)", 500);
		return false
	});
	if($(".startShow").length > 0) {
		arrowHeight = $(window).height() / 2 - 28;
		$(".left img").css("margin-top", arrowHeight);
		$(".right img").css("margin-top", arrowHeight);
		headlineSetter();
		$(".item").each(function(a) {
			$(".item:eq(" + a + ") .subitem").each(function(b) {
				$(this).attr("item", b)
			});
			$(this).attr("items", a)
		});
		startShow("true");
		setTimeout(function() {
			$(".left").animate({
				opacity : 0
			}, 1000);
			$(".right").animate({
				opacity : 0
			}, 1000)
		}, 2000);
		arrowBlende()
		colorCheck()
	}
});
function arrowBlende(a) {
	$(".left").mouseleave(function() {
		$(".left").animate({
			opacity : 0
		}, 1000)
	});
	$(".right").mouseleave(function() {
		$(".right").animate({
			opacity : 0
		}, 1000)
	});
	$(".left").mouseover(function() {
		$(".left").animate({
			opacity : 1
		}, 500)
	});
	$(".right").mouseover(function() {
		$(".right").animate({
			opacity : 1
		}, 500)
	});
}

function headlineSetter() {
	var width = $(window).width();
	var pagewidth = 1105;
	var posleft = (width - (pagewidth - 50)) / 2;
	$(".headline").each(function(a) {
		margin = width - (width - $(this).width());
		$(this).width($(this).width() + 10).css("margin-left", posleft + 20);
		$(this).appendTo(".headlines")
	});
	$(".headlines").width(width).css("left", -posleft);
	startShowCycle("headlines", slideItem)
}

function colorCheck() {
	if($(".headline.current").hasClass("black")) {
		$("body").removeClass("gmpwhite");
		$("#logo img").attr("src", "fileadmin/templates_relaunch_2010/images/gmpblack.png")
	} else {
		$("body").addClass("gmpwhite");
		$("#logo img").attr("src", "fileadmin/templates_relaunch_2010/images/gmpwhite.png")
	}
}

function startShow(a) {
	if( a = "true") {loadImage(0, 0);
		loadImage(0, 1);
		loadImage(1, 0);
		lastimg = $(".item:last").attr("items");
		loadImage(lastimg, 0);
		height = $(window).height();
		width = $(window).width();
		$(".startShow").width(width).height(height).css("overflow", "hidden");
		$(".startShow .items").width(width).height(height);
		$(".startShow .item").width(width).height(height);
		$(".startShow .subitem").width(width).height(height);
		imageResize("all");
		startShowCycle("insert", slideItem);
		startShowCycle("vertical", slideItem);
		$(window).resize(function() {startShowCycle("pause", slideItem);
			windowResize();
			startShowCycle("play", slideItem)
		});
		touch("start")
	}
}

function touch(a) {
	vari = a;
	if(a == "start") {
		$(".startShow .items").touchwipe({
			wipeLeft : function() {
				$(".pager .right").click()
			},
			wipeRight : function() {
				$(".pager .left").click()
			}
		})
	} else {
	}
}

function windowResize() {
	height = $(window).height();
	width = $(window).width();
	$(".startShow").width(width).height(height).css("overflow", "hidden");
	$(".startShow .items").width(width).height(height);
	$(".startShow .item").width(width).height(height);
	$(".startShow .subitem").width(width).height(height);
	arrowHeight = $(window).height() / 2 - 28;
	$(".left img").css("margin-top", arrowHeight);
	$(".right img").css("margin-top", arrowHeight);
	imageResize("all")
}

function startShowCycle(b, a) {
	switch(b) {
		case"insert":
			$(".item:eq(" + a + ")").cycle({
				fx : "scrollVertGMP",
				sync : 1,
				rev : 1,
				containerResize : 0,
				slideResize : 0,
				startingSlide : 0,
				speed : 1000,
				timeout : 0,
				width : itemWidth,
				height : itemHeight,
				onPrevNextEvent : function(d, c, e) {
					$(".pager .right").unbind();
					$(".pager .left").unbind();
					$(".subitemPager .prev").unbind();
					$(".subitemPager .next").unbind();
					if(d == true) {
					} else {
						if($(".item:eq(" + a + ") .subitem:eq(" + c + ")").children("img").attr("src") == "") {loadImage(a, c)
						}
					}
				},
				before : function() {
					$(".pager .right").unbind();
					$(".pager .left").unbind();
					$(".subitemPager .prev").unbind();
					$(".subitemPager .next").unbind();
					$(".subitem").removeClass("current");
					$(this).height(itemHeight);
					$(this).width(itemWidth);
					if($(this).next().children("img").attr("src") == "") {loadImage(a, $(this).next().attr("item"))
					}
				},
				after : function() {
					$(".pager .right").bind("click", function() {
						$(".startShow .items").cycle("next");
						$(".headlines").cycle("next")
					});
					$(".pager .left").bind("click", function() {
						$(".startShow .items").cycle("prev");
						$(".headlines").cycle("prev")
					});
					$(".subitemPager .next").bind("click", function() {
						$(".item:eq(" + slideItem + ")").cycle("next")
					});
					$(".subitemPager .prev").bind("click", function() {
						$(".item:eq(" + slideItem + ")").cycle("prev")
					});
					arrowBlende();
					$(this).addClass("current")
				}
			});
			break;
		case"play":
			setTimeout(function() {
				$(".item:eq(" + a + ")").cycle("resume")
			}, 3000);
			break;
		case"pause":
			$(".item:eq(" + a + ")").cycle("pause");
			break;
		case"allpause":
			$(".item").cycle("pause");
			break;
		case"stop":
			$(".item:eq(" + a + ")").cycle("stop");
			break;
		case"destroy":
			$(".item:eq(" + a + ")").cycle("destroy");
			break;
		case"vertical":
			$(".startShow .items").cycle({
				fx : "scrollHorzGMP",
				containerResize : 0,
				slideResize : 0,
				fit : 0,
				width : itemWidth,
				height : itemHeight,
				onPrevNextEvent : function(d, c, e) {startShowCycle("pause", slideItem);
					slideItem = c;
					if(d == true) {
						if($(".item:eq(" + (c + 1) + ") .subitem:eq(" + 0 + ")").children("img").attr("src") == "") {loadImage((c + 1), 0)
						}
						if($(".item:eq(" + (c) + ") .subitem:eq(" + 1 + ")").children("img").attr("src") == "") {startShowCycle("insert", slideItem)
						}
					} else {
						if($(".item:eq(" + (c - 1) + ") .subitem:eq(" + 0 + ")").children("img").attr("src") == "") {loadImage((c - 1), 0)
						}
						if($(".item:eq(" + (c) + ") .subitem:eq(" + 1 + ")").children("img").attr("src") == "") {startShowCycle("insert", slideItem)
						}
					}
					$(".subitemPager .prev").unbind();
					$(".subitemPager .next").unbind()
				},
				before : function() {
					$(".subitemPager .prev").unbind();
					$(".subitemPager .next").unbind()
				},
				after : function() {
					$(".subitemPager .next").bind("click", function() {
						$(".item:eq(" + slideItem + ")").cycle("next")
					});
					$(".subitemPager .prev").bind("click", function() {
						$(".item:eq(" + slideItem + ")").cycle("prev")
					});
					setTimeout(function() {startShowCycle("play", slideItem)
					}, 3000)
				},
				timeout : 0
			});
			break;
		case"headlines":
			$(".headlines").cycle({
				fx : "scrollHorzGMP",
				prev : ".pager .left",
				next : ".pager .right",
				containerResize : 0,
				speed : 500,
				slideResize : 0,
				fit : 0,
				width : itemWidth,
				height : itemHeight,
				timeout : 0,
				onPrevNextEvent : function(d, c, e) {
					$(".headline").removeClass("current");
					$(".headline:eq(" + c + ")").addClass("current");
					colorCheck();
					if(d == true) {
					} else {
					}
				},
				after : function() {
					$(this).addClass("current")
				}
			});
			break
	}
}

function imageResize(a) {
	switch(a) {
		case"all":
			$(".subitem img").each(function(b) {
				height = $(this).parent().attr("imageHeight");
				width = $(this).parent().attr("imageWidth");
				itemWidth = $(this).parent().parent().width();
				itemHeight = $(this).parent().parent().height();
				if((width / itemWidth) > (height / itemHeight)) {
					$(this).width("");
					$(this).height(itemHeight)
				} else {
					if((width / itemWidth) < (height / itemHeight)) {
						$(this).height("");
						$(this).width(itemWidth)
					} else {
					}
				}
			});
			break;
		case"one":
			itemWidth = $(".current").width();
			$(".current").next().width(itemWidth);
			break
	}
}

function loadImage(a, b) {
	var c = $(".startShow .item:eq(" + a + ") .subitem:eq(" + b + ")").attr("src");
	$(".startShow .item:eq(" + a + ") .subitem:eq(" + b + ") img").attr("src", c)
};

$(window).load(function(){
	$(".blende").fadeOut(1500, function() {
	});
	setTimeout(function(){
		$(".blende").fadeOut(1500, function() {
	});
	},1000)
})

