onload = function ()
{
	var links = document.getElementsByTagName('A');
	var count = links.length;
	
	for(var i = 0; i < count; i++) {
		links[i].onfocus = new Function('this.blur()');
	}
}

function toggleLogIn()
{
	Effect.toggle('login', 'slide');
}

function toggleNewsletter()
{
	Effect.toggle('newsletter', 'slide');
}

function popup(url, width, height, name) {
	var p = window.open(url, '', "left="+(screen.availWidth-width)/2+",top="+(screen.availHeight-height)/2+",width="+width+",height="+height+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollBars=no,resizable=no");
	if (p) {
		p.outerWidth = width;
		p.outerHeight = height;
		p.focus();
	}
}

var warenkorb = false;

function toggleWarenkorb()
{
	Effect.toggle('warenkorb_vorschau', 'slide', { duration: 0.3, transition: Effect.Transitions.linear, fps: 100 });
	if(warenkorb) {
		warenkorb = false;
		$('warenkorb_oeffnen').src = '/img/teaser/warenkorb.gif';
	}
	else {
		warenkorb = true;
		$('warenkorb_oeffnen').src = '/img/teaser/warenkorb2.gif';
	}
}

function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}




var posX, posY;
document.onmousemove = function(e) {
   try {
   	if (!e) var e = window.event;
    if (e.pageX || e.pageY) {
		posX = e.pageX;
		posY = e.pageY;
	}
	else if (e.clientX || e.clientY) {
		posX = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft);
		posY = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop);
	}
  } catch (er) {}
}

function ShowElement(id){
  document.getElementById(id).style.display = "block";
}

function PosToMouseElement(id) {
  	x 		= (posX) ? posX : 0;
	y 		= (posY) ? posY : 0;
	width 	= $(id).getWidth();
	sWidth  = document.body.clientWidth;
	if(x + width > sWidth) {
		x = x - width;
	}
    PosElement(id, x, y);
}

function HideElement(id){
   document.getElementById(id).style.display = "none";
}

function WriteToElement(id,inhalt){
  document.getElementById(id).firstChild.nodeValue=inhalt;
}

function PosElement(id, x, y) {
	if(id && x) {
		document.getElementById(id).style.left = x + 'px';;
	}
	if(id && y) {
		document.getElementById(id).style.top = y + 'px';;
	}
}

/**
* Ajax functions, requires Prototype
*/
function reportError(e) {}
function Helpbox(module, key, options)
{ 
  var url = '/micro/help_' + module + '/' + key; 
  var params = null;
  
  PosToMouseElement('helpbox');
  new Ajax.Updater( {success: 'helpbox'}, url, { method: 'get', parameters: params });
  /*new Draggable('helpbox', {} );*/
  
  $('helpbox').setStyle({
  	width:	(options.width) ? options.width : 300 + 'px'
  });
  
  
  ShowElement('helpbox');
}

function showIFrame(url)
{
	var left = (document.body.clientWidth - parseInt($('iframewindow').getStyle('width'))) / 2;
	
	$('iframe').src = url;
	
	$('overlay_background').setStyle({
		display: 'block'
	});
	
	$('iframewindow').setStyle({
		left: left + 'px',
		top: '74px',
		display: 'block'
	});
}

function hideIFrame()
{
	if(hideIFrame.arguments[0] != true) {
		$('overlay_background').setStyle({
			display: 'none'
		});
	}
	
	$('iframe').setStyle({
		display: 'none'
	});
	
	$('iframewindow').setStyle({
		display: 'none'
	});
	
	$('iframemessage').setStyle({
		display: 'block'
	});
}

function onloadIFrame()
{
	if(document.getElementById('iframe')) {
		$('iframe').setStyle({
			display: 'block'
		});
		
		$('iframemessage').setStyle({
			display: 'none'
		});
	}
}

function jump(url)
{
	document.location.href = url + document.location.search;
}
