/* 118000 common scripts */

var movieUrl;
var movieUrlBase = window.location.href;

var com = {
	submit: function(tgt){
		$(".labelled").each(function(){
			if ($(this).val()==this.defaultValue){
				$(this).val("");
			}
		});
		$(tgt).parents("form").submit();
	}
};

// Prevent accidental navigation away
var needToConfirm = false;

// browser-detection IE 6 || Chrome
if($.browser.msie && $.browser.version=="6.0") {
	var browserIE6 = "true";
} else {
	var browserIE6 = "false";
}
var browserChrome = /chrome/.test( navigator.userAgent.toLowerCase() );

$(document).ready(function(){

    // Check for hash value in URL 0
    // load layerbox on startup or get right tap
    var hash = window.location.hash.substr(1);
    if(hash) {
        // show tab?
    	var tab = hash.match("tab=");
    	if(tab) {
    		tab = hash.replace("tab=","");
    		var objId = "#"+tab;
    		// econda-notification
			// delayed for better performance
			window.setTimeout( function() {
				trackIt(objId);
			}, 1000);
    		$("ul.tabLinks li a,ul.sideTabs li a").removeClass("active");
    		$("ul.tabLinks li a,ul.sideTabs li a").each(function() {
    			if($(this).attr("href")==objId) {
    				$(this).addClass("active");
    			}
    		});
    		$(".tabBox").each(function() {
    			if(!$(this).hasClass("hidden")) {
    				$(this).addClass("hidden");
    			}
    			if($(this).attr("id")==tab){
    				$(this).removeClass("hidden");
    			}
    		});
    	}
    	// load layerbox?
    	var box = hash.match("box=");
    	if(box) {
    		box = hash.replace("box=","");
    		box = "layerbox.php?site1="+box // edit for right url
    		showLayerBox(box," big");
    	}
    	// load small layerbox?
    	var boxS = hash.match("boxS=");
    	if(boxS) {
    		boxS = hash.replace("boxS=","");
    		boxS = "layerbox.php?site1="+boxS // edit for right url
    		showLayerBox(boxS,"");
    	}
    	// load note layerbox?
    	var boxN = hash.match("boxN=");
    	if(boxN) {
    		boxN = hash.replace("boxN=","");
    		boxN = "layerbox.php?site1="+boxN // edit for right url
    		showLayerBox(boxN," note");
    	}
    	// goto anchor
    	var goTo = hash.match("goTo=");
    	if(goTo) {
    		goTo = hash.replace("goTo=","");
    		$.scrollTo($("#"+goTo),500);
    	}
    }

    // load note
 //   if ($.cookie('preisaenderung') != '1' && window.location.pathname == "/index.do") {	// Is frontpage?
 //   	boxN = "preisaenderung.do";			// edit for right url
//    	boxN = "layerbox.php?site1="+boxN;	// edit for right url
//    	showLayerBox(boxN," note");
    	// set cookie
 //		$.cookie('preisaenderung', '1', { expires: 3, path: '/' });
   // }

    // determine OS -> windows?
	if (navigator.appVersion.indexOf("Win")!=-1) {
		$("body").addClass("win");
	};

	// youtube-video
    var ytposition=window.location.href.indexOf("?yt=");
    if (ytposition>0) {
    	movieUrlBase=window.location.href.substring(0,ytposition);
    	movieUrl=window.location.href.substring(ytposition+4);
    	movieUrl = decodeURIComponent(movieUrl);
	}

	// target _blank for downloads and extern links
	$(".photoBox a, a.extern").attr("target", "_blank");
	$("a.newWindow, #radioThumbs a").click(function(){
		window.open($(this).attr("href"),'_blank','height=200,width=400,left=100,top=100');
		return false;
	});

	// blend in login
	$("#logintrigger").click(function() {
    	$('#login').css({display: "block"});
    	$('#logintrigger').css({display: "none"});
	});

	// fadeIn data
	if(browserChrome || $.browser.webkit  || $.browser.safari) {
		$("#emailTypeBusiness").change(function() {
			$("#privateData").slideUp(400, function() {
				$("#bussinessData").slideDown(600);
			});
		});
		$("#emailTypePrivate").change(function() {
			$("#bussinessData").slideUp(400, function() {
				$("#privateData").slideDown(600);
			});
		});
	} else {
		$("#emailTypeBusiness").focus(function() {
	    	$("#privateData").slideUp(400, function() {
	    		$("#bussinessData").slideDown(600);
	    	});
	    });
	    $("#emailTypePrivate").focus(function() {
	    	$("#bussinessData").slideUp(400, function() {
	    		$("#privateData").slideDown(600);
	    	});
	    });
	}

	// anchor-link
	$("a.anchor").click(function() {
    	goTo = $(this).attr("href");
    	goTo = goTo.split("#");
    	goTo = goTo[1].replace("goTo=","");
    	if ($("#"+goTo).is("div") ) {
    		$.scrollTo($("#"+goTo),500);
    		return false;
    	}
	});

	// open Tab
	$("ul.tabLinks li a").click(function() {
		openTab($(this).attr("href"));
		return false;
	});
	$("ul.sideTabs li a").click(function() {
		openTab($(this).attr("href"));
		var viewHeight = getViewHeight();
		if(viewHeight < 500) {
			$.scrollTo($("#tabs"),500);
		} else if(viewHeight < 610) {
			$.scrollTo($("#mainContent"),500);
		}
		return false;
	});

	// open more Fields
	$("div.openFields").click(function() {
		openFields($(this));
	});

	// close Fields
	$("div.closeFields").click(function() {
		closeFields($(this));
	});

	//smooth scrolling
	$(".content").localScroll({
		duration:400
	});

	// Prevent accidental navigation away
	$("#userData input, #userData select").change(function() {
		needToConfirm = true;
	});
	$("#userData .submitEntry input,.callAction a").click(function() {
		needToConfirm = false;
	});

	// replace default-values for labelled inputs
	$(".labelled").each(function(){
		$(this).data("defaultValue", this.defaultValue);
	}).focus(function(e){
		if ($(this).val()==this.defaultValue){
			$(this).val("").select(); // select() kills problems in IE
		}
	}).blur(function(e){
		$(this).blurField();
	});

	// input-text-color after changed values
	$(".inputBox input, .inputBox select").change(function() {
		$(this).removeClass("error").removeClass("labelled").parent().removeClass("error");
		$(this).addClass("changed");
	});

	// validate time
	$(".time").change(function(){
		validateTime($(this));
	});

	// validate lost&found code
	$("#lostFound input").change(function(){
		validateCode($(this));
	});

	$('#lostandfoundcode').submit(function() {
	    return mandatoryCodeInput();
	});

	// validate Order amount lost&Found
	$("#orderAmount").change(function(){
		validateOrder($(this));
	});

	// change Country-Select on start
	$("#vacation option").each(function(){
		var countryCode = $("#a_countryCode").val().substring(1);
		thisValue = $(this).attr("value").split("-",1);
		if(thisValue == countryCode) {
			$(this).attr('selected', 'selected')
		}
	});
	// change countryCode on Country-Select
	$("#vacation").change(function(){
		var code = "+"+$(this).val();
		code = code.split("-",1);
		$("#a_countryCode").val(code).css({color:"#000"});
	});

	// get price for order
	$("#orderAmount").change(function(){
		getPrice($(this).val());
	});

	// Questions
	$(".question").click(function() {
		$(".question").not(this).removeClass("close");
		$(".questionBox").fadeOut(300);
		$("#headBox .questionBox").hide();
		if($(this).hasClass("close")) {
			$(this).removeClass("close");
			$("select").removeClass("hide");
		} else {
			$("select").addClass("hide");
			$("#Q"+this.id).stop().show();
			$(this).addClass("close");
		}
	});

	$(".questionBox").click(function() {
		$(".close").removeClass("close");
		$(this).fadeOut(300);
		$("select").removeClass("hide");
	});

	// layerBox
	$("a.layerBox").click(function(){
		showLayerBox(this.href,"");
		return false;
	});

	// layerBox
	$("a.feedback").click(function(){
		showLayerBox(this.href,"");
		return false;
	});

	// layerBox Big
	$("a.layerBoxBig").click(function(){
		showLayerBox(this.href," big");
		return false;
	});

	// blend in more fields
	// blendInMore(IdOfParentBox,HowManyFields,this) -> Blends in as many hidden fields as stated in second variable
	// eraseFields(IdOfParentBox,HowManyFields,this) -> Hides as many fields as stated and sets standard inputs
	// blendInErase(this,HowManyFields) -> Blends in the Erase-Button as soon as there is a new value in the field above
	$("#addressee .moreFields").click(function(){
		blendInMore("#addressee",2,$(this));
	});
	$("#privateData .moreFields").click(function(){
		blendInMore("#privateData",1,$(this));
	});
	$("#schools .moreFields").click(function(){
		blendInMore("#schools",2,$(this));
	});

	$("#portalName .moreFields").click(function(){
		blendInMore("#portalName",1,$(this));
	});
	$("#portalName .eraseFields").click(function(){
		eraseFields("#portalName",2,$(this),1);
	});
	$("#portalName input,#portalName select").focus(function(){
		blendInErase($(this),1);
	});

	$("#portalId .moreFields").click(function(){
		blendInMore("#portalId",1,$(this));
	});
	$("#portalId .eraseFields").click(function(){
		eraseFields("#portalId",2,$(this),1);
	});
	$("#portalId input,#portalId select").focus(function(){
		blendInErase($(this),1);
	});

	$("#lostFound .moreFields").click(function(){
		blendInMore("#lostFound",1,$(this));
	});
	$("#lostFound .eraseFields").click(function(){
		eraseFields("#lostFound",2,$(this),1);
	});
	$("#lostFound input").focus(function(){
		blendInAction($(this),1);
	});

	$("#jobs .moreFields").click(function(){
		blendInMore("#jobs",1,$(this));
	});

	$("#time .moreFields").click(function(){
		blendInMore("#time",1,$(this));
	});
	$("#time .eraseFields").click(function(){
		eraseFields("#time",2,$(this),1);
	});
	$("#time input,#time select").focus(function(){
		blendInErase($(this),1);
	});

	$("#banned .moreFields").click(function(){
		blendInMore("#banned",3,$(this));
	});
	$("#banned .eraseFields").click(function(){
		eraseFields("#banned",4,$(this),3);
	});
	$("#banned input,#banned select").focus(function(){
		blendInErase($(this),3);
	});

	// Copy-Button
	$("#availability2 input,#availability2 select").focus(function(){
		copyFields($(this));
	});
	$(".copyIt").click(function(){
		copyIt($(this));
	});

	// nutzungsfall-Features
	$(".caseWrapper").hover(
    	function() {
    		caseIn($(this));
    	},
    	function() {
    		caseOut($(this));
    	}
    );

	// Teilen-Link Facebook
	var fbUrl = mappingRedirect4fb(window.location.href); //ych: url mapping f�r facebook
	$("a.teilen").attr("href","http://www.facebook.com/sharer.php?u="+fbUrl);
	$("a.teilen").click(function() {
		window.open($(this).attr("href"),'_blank','height=500,width=600,left=100,top=100') ;
		return false;
	});

	// Fixing bug IE8
	$("#loginForm").keypress(function(event) {
  		if (event.keyCode == '13') {
     		$("#loginForm .login input").focus();
   		}
	});

});


