﻿/** Background Position Animation
* @author Alexander Farkas
* v. 1.21
*/

function checkValues(xform) {  
	var check = true;
	check = (check && (xform.elem_6.value != ''));
	check = (check && (xform.elem_7.value != ''));
	check = (check && (xform.elem_8.value != ''));
	check = (check && (xform.elem_10.value != ''));
	check = (check && (xform.elem_11.value != ''));
	check = (check && (xform.elem_12.value != ''));
	if(check == true) {
		xform.submit();
	} else {
		alert("Please fill in all mandatory fields (*)!");
	}
}

function checkValuesCareer(xform) {  
	var check = true;
	check = (check && (xform.firstname.value != ''));
	check = (check && (xform.lastname.value != ''));
	check = (check && (xform.phone.value != ''));
	check = (check && (xform.email.value != ''));
	check = (check && (xform.city.value != ''));
	check = (check && (xform.visualCvUrl.value != ''));
	check = (check && (xform.country.value != ''));
	check = (check && (xform.location.value != ''));
	check = (check && (xform.jobRole.value != ''));
	if(check == true) {
		xform.submit();
	} else {
		alert("Please fill in all mandatory fields (*)!");
	}
}




(function ($) { if (!document.defaultView || !document.defaultView.getComputedStyle) { var oldCurCSS = jQuery.curCSS; jQuery.curCSS = function (elem, name, force) { if (name === "background-position") name = "backgroundPosition"; if (name !== "backgroundPosition" || !elem.currentStyle || elem.currentStyle[name]) return oldCurCSS.apply(this, arguments); var style = elem.style; if (!force && style && style[name]) return style[name]; return oldCurCSS(elem, "backgroundPositionX", force) + " " + oldCurCSS(elem, "backgroundPositionY", force) } } var oldAnim = $.fn.animate; $.fn.animate = function (prop) { if ("background-position" in prop) { prop.backgroundPosition = prop["background-position"]; delete prop["background-position"] } if ("backgroundPosition" in prop) prop.backgroundPosition = "(" + prop.backgroundPosition; return oldAnim.apply(this, arguments) }; function toArray(strg) { strg = strg.replace(/left|top/g, "0px"); strg = strg.replace(/right|bottom/g, "100%"); strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g, "$1px$2"); var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/); return [parseFloat(res[1], 10), res[2], parseFloat(res[3], 10), res[4]] } $.fx.step.backgroundPosition = function (fx) { if (!fx.bgPosReady) { var start = $.curCSS(fx.elem, "backgroundPosition"); if (!start) start = "0px 0px"; start = toArray(start); fx.start = [start[0], start[2]]; var end = toArray(fx.options.curAnim.backgroundPosition); fx.end = [end[0], end[2]]; fx.unit = [end[1], end[3]]; fx.bgPosReady = true } var nowPosX = []; nowPosX[0] = (fx.end[0] - fx.start[0]) * fx.pos + fx.start[0] + fx.unit[0]; nowPosX[1] = (fx.end[1] - fx.start[1]) * fx.pos + fx.start[1] + fx.unit[1]; fx.elem.style.backgroundPosition = nowPosX[0] + " " + nowPosX[1] } })(jQuery);

// Main Navigation
(function ($) {
	$.fn.ffNav = function (options) {
		var opts = $.extend({}, $.fn.ffNav.defaults, options);
		var hideTimeout, showTimeout = null;

		var over = function () {
			var showSubnav = function () {
				$$.find('>ul').fadeIn(opts.subnavShowDuration);
			};

			$$ = $(this);
			if (!$$.hasClass("A") || $$.hasClass("home") ) {
				$$.stop().animate({ backgroundPosition: "(0 -340px)" }, opts.bgOverDuration);
			}
			showTimeout = setTimeout(showSubnav, opts.subnavShowDelay);
		}

		var out = function () {
			var hideSubnav = function () {
				$$.find('>ul').fadeOut(opts.subnavHideDuration);
			};

			clearTimeout(showTimeout);
			var $$ = $(this);
			if (!$$.hasClass("A") || $$.hasClass("home") ) {
				$$.animate({ backgroundPosition: "(0 -300px)" }, opts.bgOutDuration);
			}
			hideTimeout = setTimeout(hideSubnav, opts.subnavHideDelay);
		};

		$('#topnav > li').hover(over, out);

		$('#topnav > li > ul').mouseenter(function () {
			clearTimeout(hideTimeout);
		});
	};

	$.fn.ffNav.defaults = {
		bgOverDuration: 400,
		bgOutDuration: 1000,
		subnavShowDelay: 300,
		subnavHideDelay: 200,
		subnavShowDuration: 200,
		subnavHideDuration: 50
	};
})(jQuery);

