function configAddressType(suf)
{
	var selector = findObject('addresstype'+suf);
	if(!selector) return;
	
	switch (selector.value) {
		case "normal": 
			changeProp('street_box'+suf,'style.display','inline');
			changeProp('streetnr_box'+suf,'style.display','inline');
			changeProp('psbox_box'+suf,'style.display','none');
			changeProp('pscustomer_box'+suf,'style.display','none');
			changeProp('pobox_box'+suf,'style.display','none');
			break;
		case "postfach":
			changeProp('street_box'+suf,'style.display','none');
			changeProp('streetnr_box'+suf,'style.display','none');
			changeProp('psbox_box'+suf,'style.display','none');
			changeProp('pscustomer_box'+suf,'style.display','none');
			changeProp('pobox_box'+suf,'style.display','inline');
			break;
		case "packstation": 
			changeProp('street_box'+suf,'style.display','none');
			changeProp('streetnr_box'+suf,'style.display','none');
			changeProp('psbox_box'+suf,'style.display','inline');
			changeProp('pscustomer_box'+suf,'style.display','inline');
			changeProp('pobox_box'+suf,'style.display','none');
			break;
		default: break;
	}
}

function configPaymentType()
{
	var selector = findObject('paymenttype');
	if(!selector) return;

	switch (selector.value) {
		case "invoice": 
			changeProp('debit_bank_box','style.display','none');
			changeProp('debit_account_box','style.display','none');
			changeProp('debit_banknr_box','style.display','none');
			changeProp('credit_institute_box','style.display','none');
			changeProp('credit_card_box','style.display','none');
			changeProp('credit_cvc_box','style.display','none');
			changeProp('credit_valid_box','style.display','none');
			break;
		case "debit":
			changeProp('debit_bank_box','style.display','inline');
			changeProp('debit_account_box','style.display','inline');
			changeProp('debit_banknr_box','style.display','inline');
			changeProp('credit_institute_box','style.display','none');
			changeProp('credit_card_box','style.display','none');
			changeProp('credit_cvc_box','style.display','none');
			changeProp('credit_valid_box','style.display','none');
			break;
		case "credit": 
			changeProp('debit_bank_box','style.display','none');
			changeProp('debit_account_box','style.display','none');
			changeProp('debit_banknr_box','style.display','none');
			changeProp('credit_institute_box','style.display','inline');
			changeProp('credit_card_box','style.display','inline');
			changeProp('credit_cvc_box','style.display','inline');
			changeProp('credit_valid_box','style.display','inline');
			break;
		default: break;
	}
}

var SLIDETIMER = 3;
var SLIDESPEED = 3;
var SCROLLTIMER = 3;
var SCROLLSPEED = 1;
var STARTINGOPACITY = 40;


// handles manual scrolling of the content //
function scrollContent(id,dir) {
  var div = document.getElementById(id);
  clearInterval(div.timer);
  var sections = div.getElementsByTagName('div');
  var length = sections.length;
  var limit;
  if(dir == -1) {
    limit = 0;
  } else {
    if(length > 1) {
      limit = sections[length-1].offsetTop;
    } else {
      limit = sections[length-1].offsetHeight - div.parentNode.offsetHeight + 20;
    }
  }
  div.style.opacity = STARTINGOPACITY * .01;
  div.style.filter = 'alpha(opacity=' + STARTINGOPACITY + ')';
  div.timer = setInterval( function() { scrollAnimate(div,dir,limit) }, SCROLLTIMER);
}

function scrollAnimate(div,dir,limit) {
  div.style.top = div.style.top || '0px';
  var top = div.style.top.replace('px','');
  if(dir == 1) {
	if(limit - Math.abs(top) <= SCROLLSPEED) {
	  cancelScroll(div.id);
	  div.style.top = '-' + limit + 'px';
	} else {
	  div.style.top = top - SCROLLSPEED + 'px';
	}
  } else {
	if(Math.abs(top) - limit <= SCROLLSPEED) {
	  cancelScroll(div.id);
	  div.style.top = limit + 'px';
	} else {
	  div.style.top = parseInt(top) + SCROLLSPEED + 'px';
	}
  }
}

// cancel the scrolling on mouseout //
function cancelScroll(id) {
  var div = document.getElementById(id);
  div.style.opacity = 1;
  div.style.filter = 'alpha(opacity=100)';
  clearTimeout(div.timer);
}