// Prevent accidental navigation away
window.onbeforeunload = confirmExit;

function confirmExit() {
    if (needToConfirm) {
    	return unescape("Sie haben %C4nderungen auf dieser Seite vorgenommen. Bitte bleiben Sie auf dieser Seite und klicken Sie dort auf %BB%C4nderung speichern%AB damit Ihre Daten bei uns hinterlegt sind.");
    }
}

// Datum
function today() {
	var today = new Date();
	var month = today.getMonth()+1;
	var year = today.getFullYear();
	var day = today.getDate();
	if(day<10) day = "0" + day;
	if(month<10) month= "0" + month;
	var now = day + "." + month + "." + year;
	return now;
}

// homeBoxNavi
function startBox(box) {
	var boxId = box.attr("id").replace("startBox","");
	if(browserIE6 == "true"){
		$("#homeBoxStart").hide();
		$("#homeBoxContent").show();
		homeBox($("#boxNavi"+boxId));
	} else {
		box.animate({marginTop: "600px"},250, 'easeInQuad');
		$("#homeBoxStart .content").fadeOut(500);
		boxAni(boxId);
		homeBox($("#boxNavi"+boxId));
		window.setTimeout(function () {
			$("#homeBoxContent").fadeIn(800);
		},550);
	}
}

function boxAni(boxId) {
	if (boxId == 1) {
	    var nextId = 2;
	    var nextnextId = 3;
	} else if (boxId == 2)   {
	    var nextId = 1;
	    var nextnextId = 3;
	} else {
	    var nextId = 2;
	    var nextnextId = 1;
	}
	window.setTimeout(function () {
	    $("#startBox"+nextId).animate({marginTop: "600px"}, 250, 'easeInQuad');
	},100);
	window.setTimeout(function () {
	    $("#startBox"+nextnextId).animate({marginTop: "600px"}, 250, 'easeInQuad');
	},200);

}

