





var flashString="";
var timer;
var timer2;
var id;

/* Open Popup Window */
function openPopup(targetUrl)
{
 fenster=window.open(targetUrl, 'Popup', 'width=600,height=720,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes');
 fenster.focus();
}

/* Open Popup Window for new WTU */
function openPopup2(targetUrl)
{
 fenster=window.open(targetUrl, 'Popup', 'width=970,height=750,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes');
 fenster.focus();
}


// Flash Calculators: 
// preset values of Flash Calculator
function presetCalculator(Amount,Term, monthlyRate){
//		alert("Amount in presetCalculator:"+Amount);
//		alert("Term in presetCalculator:"+Term);
		flashString = "amount="+Amount+"&term="+Term+"&monthlyRate="+monthlyRate;
//		alert("flashString in presetCalculator = "+flashString);
		document.getElementById("Amount").value = Amount;
		document.getElementById("Term").value = Term;
		document.getElementById("monthlyRate").value = monthlyRate;
}


// Flash Calculators: 
// builds URL with GET parameters (Amount / Term) for the receiving page to put the slide controls in the same position
function submitFlashData(url){
	var Amount = document.getElementById("Amount").value;
	var Term = document.getElementById("Term").value;
	var monthlyRate = document.getElementById("monthlyRate").value;
	
	url = url + "?Amount=" + Amount + "&Term="+ Term + "&monthlyRate="+ monthlyRate;
//	alert ("Amount in submitFlashData:"+Amount);
//	alert ("Term in submitFlashData:"+Term);
//	alert ("URL built in submitFlashData:"+url);
	document.location.href= url;
}

// Flash Calculators: 
// writes HIDDEN fields into the product page
// these hidden fields are used to transfer Amount & Term to the full calculator at http://www.finansbank.de/finansbank/germany/german/consumer_banking/loans/personal/calculator/payments/index.jsp
function transferData(Amount,Term, monthlyRate){
//	alert ("Amount in transferData:"+Amount);
//	alert ("Term in transferData:"+Term);
	document.getElementById("Amount").value = Amount;
	document.getElementById("Term").value = Term;
	document.getElementById("monthlyRate").value = monthlyRate;
	document.getElementById("Installment").value = monthlyRate;
//	alert ("Amount in transferData:"+Amount);
//	alert ("Term in transferData:"+Term);
}

// Flash Calculators: 
// reads GET parameters from URL (Amount / Term) to put the slide controls in the same position as before selected by the user
function receiveGetString(){
	query = self.location.search;
	sammlung = new Array();

	if (query != ''){

		query = query.substr(1, query.length - 1);
		query = query.replace(/%26/,'&');
		teile = query.split('&');
	
		for (i = 0; i < teile.length; i++){
			teile[i] = teile[i].split('=');
			sammlung[teile[i][0]] = teile[i][1];
		}
		Amount = teile[0][1];
		Term = teile[1][1];
		monthlyRate = teile[2][1];
//		alert("Amount in receiveGetString:"+Amount);
//		alert("Term in receiveGetString:"+Term);
		transferData(Amount,Term, monthlyRate);
		flashString = "amount=" + Amount + "&term="+ Term + "&monthlyRate="+ monthlyRate;
//		alert("flashString in receiveGetString:"+flashString);
	}else{
		presetCalculator(10000,60,190);
	}
}

/* Preload Images for Mouse overs in Navi */
function loadImg() {
	var img = new Array('nav_consumer_banking.gif','nav_consumer_banking_over.gif','nav_consumer_banking_active.gif','nav_corporate_banking.gif','nav_corporate_banking_over.gif','nav_corporate_banking_active.gif','nav_bank_relations.gif','nav_bank_relations_over.gif','nav_bank_relations_active.gif','nav_intermediaries.gif','nav_intermediaries_over.gif','nav_intermediaries_active.gif','nav_about_us.gif','nav_about_us_over.gif','nav_about_us_active.gif','nav_representations.gif','nav_representations_over.gif','nav_representations_active.gif');
	document.preload = new Array();
	
	if(document.images)	{
		//alert(img.length);
		for(var i=0; i<img.length; i++){
			//alert(img[i]);
			document.preload[i] = new Image();
			document.preload[i].src = fb_resources + "/pics/" + fb_country + "/" + fb_language + "/" + img[i];
		}
	}
}

// 1st level mouseover
function mOver() {
	var e = this.id;
	var pic = document.getElementById(e+"Img");
	var picId = pic.id;
	if(document.getElementById(pic.id)) {
		if(picId.indexOf("Active")==-1) {
			if (pic.src.substring(pic.src.length-9,pic.src.length) != "_over.gif") {
					pic.src = pic.src.substring(0,pic.src.length-4)+"_over.gif";
			}
		}
	}
}

