var onsiteBasePath = "http://vkb-servicepool.de/wir-planen-auch-ihre-rente/onsite/";
var onsiteTarget = "http://www.wir-planen-auch-ihre-rente.de/wir-planen-auch-ihre-rente/rentenbeispiel.html";
var userGender = null;
var userAge = null;
var userDataComplete = false;

function validateUserData() {
	userAge = $("#inputAlter").val();
	if(userAge != "" && userGender != "" && userAge != null && userGender != null) {
		if($('#inputAlter').val().match(/[0-9]{2}/) != null) {
			userDataComplete = true;
		}
	}
	else {
		userDataComplete = false;
	}
}

$(function() {  
	
	$(".kanalTeaser").empty();
	$(".kanalTeaser").removeAttr("onclick");
	$(".kanalTeaser").removeAttr("style");
	$(".kanalTeaser").attr('style', 'background:url("' + onsiteBasePath + 'img/bgKanalTeaser.jpg") no-repeat');
	var initHTML = '<img id="buttonWeiblich" class="buttonGender" src="' + onsiteBasePath + 'img/buttonWeiblichInact.png" alt="Geschlecht: Weiblich" style="margin-top: 112px; margin-left: 45px;">';
		initHTML += '<img id="buttonMaennlich" class="buttonGender" src="' + onsiteBasePath + 'img/buttonMaennlichInact.png" alt="Geschlecht: Maennlich">';
		initHTML += '<div id="inputAlterContainer" style="padding: 4px 0 0 48px"><form><input id="inputAlter" type="number" size="2" maxlength="2" value="" style="font-size:18px;"/></form></div>';
		initHTML += '<img id="buttonLoslegen" src="' + onsiteBasePath + 'img/buttonLoslegenInact.png" alt="Jetzt Loslegen"  style="margin-top: 72px; margin-left: 25px;">';
	$(".kanalTeaser").append(initHTML);
	
	$("#buttonWeiblich").hover(
		function () {
			$(this).attr('src', onsiteBasePath + 'img/buttonWeiblichAct.png');
		},
		function () {
			if(userGender != "female") {
				$(this).attr('src', onsiteBasePath + 'img/buttonWeiblichInact.png');
			}
		}
	);
	$("#buttonWeiblich").click(
		function () {
			userGender = "female";
			$(this).attr('src', onsiteBasePath + 'img/buttonWeiblichAct.png');
			$("#buttonMaennlich").attr('src', onsiteBasePath + 'img/buttonMaennlichInact.png');
		}
	);
	
	$("#buttonMaennlich").hover(
		function () {
			$(this).attr('src', onsiteBasePath + 'img/buttonMaennlichAct.png');
		},
		function () {
			if(userGender != "male") {
				$(this).attr('src', onsiteBasePath + 'img/buttonMaennlichInact.png');
			}
		}
	);
	$("#buttonMaennlich").click(
		function () {
			userGender = "male";
			$(this).attr('src', onsiteBasePath + 'img/buttonMaennlichAct.png');
			$("#buttonWeiblich").attr('src', onsiteBasePath + 'img/buttonWeiblichInact.png');
		}
	);
	$("#buttonLoslegen").hover(
		function () {
			$(this).attr('src', onsiteBasePath + 'img/buttonLoslegenAct.png');
		},
		function () {
			$(this).attr('src', onsiteBasePath + 'img/buttonLoslegenInact.png');
		}
	);
	$("#inputAlter").keyup(
		function() {
			if ($('#inputAlter').val().match(/[0-9]{2}/) == null) {
				$('#inputAlter').empty();
			}
		}
	);
	$("#buttonLoslegen").click(
		function () {
			validateUserData();
			if(userDataComplete == true) {
				window.open(onsiteTarget + "?" + userGender + "&" + userAge);
				//window.location.href = onsiteTarget + "?" + userGender + "&" + userAge;
			}
		}
	);
	
	$(".standardteaser-left:eq(0)").empty();
	$(".standardteaser-left:eq(0)").removeAttr("onclick");
	$(".standardteaser-left:eq(0)").click(function() {
		window.open("http://www.gesundheit-im-dialog.de/gesundheit-im-dialog/")
	});
	$(".standardteaser-left:eq(0)").removeAttr("style");
	$(".standardteaser-left:eq(0)").attr('style', 'background:url("' + onsiteBasePath + 'img/bgTeaserGID.jpg") no-repeat; cursor:pointer;');
	initHTML = '<div style="position:relative; top:202px; left:15px; color:#0055aa; font: Arial, Helvetica, sans-serif, Verdana; font-size:12px; line-height:15px;">';
	initHTML += '<b>Gesundheit im Dialog</b><br />';
	initHTML += 'Die Initiative Ihrer Privaten Krankenversicherer<br />beantwortet wichtige Fragen.</div>';
	$(".standardteaser-left:eq(0)").append(initHTML);
	
	//$(".standardteaser-left:eq(1)").empty();
	//$(".standardteaser-left:eq(1)").removeAttr("onclick");
	//$(".standardteaser-left:eq(1)").click(function() {
	//	document.location.href="http://www.vkb.de/web/html/pk/service/premium_offen/vorteile_premium/";
	//});
	//$(".standardteaser-left:eq(1)").removeAttr("style");
	//$(".standardteaser-left:eq(1)").attr('style', 'background:url("' + onsiteBasePath + 'img/bgTeaserPremium.jpg") no-repeat; cursor:pointer;');
	//initHTML = '<div style="position:relative; top:202px; left:15px; color:#0055aa; font: Arial, Helvetica, sans-serif, Verdana; font-size:12px; line-height:15px;">';
	//initHTML += '<b>Premiumservice</b><br />';
	//initHTML += 'Online-Vertragsansicht mit<br />vielen Vorteilen - exklusiv und<br />kostenlos.</div>';
	//$(".standardteaser-left:eq(1)").append(initHTML);
	
	$(".standardteaser-left:eq(1)").empty();
	$(".standardteaser-left:eq(1)").removeAttr("onclick");
	$(".standardteaser-left:eq(1)").click(function() {
		document.location.href="http://www.vkb.de/web/html/pk/versicherungen/kraftfahrt/pkw_motorrad/produktuebersicht/";
	});
	$(".standardteaser-left:eq(1)").removeAttr("style");
	$(".standardteaser-left:eq(1)").attr('style', 'background:url("' + onsiteBasePath + 'img/bgTeaserKfz.jpg") no-repeat; cursor:pointer;');
	initHTML = '<div style="position:relative; top:202px; left:15px; color:#0055aa; font: Arial, Helvetica, sans-serif, Verdana; font-size:12px; line-height:15px;">';
	initHTML += '<b>Sicher auf der Stra&szlig;e</b><br />';
	initHTML += 'Hier finden Sie die<br />passende Kfz-Versicherung.</div>';
	$(".standardteaser-left:eq(1)").append(initHTML);
	
	$(".start_bedarf:eq(0)").empty();
	$(".start_bedarf:eq(0)").removeAttr("onclick");
	$(".start_bedarf:eq(0)").click(function() {
		document.location.href="http://www.vkb.de/web/html/pk/service/aktuelles/rente/uebersicht_rente/index.html";
	});
	$(".start_bedarf:eq(0)").removeAttr("style");
	$(".start_bedarf:eq(0)").attr('style', 'background:url("' + onsiteBasePath + 'img/bgTeaserRente.jpg") no-repeat; cursor:pointer;');
	initHTML = '<div style="position:relative; top:80px; left:15px; color:#0055aa; font: Arial, Helvetica, sans-serif, Verdana; font-size:12px; line-height:15px;">';
	initHTML += '<b>Vers&uuml;&szlig;en Sie Ihre Rente</b><br />';
	initHTML += 'Heute vorsorgen und die<br />Zukunft unbeschwert genie&szlig;en.</div>';
	$(".start_bedarf:eq(0)").append(initHTML);
	
	$(".xSchnellStart_Hintergrund:eq(0)").removeAttr("style");
	$(".xSchnellStart_Hintergrund:eq(0)").attr('style', 'background:#bdcee8;');
});