function homeBox(box) {
	var boxId = box.attr("id").replace("boxNavi","");
	var pos = "-"+((954*boxId)-954)+"px";
	$(".boxNavi.active").removeClass("active");
	$(box).addClass("active");
	if(boxId == 3) {
	    $("#boxNavi2").addClass("prev");
	} else {
	    $("#boxNavi2").removeClass("prev");
	}
	buttonAni(boxId);
	if(browserIE6 == "true"){
		$("#homeBoxWrapper").css({marginLeft: pos});
	} else {
		$("#homeBoxWrapper").stop().animate({marginLeft: pos}, 450, 'easeInOutQuad');
	}
}

function buttonAni(boxId) {
	if(browserIE6 == "true"){
		$(".homeBoxLink").not("#homeBoxLink"+boxId).css({bottom: "-20px"});
		$("#homeBoxLink"+boxId).not("#homeBoxLink0").css({bottom: "0px"});
		if (boxId == 0) {
			$("#homeBoxLink0").show();
		}
	} else {
		$(".homeBoxLink").not("#homeBoxLink"+boxId).stop().animate({bottom: "-20px"}, 150, 'easeInOutQuad');
		window.setTimeout(function () {
			$("#homeBoxLink"+boxId).not("#homeBoxLink0").stop().animate({bottom: "0px"}, 150, 'easeInOutQuad');
		}, 450);
	}
	if (boxId == 0) {
		window.setTimeout(function () {
			$("#homeBoxLink0").stop().fadeIn(400);
		}, 600);
	} else {
		$("#homeBoxLink0").stop().hide();
	}
}

