Cufon.replace('h1', {
	textShadow: '1px 1px rgba(0, 0, 0, 0.2)'
});

Cufon.replace('h2');
Cufon.replace('#top_menu a');
Cufon.replace('#bottom_menu a', {
	hover: true} );

/************************************************************* */

function addGuestBookEvents()
{
	var oDuration = 0.5;
	
	var over_a_in;
	var over_a_out;
	
	var out_a_in;
	var out_a_out;
	
	$('a_guestbook').observe('mouseover', (function(event) { 
		Event.stop(event);
		
		try 
		{
			out_a_in.cancel();
			out_a_out.cancel();
		}
		catch(err) { }
		
		over_a_in = new Effect.Opacity('a_guestbook_in', { duration: oDuration, to: 0 });
		over_a_out = new Effect.Opacity('a_guestbook_out', { duration: oDuration, to: 1 });
		
		}));
		
	$('a_guestbook').observe('mouseout', (function(event) {
		Event.stop(event);
		
		try 
		{
			over_a_in.cancel();
			over_a_out.cancel();
		}
		catch(err) { }
		
		out_a_in = new Effect.Opacity('a_guestbook_out', { duration: oDuration, to: 0 });
		out_a_out = new Effect.Opacity('a_guestbook_in', { duration: oDuration, to: 1 });
		
		}));
}

/************************************************************* */

function setupGastebuchInput(input_name, input_description)
{
	if ($('input_' + input_name).value == '')
		$('input_' + input_name).value = input_description;

    $('input_' + input_name).observe('click', function(event){
		element = event.element();
		if (element.value == input_description) element.value = '';
		element.focus();
		element.addClassName("hover");
    })

    $('input_' + input_name).observe('blur', function(event){
		element = event.element();
		if (element.value == '') element.value = input_description;
		element.removeClassName("hover");
    })
}

function setupGastebuchTextarea(input_name, input_description)
{
	if ($('input_' + input_name).innerHTML  == '')
		$('input_' + input_name).innerHTML = input_description;

    $('input_' + input_name).observe('click', function(event){
		element = event.element();
		if (element.innerHTML == input_description) element.innerHTML = '';
		element.addClassName("hover");
    })

    $('input_' + input_name).observe('blur', function(event){
		element = event.element();
		if (element.innerHTML == '') element.innerHTML = input_description;
		element.removeClassName("hover");
    })
}

function checkGastebuchInput(input_name, input_description)
{
	if ($('input_' + input_name).value == input_description)
		$('input_' + input_name).value = '';
}

function checkGastebuchTextarea(input_name, input_description)
{
	if ($('input_' + input_name).innerHTML == input_description)
		$('input_' + input_name).innerHTML = '';
}

function setupGastebuchForm()
{
	setupGastebuchInput('name', 'Name:');
	setupGastebuchInput('email', 'E-mail:');
	setupGastebuchInput('homepage', 'Homepage:');
	setupGastebuchInput('icq', 'ICQ:');
	setupGastebuchInput('wohnort', 'Wohnort:');
	setupGastebuchTextarea('content', 'Kommentar:');

	$('gastebuch_form').observe('submit', function(event){
		checkGastebuchInput('name', 'Name:');
		checkGastebuchInput('email', 'E-mail:');
		checkGastebuchInput('homepage', 'Homepage:');
		checkGastebuchInput('icq', 'ICQ:');
		checkGastebuchInput('wohnort', 'Wohnort:');
		checkGastebuchTextarea('content', 'Kommentar:');
	})
}

function setInpuAsBad(input_name)
{
	$('input_' + input_name).addClassName("bad_value");
}

/************************************************************* */

function hidePopupm(id)
{
	document.getElementById(id + '-ddcontent').style.display = 'none';
	document.getElementById(id + '-ddcontent').style.opacity = 0;
}

var DDSPEED = 3;
var DDTIMER = 15;

// main function to handle the mouse events //
function ddMenu(id,d){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearInterval(c.timer);
  if(d == 1){
  	 document.getElementById(id + '-ddheader').style.backgroundPosition  = 'bottom';
    clearTimeout(h.timer);
    if(c.maxh && c.maxh <= c.offsetHeight){return}
    else if(!c.maxh){
      c.style.display = 'block';
      c.style.height = 'auto';
      c.maxh = c.offsetHeight;
      c.style.height = '0px';
    }
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }else{
  	 document.getElementById(id + '-ddheader').style.backgroundPosition  = 'top';	
    h.timer = setTimeout(function(){ddCollapse(c)},50);
  }
}

// collapse the menu //
function ddCollapse(c){
  c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
}

// cancel the collapse if a user rolls over the dropdown //
function cancelHide(id){
  document.getElementById(id + '-ddheader').style.backgroundPosition  = 'bottom';
	
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
	
  clearTimeout(h.timer);
  clearInterval(c.timer);
  if(c.offsetHeight < c.maxh){
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(c,d){
  var currh = c.offsetHeight;
  var dist;
  if(d == 1){
    dist = (Math.round((c.maxh - currh) / DDSPEED));
  }else{
    dist = (Math.round(currh / DDSPEED));
  }
  if(dist <= 1 && d == 1){
    dist = 1;
  }
  c.style.height = currh + (dist * d) + 'px';
  c.style.opacity = currh / c.maxh;
  c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
    clearInterval(c.timer);
  }
}

/*************************************************************
 * Window Onload Manager (WOM) v1.0
 * Author: Justin Barlow - www.netlobo.com
 *
 * Description:
 * The WOM library of functions allows you to easily call
 * multiple javascript functions when your page loads.
 *
 * Usage:
 * Add functions to WOM using the womAdd() function. Pass the
 * name of your functions (with or without parameters) into
 * womAdd(). Then call womOn() like this:
 *     womAdd('hideDiv()');
 *     womAdd('changeBg("menuopts","#CCCCCC")');
 *     womOn();
 * WOM will now run when your page loads and run all of the
 * functions you have added using womAdd()
 *************************************************************/

/*************************************************************
 * The womOn() function will set the window.onload function to
 * be womGo() which will run all of your window.onload
 * functions.
 *************************************************************/
function womOn(){
	window.onload = womGo;
}

/*************************************************************
 * The womGo() function loops through the woms array and
 * runs each function in the array.
 *************************************************************/
function womGo(){
	for(var i = 0;i < woms.length;i++)
		eval(woms[i]);
}

/*************************************************************
 * The womAdd() function will add another function to the woms
 * array to be run when the page loads.
 *************************************************************/
function womAdd(func){
	woms[woms.length] = func;
}

/*************************************************************
 * The woms array holds all of the functions you wish to run
 * when the page loads.
 *************************************************************/
var woms = new Array();
