function change_donation_type() {
	donation_debit = document.getElementById('donation_data_debit');
	donation_card = document.getElementById('donation_data_card');
	display_debit = donation_debit.style.display;
	display_card = donation_card.style.display;
	donation_debit.style.display = (display_debit == "block") ? "none" : "block";
	donation_card.style.display = (display_card == "block") ? "none" : "block";
}

// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function display_info_layer() {
    var objBody = $$('body')[0];
    var arrayPageSize = getPageSize();
    layer = 'info_layer';
    //add overlay
    objBody.appendChild(Builder.node('div',{id:'overlay'}));
    
    if(self.innerWidth==undefined)
    {
        arrayPageSize[0] = document.documentElement.clientWidth;
    }
    //arrayPageSize[0] = window.outerWidth;
    var leftOffset = (arrayPageSize[0] > 1024) ? Math.floor((1024-arrayPageSize[0])/2)+7 : 0;
    overlayLayer = document.getElementById('overlay');
    //$('overlay').hide();
    overlayLayer.style.opacity = '0.6';
    overlayLayer.style.filter  = 'Alpha(opacity=60)';
    overlayLayer.style.width   = arrayPageSize[0]+'px';
    overlayLayer.style.height  = arrayPageSize[1]+'px';
    //overlayLayer.style.left    = leftOffset+'px';
    //document.getElementById('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px', left: leftOffset+'px', opacity: 0 });
    
    overlayLayer = document.getElementById('overlay');
    //new Effect.Appear(overlayLayer, { duration: 0.2, from: 0.0, to: 0.4 });
    //alert(document.documentElement.scrollTop);
    var offsetTop = (window.pageYOffset > -1) ? window.pageYOffset : document.documentElement.scrollTop;
    position = 'top:'+(offsetTop+50)+'px;';
    //alert(position);
    objBody.appendChild(Builder.node('div',{id: 'info_layer', style: position},[
          Builder.node('div',{id:'info_layer_content'})]));
    
    // Close layer on ESC keypress:
    Event.observe(document, 'keypress', function(event){ if(event.keyCode == Event.KEY_ESC) hide_info_layer();});
}

function hide_info_layer()
{
    var objBody = $$('body')[0];
    layer = "info_layer";
    ov = objBody.removeChild(document.getElementById("overlay"));
    objBody.removeChild(document.getElementById(layer));
}

function getPageSize() {
    
    var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	return [windowWidth,pageHeight];
}

function countdown(endDateYear, endDateMonth, endDateDay, now)
{
    currentDate = now;
    elem = document.getElementById("challenge_countdown");
    endDate = new Date(endDateYear, endDateMonth-1, endDateDay, 23, 59, 59);
    currentDate = new Date();
    days    = Math.floor((endDate.getTime() - currentDate.getTime()) / 86400000);
    hours   = Math.floor((endDate.getTime() - currentDate.getTime()) % 86400000 / 3600000);
    minutes = Math.floor((endDate.getTime() - currentDate.getTime()) % 3600000 / 60000);
    seconds = Math.floor((endDate.getTime() - currentDate.getTime()) % 60000 / 1000);
    if(seconds < 10)
    {
      seconds = "0"+seconds;
    }
    if(minutes < 10)
    {
      minutes = "0"+minutes;
    }
    if(hours < 10)
    {
      hours = "0"+hours;
    }
    /*
    if(days < 10)
    {
      days = "0"+days;
    }
    */
    minStr  = (minutes != "01") ? "Minuten" : "Minute" ;
    secStr  = (seconds != "01") ? "Sekunden" : "Sekunde" ;
    hourStr = (hours != "01") ? "Stunden" : "Stunde" ;
    dayStr  = (days != "01") ? "Tage" : "Tag" ;
    elem.innerHTML = "noch "+days+" "+dayStr+" - "+hours+" "+hourStr+" - "+minutes+" "+minStr+"";
//    alert(elem.value);
    setTimeout('countdown('+endDateYear+', '+endDateMonth+', '+endDateDay+', '+(now-200)+')',30000);
}