function slideNavi(box) {
	var boxId = $(".boxNavi.active").attr("id").replace("boxNavi","");
	if (box.hasClass("nextButton")) {
		if (boxId==3) {
			restartBox();
		} else {
			boxId = parseFloat(boxId)+1;
			homeBox($("#boxNavi"+boxId));
		}
	} else {
		if (boxId==1) {
			restartBox();
		} else {
			boxId = boxId-1;
			homeBox($("#boxNavi"+boxId));
		}
	}
}

function restartBox() {
	$(".startBox").css({marginTop: "0px"});
	if(browserIE6 == "true"){
		$("#homeBoxStart").show();
		$("#homeBoxContent").hide();
	} else {
		$("#homeBoxContent").animate({opacity: "0"}, 450, function(){
			$("#homeBoxContent").css({display: "none", opacity: "1"});
		});
		$("#homeBoxStart").css({display: "none"});
		window.setTimeout(function () {
			$("#homeBoxStart .content").css({display: "block"});
			$("#homeBoxStart").fadeIn(800);
		},550);
	}
	buttonAni(0);
}

// open Tab
function openTab(box) {
	$(".tabBox").stop().css({height: "auto", paddingTop: "18px", paddingBottom: "18px", overflow: "visible"});
	if($.browser.msie){
		$(".tabBox").not(box).hide();
		$(box).show();
	} else {
		$(".tabBox").not(box).slideUp(400, function() {
			$(box).slideDown(600);
		});
	}
	if(box =="#myEntry"){
		$(".deleteAccount").show();
	} else {
		$(".deleteAccount").hide();
	}
	if(box == "#myEntry" || box == "#loginData"){
		$(".reqNote span").show();
	}else{
		$(".reqNote span").hide();
	}

	$("ul.tabLinks li a,ul.sideTabs li a").removeClass("active");
	$('a[href^="'+box+'"]').addClass("active");

	// set hash
	window.location.hash = "tab="+box.replace("#",'');

    // econda-notification
	// delayed for better performance
	window.setTimeout( function() {
		trackIt(box);
	}, 1000);
}