// 1st level mouseout
function mOut() {
	closeAllSubnavs();
	//alert(this.id);
	var e = this.id;
	var pic = document.getElementById(e+"Img");
	var picId = pic.id;
	if(document.getElementById(pic.id)) {
		if(picId.indexOf("Active")==-1) {
			pic.src = pic.src.substring(0,pic.src.length-9)+".gif";
		}
	}
}

// close all subnavs and open the one required
function openSubnav() {
	clear_Timeout();
	var d = document.getElementById('s'+this.id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
	if (d) {d.style.display='block';}
}

// close specific subnav
function closeSubnav(object) {
	//alert(object.id);
	var e = (object)? object.id : this.id;
	var dd = document.getElementById(e);
	
	dd.style.display = '';
	
}

// close all subnavs
function closeAllSubnavs(){
	var dds = document.getElementsByTagName("dd");
	for(var i = 0; i < dds.length; i++) {
		closeSubnav(dds[i]);
	}
}

// close all subnavs after a certain time
// e.g. mouse leaves 2nd level nav without going over 3rd level 
function closeSubnavTimer(){
	if (timer2) window.clearTimeout(timer2);
	timer2 = window.setTimeout("closeAllSubnavs()",100);
}

// close specific subnav after a certain time 
// eg mouse leaves 3rd level nav
function start_Timeout(){
	id = this.id;
	if (timer) window.clearTimeout(timer);
	timer = window.setTimeout("closeSubnav(this)",100);
}

// clear timeouts to avoid closing of navs
function clear_Timeout(){
	if (timer) window.clearTimeout(timer);
	if (timer2) window.clearTimeout(timer2);
}


function init() {
	try {
		initLinkEventsMainNav();
		loadImg(); // preload images of nav
	} catch(e) {
		/* ignore */
	}
}

function initLinkEventsMainNav() {
	// All tags of type 'a'
	// in nav
	var navId = document.getElementById("nav");
	var elems = navId.getElementsByTagName('a');
	// behaviour of links in nav 1st level
	for(var i = 0; i < elems.length; i++) {
		if (elems[i].href) {
			//alert('initLinkElements: elems[' + i + '].href=' + elems[i].href);
			elems[i].onmouseover = mOver;
			elems[i].onmouseout = mOut;
		}
	}
}

function initLinkEvents() {
	// All tags of type 'a'
	// in nav
	var navId = document.getElementById("nav");
	var elems = navId.getElementsByTagName('a');
	var dts = document.getElementsByTagName("dt");
	var dds = document.getElementsByTagName("dd");
	
	// behaviour of links in nav 1st level
	for(var i = 0; i < elems.length; i++) {
		if (elems[i].href) {
			//alert('initLinkElements: elems[' + i + '].href=' + elems[i].href);
			elems[i].onmouseover = mOver;
			elems[i].onmouseout = mOut;
		}
	}
	// behaviour of nav 2nd level
	for(var j = 0; j < dts.length; j++) {
		dts[j].onmouseout = closeSubnavTimer;
		dts[j].onmouseover = openSubnav;
	}
	// behaviour of nav 3rd level
	for(var k = 0; k < dds.length; k++) {
		dds[k].onmouseout = start_Timeout;
		dds[k].onmousemove = clear_Timeout;
	}
}

function popup_print(url) {
 fenster=window.open(url, "drucken", "width=900,height=500,resizable=no,scrollbars=yes,menubar=yes");
 fenster.focus();
 return false;
}


var sfHover = function() {
	if(document.getElementById("ulSubnav")){
	var sfEls = document.getElementById("ulSubnav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

window.onload = init;


function toggle_div(object){
	for (var i=1;i<5;i++){
		if (document.getElementById(object.id)!=document.getElementById('produkt_menu_'+i)){
			document.getElementById('produkt_menu_'+i+'_div').style.display='none';
		  	document.getElementById('produkt_menu_'+i).className="menu_head";
		}
		else {
		document.getElementById(object.id+'_div').style.display='block';
		document.getElementById(object.id).className="menu_head_active";
		
		}
	}
}

function popupIB(url)
  {
      window.open(url, 'win1','top=0,left=0,toolbar=0,width=1014,height=688,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=1,copyhistory=1');
  }





function show(obj){
		var objID = document.getElementById(obj);
		 objID.style.display = "block";
}

function hide(obj){
		var objID = document.getElementById(obj);
		 objID.style.display = "none";
}


function show_hide(obj){
		var objID = document.getElementById(obj);
		//alert(obj[i]);
		if (objID.style.display !="block"){
			objID.style.display = "block";
		}
		else
			{objID.style.display = "none";
		}
}

function subscribe2Newsletter(email) {
   openPopup(fb_siteroot + fb_language + '/about/news/newsletter/subscribe.jsp?e=' + email);	
}

function subscribe2NewsletterDE(email) {
   openPopup('http://newsletter.crediteurope.de/reg.php?EMAIL=' + email);
}