// Clickable Boxes (z.B. auf der Homepage)
(function ($) {
	$.fn.ffClickBox = function () {
		$(this).each(function () {
			var $$ = $(this);
			var $a = $$.find("a");
			var href = $a.attr("href");
			var outPos = $$.hasClass("gray") ?  "(0 0)" : "(0 -400px)";
			var overPos = $$.hasClass("gray") ? "(0 -95px)" : "(0 -495px)";

			var over = function () {
				$$.stop().animate({ backgroundPosition: overPos }, 500);
			}

			var out = function () {
				$$.animate({ backgroundPosition: outPos }, 500);
			};

			$$.hover(over, out);

			$$.click(function () {
				if ($a.attr("target") != "_blank") {
					window.location.href = href;
				}
				else {
					window.open(href);
				}
			});
		});
	}
})(jQuery);


// dd original name Toggler
(function ($) {
	$.fn.ddOriginalToggler = function (language) {
		$(this).each(function () {
			var $$ = $(this);
			var xclaims = new Array();
			var $asteriskPlaceHolder = $("#claim-asterisk");
			var currentIndex = 0;
			$$.find(".ddo").each(
			function() {
				var $this = $(this);
				xclaims.push({ asterisk: $this.html() });
			});
			var maxIndex = xclaims.length-1;
			
			var showDD = function () {
				if($.support.opacity) {
					$asteriskPlaceHolder.fadeOut(500, function() { $asteriskPlaceHolder.html(xclaims[currentIndex].asterisk).fadeIn(500); });
				}
				else {
					$asteriskPlaceHolder.html(xclaims[currentIndex].asterisk).show();
				}
			}

			var next = function() {
				currentIndex = (currentIndex == maxIndex) ? 0 : ++currentIndex;
				showDD();
			}

			var prev = function() {
				currentIndex = (currentIndex == 0) ? maxIndex : --currentIndex;
				showDD();
			}
			
			$("#pager .prev").click( prev );
			$("#pager .next").click( next );
			
			function startsWith(test, str) {
				return (test.match("^"+str)==str)
			}			
			
			// detected correct currentIndex for set language
			$$.find(".ddo").each(
				function(index) {
					var $this = $(this);
					//alert($this.attr("id"))
					var probedIso = $this.attr("id").toLowerCase()
					//alert(language.toLowerCase()  + " startsWith " + probedIso)
					if(startsWith(language.toLowerCase(), probedIso)) {
						currentIndex = index;
					}
				}
			);

			showDD();
		});
	}
})(jQuery);


// Claim Scheduled Switching
(function ($) {
	$.fn.ffClaimToggler = function () {
		$(this).each(function () {
			var $$ 				   = $(this);
			var myTargetSelector   = $$.attr("claimTarget")
			var myElementsSelector = $$.attr("claimElements")
			var claimSwitchFrequency = $$.attr("claimSwitchFrequency")			

			var claims             = new Array();
			var $claimPlaceHolder  = $(myTargetSelector);   //var $claimPlaceHolder = $("#claim");
			//var $asteriskPlaceHolder = $("#claim-asterisk");
			var currentIndex = 0;

			$$.find(myElementsSelector).each( function() {
				var $this = $(this);
				claims.push({ claim: $this.html()});
			});
			var maxIndex = claims.length-1;

			var showClaim = function () {
				if($.support.opacity) {
					$claimPlaceHolder.fadeOut(500, function() { $claimPlaceHolder.html(claims[currentIndex].claim).fadeIn(500); });;
					//$asteriskPlaceHolder.fadeOut(500, function() { $asteriskPlaceHolder.html(claims[currentIndex].asterisk).fadeIn(500); });
				}
				else {
					$claimPlaceHolder.html(claims[currentIndex].claim).show();
					//$asteriskPlaceHolder.html(claims[currentIndex].asterisk).show();
				}
			}
			
			interval = setInterval(function() {
				currentIndex = (currentIndex == maxIndex) ? 0 : ++currentIndex;
				showClaim();				
			}, claimSwitchFrequency);			

			showClaim();
		});
	}
})(jQuery);