// get Price
function getPrice(amount) {
	var cleanAmount = amount.replace(/[^0-9]/g, "");
	var newPrice = parseInt(cleanAmount)*995;
	newPrice = newPrice+'';
	var euroPrice = newPrice.substr(0,(newPrice.length-2));
	var centPrice = newPrice.substr((newPrice.length-2));
	newPrice = euroPrice+","+centPrice+" "+unescape("%u20AC");
	$("#orderPrice").attr("value",newPrice);
}

// open Fields
function openFields(box) {
	if(browserIE6 == "true") {
		box.hide();
		window.setTimeout(function() {
			box.next().show();
		}, 600);
		box.next().next().show().removeClass('hidden');
 		if(box.hasClass('moreBoxes')) {
 			box.parent().next().show().removeClass('hidden');
 		}
	} else {
		box.slideUp(400);
		window.setTimeout(function() {
			box.next().fadeIn(300);
		}, 600);
		box.next().next().slideDown(600).removeClass('hidden');
 		if(box.hasClass('moreBoxes')) {
 			box.parent().next().slideDown(600).removeClass('hidden');
 		}
	}
}

// close Fields
function closeFields(box) {
	if(browserIE6 == "true") {
		box.prev().show();
		box.hide();
		box.next().hide();
 		if(box.hasClass('moreBoxes')) {
 			box.parent().next().hide();
 		}
	} else {
		box.prev().slideDown(600);
		box.hide();
		box.next().slideUp(400);
 		if(box.hasClass('moreBoxes')) {
 			box.parent().next().slideUp(400);
 		}
	}
}

// blur Field
jQuery.prototype.blurField = function(){
	if (this.val()==""){
		this.val(this.data("defaultValue"));
 	}
}

// more Fields
function blendInMore(boxId,fields,link) {

	// hide link
	var n = $(boxId+" div.field.hidden").length;
	if (n <= fields) {
		link.slideUp(200);
	}

	$(boxId+" div.firstHidden").show();

	if(browserIE6 == "true") {
		for (i=0;i<fields;i++) {
			$(boxId+" div.field.hidden:first")
				.css({display:"none"})
				.removeClass("hidden")
				.addClass("notHidden")
				.show();
		}
	} else {
		for (i=0;i<fields;i++) {
			$(boxId+" div.field.hidden:first")
				.css({display:"none"})
				.removeClass("hidden")
				.addClass("notHidden")
				.slideDown(200);
		}
	}
}

// erase Fields
function blendInErase(boxId,fields) {
	boxId = boxId.closest(".field");
	for (i=0;i<fields;i++) {
		if(browserIE6 == "true") {
			boxId.next(".eraseFields")
				.css({display:"none"})
				.removeClass("hidden")
				.addClass("notHidden")
				.show();
			boxId = boxId.next();
		} else {
			boxId.closest(".field").next(".eraseFields").slideDown(200, function () {
					$(this).removeClass("hidden").addClass("notHidden");
				});
			boxId = boxId.next();
		}
	}
}

// activate Code
function blendInAction(boxId,fields) {
	boxId = boxId.closest(".field");
	if(!boxId.children(".inputBox").hasClass("readonly2")) {
		for (i=0;i<fields;i++) {
			if(browserIE6 == "true") {
				boxId.children(".callAction")
					.css({display:"none"})
					.removeClass("hidden")
					.addClass("notHidden")
					.show();
			} else {
				boxId.children(".callAction").slideDown(200, function () {
					$(this).removeClass("hidden").addClass("notHidden");
				});
			}
		}
	}
}

