agent = navigator.userAgent.toLowerCase();

function initSDK() {
 var formtags=['input','textarea','select'];
 for (var t=0; t < formtags.length; t++) {
  for (var i=0; i < document.getElementsByTagName(formtags[t]).length; i++) {
   if (document.getElementsByTagName(formtags[t])[i].getAttribute('type')=="submit" || document.getElementsByTagName(formtags[t])[i].getAttribute('type')=="image" || document.getElementsByTagName(formtags[t])[i].getAttribute('type')=="button") continue;
   document.getElementsByTagName(formtags[t])[i].onfocus = function(e){handleFocus(e);};
   document.getElementsByTagName(formtags[t])[i].onblur = function(e){handleBlur(e);};
  }
 }

 initFlash();
};

function checkRueckgewaehrBlock() {

	if (document.getElementById('beginn_rentenzahlung_sofort').checked == true) {
		document.getElementById('rueckgewaehr_block').style.display = "none";
	} else {
		document.getElementById('rueckgewaehr_block').style.display = "block";
	}
}

function checkBeginnZahlungBlock() {

	if (document.getElementById('zahlungsweise').value == 'einmalig') {
		document.getElementById('beginn_rente_sofort').style.display = "block";
	} else {
		document.getElementById('beginn_rente_sofort').style.display = "none";
	}
}

function checkUmstellunsBlock() {
	
	if (document.getElementById('umstellung').checked == true) {
		document.getElementById('umstellungsblock').style.display = "block";
	} else {
		document.getElementById('umstellungsblock').style.display = "none";
	}
}


function checkUmstellunsBlock1() {
	
	if (document.getElementById('umstellung').checked == true) {
		document.getElementById('umstellungsblock').style.display = "block";
		document.getElementById('umstellungsblock2').style.display = "block";
	} else {
		document.getElementById('umstellungsblock').style.display = "none";
		document.getElementById('umstellungsblock2').style.display = "none";
	}
}





function checkZahlungsdauerBlock() {
	if (document.getElementById('zahlungsweise').value == 'einmalig') {
		document.getElementById('zahlungsdauer_block').style.display = "none";
	} else {
		document.getElementById('zahlungsdauer_block').style.display = "block";
	}
}

function checkErhoehungsBlock() {
	if (document.getElementById('zahlungsweise').value == 'einmalig') {
		document.getElementById('erhoehungs_block').style.display = "none";
	} else {
		document.getElementById('erhoehungs_block').style.display = "block";
	}
}

function checkBerufsInfoBlock() {
	if (document.getElementById('zahlungsweise').value == 'einmalig') {
		document.getElementById('berufsunfaehigkeits_info_block').style.display  = "none";
		document.getElementById('berufsunfaehigkeits_detail_block').style.display = "none";
	} else {
		document.getElementById('berufsunfaehigkeits_info_block').style.display = "block";
		
		if (document.getElementById('f43').checked == true) {
			document.getElementById('berufsunfaehigkeits_detail_block').style.display = "block";
		}
	}
}

function checkBerufsDetailBlock() {

	if (document.getElementById('zahlungsweise').value == 'einmalig' || (document.getElementById('f43').checked == false)) {
		document.getElementById('berufsunfaehigkeits_detail_block').style.display = "none";
	} else {
		document.getElementById('berufsunfaehigkeits_detail_block').style.display = "block";
	}
}

function handleFocus(e) {
 target = (! e) ? window.event.srcElement : e.target;
 target = (target.type && (target.type=='radio' || target.type=='checkbox')) ? target.parentNode.parentNode : target.parentNode;
 target.prevClass = target.className;
 target.className += ' focus';
}

function handleBlur(e) {
 target = (! e) ? window.event.srcElement : e.target;
 target = (target.type && (target.type=='radio' || target.type=='checkbox')) ? target.parentNode.parentNode : target.parentNode;
 target.className = target.prevClass;
}



// Flash
// <div class="flashobject"><img src="img/..." width="" height="" /></div>
flashVersion = 0; flashEnabled="";
function initFlash() {
 if (navigator.plugins != null && navigator.plugins.length > 0) {
  var flashPlugin = navigator.plugins['Shockwave Flash'];
  if (typeof flashPlugin == 'object') {for (var i = 9; i >= 4; i--) {if (flashPlugin.description.indexOf(i + '.') != -1) { flashVersion = i; break; }}}
 } else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1) {
  document.write('<scr' + 'ipt language="VBScript"\>\nOn Error Resume Next \nDim obFlash \nFor i = ' + 9 + ' To 4 Step -1 \nSet obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \nIf IsObject(obFlash) Then \nflashVersion = i \nExit For \nEnd If \nNext \n</scr' + 'ipt\> \n');
 }

 flashEnabled = (flashVersion >= 5) ? true : false;
 if (! flashEnabled) return;

 var i=0;
 while (objdiv = document.getElementsByTagName("div")[i++]) {
  if (objdiv.className.indexOf("flashobject")==-1) continue;
  objdiv.innerHTML = getFlashHTML(objdiv.firstChild.src.replace(/(\.jpg)|(\.gif)|(\.png)/,'.swf'),objdiv.firstChild.width,objdiv.firstChild.height);
 }
}

function getFlashHTML(fname, width, height) {
 return "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\""+width+"\" height=\""+height+"\"><param name=\"movie\" value=\""+fname+"\" /><param name=\"menu\" value=\"false\" /><param name=\"quality\" value=\"high\" /><param name=\"scale\" value=\"noscale\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"bgcolor\" value=\"#ffffff\" /><embed src=\""+fname+"\" menu=\"false\" quality=\"high\" scale=\"noscale\" wmode=\"transparent\" bgcolor=\"#ffffff\" width=\""+width+"\" height=\""+height+"\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed></object>";
}




document.write('<style type="text/css">#helpsection{display:none;}</style>');

function helpMe(anchor) {
 document.getElementById('helpcontainer').innerHTML = document.getElementById( anchor.href.split('#')[1] ).innerHTML;
 window.scrollTo(0,0);
 return false;
}

function helpMeGewinn(anchor) {
 document.getElementById('helpcontainer').innerHTML = document.getElementById( anchor.href.split('#')[1] ).innerHTML;
 return false;
}

function checkMainSearchEnter(evt) {
	if (evt.keyCode==13) document.getElementById("search").submit();
	return true;
}