function eraseFields(boxId,fields,link,erase) {
	$(boxId+" div.moreFields").show();
	var box = $(boxId+" div.moreFields");
	for (i=0;i<fields;i++) {
		if(browserIE6 == "true") {
			link.removeClass("notHidden")
				.css({display:"block"})
				.addClass("hidden")
				.hide(function() {
					$(this).remove();
					box.before($(this));
					box = box.prev();
					if (box.hasClass("eraseFields")) {
						box.click(function(){
							eraseFields(boxId,fields,$(this));
						});
					}
					box.find("input, select").focus(function(){
						blendInErase($(this),erase);
					});
					getInputValue(box);
				});
			link = link.prev();
		} else {
			link.removeClass("notHidden")
				.css({display:"block"})
				.addClass("hidden")
				.slideUp(200, function() {
					$(this).remove();
					box.before($(this));
					box = box.prev();
					if (box.hasClass("eraseFields")) {
						box.click(function(){
							eraseFields(boxId,fields,$(this));
						});
					}
					getInputValue(box,erase);
				});
			link = link.prev();
		}
	}
}

function getInputValue(field,erase) {

	field.find(".checked").remove();
	field.find(".warned").remove();
	field.find(".question").remove();
	field.find(".callAction").removeClass("notHidden").addClass("hidden").css({display: "none"});

	field.find("input").each(function () {
	    var theName = $(this).attr("name");
	    if (theName.match("country")) { $(this).attr("value","+49"); };
	    if (theName.match("areaCode")) { $(this).attr("value","Vorwahl"); };
	    if (theName.match("localNum")) {
	    	$(this).attr("value","Nummer");
	    	if($(this).parent().hasClass("sizeM")) { /* remove question in order to prohibit wrong display */
	    		$(this).parent().removeClass("sizeM").addClass("sizeL");
	    	}
	    };
	    if (theName.match("firstName")) { $(this).attr("value","Vorname"); };
	    if (theName.match("lastName")) { $(this).attr("value","Nachname"); };
	    if (theName.match("Time")) { $(this).attr("value","ss:mm"); };
	    if (theName.match("portalId")) {
	    	$(this).attr("value","Ihre Anzeigen-ID");
	    	if($(this).parent().hasClass("sizeM")) { /* remove question in order to prohibit wrong display */
	    		$(this).parent().removeClass("sizeM").addClass("sizeL");
	    	}
	    };
	    if (theName.match("portalName")) {
	    	$(this).attr("value","Name");
	    	if($(this).parent().hasClass("sizeM")) { /* remove question in order to prohibit wrong display */
	    		$(this).parent().removeClass("sizeM").addClass("sizeL");
	    	}
	    };
	    if (theName.match("lostFound")) {
	    	$(this).parent().parent().removeClass("readonly2"); 	// remove readonly style
	    	$(this).removeAttr("readonly"); 						// remove readonly function
	    	if($(this).parent().hasClass("sizeXXL")) { /* remove question in order to prohibit wrong display */
	    		$(this).parent().removeClass("sizeXXL").addClass("sizeXXXL");
	    	}
	    	if($(this).parent().hasClass("sizeXL")) { /* remove question in order to prohibit wrong display */
	    		$(this).parent().removeClass("sizeXL").addClass("sizeXXXL");
	    	}
	    	$(this).val("test");
	    	$(this).val("");
	    };
	    // add functions to input-fields
	    $(this).data("defaultValue", this.defaultValue);
	    $(this).focus(function() {
	    	if (theName.match("lostFound")) {
				blendInAction($(this),1);
	    	} else {
	    		blendInErase($(this),erase);
	    	}
	    	if ($(this).val()==this.defaultValue) {
				$(this).val("").select(); // select() kills problems in IE
			}
		});
	    if (!theName.match("lostFound")) {
	    	$(this).addClass("labelled").change(function() {
				$(this).removeClass("error").removeClass("labelled").parent().removeClass("error");
				$(this).addClass("changed");
			}).blur(function(){
				$(this).blurField();
			});
		} else {
	    	$(this).change(function(){
				validateCode($(this));
				$(this).addClass("changed");
			});
		}
	});
	field.find("select").each(function () {
	    $(this).css({color: "#999"});
	    $(this).children('option').attr('selected', false);
	    if($(this).hasClass("shorterSelect")) { /* remove question in order to prohibit wrong display */
	    	$(this).removeClass("shorterSelect").addClass("shortSelect");
	    }
	    $(this).focus(function() {
	    	blendInErase($(this),1);
	    });
	    $(this).change(function() {
			$(this).css({color: "#000"});
		});
	});
}

// copyFields
function copyFields(box) {
	if(browserIE6 == "true") {
		box.closest(".field").next().children(".copyIt").show();
		box.closest(".field").next().next().children(".copyIt").show();
	} else {
		box.closest(".field").next().children(".copyIt").fadeIn(300);
		box.closest(".field").next().next().children(".copyIt").fadeIn(300);
	}
}

function copyIt(box) {
	var firstInput = box.parent().prev().prev().children(".inputBox");
	var secInput = box.parent().prev().children(".inputBox");
	var nextInput = box.parent().next().children(".inputBox");
	var nextSecInput = box.parent().next().next().children(".inputBox");

	nextInput.children(".inputWrapper").eq(0).children("input").val(firstInput.children(".inputWrapper").eq(0).children("input").val()).css({color: "#000"});
	nextInput.children(".inputWrapper").eq(1).children("input").val(firstInput.children(".inputWrapper").eq(1).children("input").val()).css({color: "#000"});
	nextInput.children("select").val(firstInput.children("select").val()).css({color: "#000"});
	nextSecInput.children(".inputWrapper").eq(0).children("input").val(secInput.children(".inputWrapper").eq(0).children("input").val()).css({color: "#000"});
	nextSecInput.children(".inputWrapper").eq(1).children("input").val(secInput.children(".inputWrapper").eq(1).children("input").val()).css({color: "#000"});
	nextSecInput.children("select").val(secInput.children("select").val()).css({color: "#000"});

	firstInput.children(".inputWrapper").children("input").css({color: "#000"});
	secInput.children(".inputWrapper").children("input").css({color: "#000"});
	firstInput.children("select").css({color: "#000"});
	secInput.children("select").css({color: "#000"});

	copyFields(nextInput);
}

// Zeit validieren
function validateTime(el) {

	var msg = unescape("Bitte geben Sie eine g%FCltige Uhrzeit im richtigen Format ein (ss:mm).");
	var alertMsg = false;
	var time = el.attr("value");

	time = time.replace(".",":");
	time = time.replace("/",":");
	time = time.replace("-",":");

	var times = time.split(":");
	var hour = times[0];
	var min = times[1];

	var theMin;
	var theHour;

	var regTime = '([0-1][0-9]|[2][0-3])(:([0-5][0-9]))';

	if(!time.match(regTime)) {
	    if (time != "" && hour <= 24 && (min <= 59 || !min)) {
	    	if(parseFloat(hour) < 10) {
	    		theHour = "0"+parseFloat(hour);
	    	} else {
	    		theHour = hour;
	    	}
	    	if (!min) {
	    		theMin = "00";
	    	} else if (min < 10) {
	    		if (min.length < 2) {
	    			if(min > 5) {
	    				theMin = "00";
	    			} else {
		    			theMin = parseFloat(min)+"0";
		    		}
	    		} else {
	    			theMin = "0"+parseFloat(min);
	    		}
	    	} else {
	    		theMin = min;
	    	}
	    	newTime = theHour+":"+theMin;
	    	el.attr("value",newTime);
	    	if(hour==24) {
	    		if(min=="00" || min=="0" || !min) {
	    			theHour = "24";
	    			theMin = "00";
	    		} else {
	    			alert(msg);
	    			el.attr("value","ss:mm");
	    		}
	    	}
	    } else if (time == "") {
	    	el.attr("value","ss:mm");
	    } else {
	    	alert(msg);
	    	el.attr("value","ss:mm");
	    }
	} else if (time.length < 5) {
	    var newTime = time+"0";
	    el.attr("value",newTime);
	} else {
		el.attr("value",time);
	}
}

// lost&found code validieren
function validateCode(el) {
	var msg = unescape("Bitte geben Sie einen g%FCltigen Anh%E4ngercode ein. Dieser muss aus zehn Ziffern bestehen.");
	var code = el.attr("value");
	var regCode = '([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])';
	if(!code.match(regCode) && code != "") {
	    alert(msg);
	    el.val("");
	}
}
function mandatoryCodeInput() {
  var msg = unescape("Bitte geben Sie einen g%FCltigen Anh%E4ngercode ein. Dieser muss aus zehn Ziffern bestehen.");
  ret = false;
  $("#lostFound input").each(function(index) {
    if ($(this).val() && $(this).val().length>0) { ret = true; }
  });
  if (ret == false) alert(msg);
  return ret;
}

// lost&found order menge validieren
function validateOrder(el) {
	var msg = unescape("Sie k%F6nnen maximal 20 Anh%E4nger bestellen. F%FCr gr%F6%DFere St%FCckzahlen nehmen Sie bitte Kontakt mit uns auf.");
	var amount = el.attr("value");
	var amountOrder = '([0-9]{1,2})';
	if(!amount.match(amountOrder) || amount > 20 || amount <= 0) {
		if(amount != "" && amount > 0 && amount.match(amountOrder)) {
			alert(msg);
		}
		if (amount > 20) {
		    el.val("20");
		} else {
		    el.val("1");
		}
	}
}

// Nutzungsfaelle
function caseIn(theCase) {
	var indexItem = $(".caseWrapper").index(theCase); // get ID of element
	theMargin = (indexItem + 1) * 42;
	if (browserIE6 == "true") {
		theCase.children(".case").children(".caseBody").css({height: "315px"});
		$(".caseWrapper").eq(0).css({marginTop: "-"+theMargin});
	} else {
		theCase.children(".case").children(".caseBody").stop().animate({height: "315px"},450, 'easeOutQuad');
		$(".caseWrapper").eq(0).stop().animate({marginTop: "-"+theMargin},450, 'easeOutQuad');
	}
}

function caseOut(theCase) {
	if (browserIE6 == "true") {
		theCase.children(".case").children(".caseBody").css({height: "99px"});
		$(".caseWrapper").eq(0).css({marginTop: "0"});
	} else {
		theCase.children(".case").children(".caseBody").stop().animate({height: "99px"},500, 'easeOutQuad');
		$(".caseWrapper").eq(0).stop().animate({marginTop: "0"},500, 'easeOutQuad');
	}
}

// econda-notification
function trackIt(toTrack) {
	// layerbox-tracking
	if (toTrack.indexOf('nutzung')>0)             emos_userEvent1('content','Nutzungsfaelle');
    if (toTrack.indexOf('weiterempfehlung')>0)    emos_userEvent1('content','Weiterempfehlung');
    if (toTrack.indexOf('smsRequestNewCode1')>0)  emos_userEvent2('content','SMS Verifizieren', 'private');
    if (toTrack.indexOf('smsRequestNewCode2')>0)  emos_userEvent2('content','SMS Verifizieren', 'business');
    // tab-tracking
    if (toTrack=='#myEntry')     	emos_userEvent2('content','Mein Eintrag', 'Mein Eintrag');
	if (toTrack=='#service')      	emos_userEvent2('content','Mein Eintrag', 'Mein 118000-Service');
	if (toTrack=='#availability') 	emos_userEvent2('content','Mein Eintrag', 'Meine Erreichbarkeit');
	if (toTrack=='#loginData')   	emos_userEvent2('content','Mein Eintrag', 'Zugangsdaten');
}
function trackIt2(toTrack, currentState) {
	// startBox-tracking
	if (currentState=='startBox' || currentState.indexOf('boxNavi')>-1) {
		emos_userEvent2('content',currentState, toTrack);
	}
}

function mappingRedirect4fb(fbUrl){
	fbUrl = fbUrl.replace("presse.do", "presse2.do"); // presse2.do muss konfiguriert sein
	return fbUrl;
}

