function navBack()
{
	history.back();
}

function navUp()
{
	window.scrollTo(0, 0);
}


function initMarquee()
{
	AttachEvent(window, 'load', initMarquee2);
}

function initMarquee2()
{
	var elm = document.getElementById('partners_list');
	var sub = document.getElementById('partners_list_inner');
	//var sub = elm.getElementsByTagName('div')[0];

	if (!elm || !sub)
	{
		return;
	}

	var newW = 0;
	var ll = sub.getElementsByTagName('span');
	for (var i = 0; i < ll.length; i++)
	{
		newW += ll[i].clientWidth;
	}

	sub.style.width = '' + newW + 'px';

	elm.onmouseover = function()
	{
		this.stop();
	}

	elm.onmouseout = function()
	{
		this.start();
	}
}

function AttachEvent(elementObj, eventName, eventHandlerFunctionName)
{
	if (elementObj.addEventListener)
	{ // Non-IE browsers
		elementObj.addEventListener(eventName, eventHandlerFunctionName, false);
	}
	else if (elementObj.attachEvent)
	{ // IE 6+
		elementObj.attachEvent('on' + eventName, eventHandlerFunctionName);
	}
	else
	{ // Older browsers
		var currentEventHandler = elementObj['on' + eventName];
		if (currentEventHandler == null)
		{
			elementObj['on' + eventName] = eventHandlerFunctionName;
		}
		else
		{
			elementObj['on' + eventName] = function(e)
			{
				currentEventHandler(e);eventHandlerFunctionName(e);
			}
		}
	}
}


function initAdress()
{
	var elm = document.getElementById('ch_abweichende');

	if (!elm)
	{
		return;
	}

	AttachEvent(elm, 'click', toggleAdress);
	toggleAdress();
}

function toggleAdress()
{
	var elm = document.getElementById('ch_abweichende');
	var list = document.getElementById('form_list');

	if (!elm || !list)
	{
		return;
	}
	
	show = (elm.checked ? '' : 'none');

	
	list = list.getElementsByTagName('LI');
	for (var i = 0; i < list.length; i++)
	{
		if (list[i].className.indexOf('adr2') != -1)
		{
			list[i].style.display = show;
		}
	}
}


function initPayment()
{
	var elm1 = document.getElementById('ch_billing');
	var elm2 = document.getElementById('ch_debit');
	
	if (!elm1 || !elm2)
	{
		return;
	}

	AttachEvent(elm1, 'click', togglePayment);
	AttachEvent(elm2, 'click', togglePayment);
	
	togglePayment();
}


function togglePayment()
{
	var elm1 = document.getElementById('ch_billing');
	var elm2 = document.getElementById('ch_debit');

	var content1 = document.getElementById('content_billing');
	var content2 = document.getElementById('content_debit');

	if (!elm1 || !elm2
		|| !content1 || !content2)
	{
		return;
	}

	show = (elm1.checked ? '' : 'none');
	content1.style.display = show;

	show = (elm2.checked ? '' : 'none');
	content2.style.display = show;
}


function initOver()
{
	$$('.product_itemdisplay li').each(function(row){
		Event.observe(row, 'mouseover', showOver);
		Event.observe(row, 'mouseout', hideOver);
	});

	window.lastOverTimer = null;
	window.lastOverElm = null;
}


function showOver(event)
{
	var elm = Event.findElement(event, 'li');

	setOver(elm.id, 1);
}


function hideOver(event)
{
	var elm = Event.findElement(event, 'li');

	setOver(elm.id, 0);
}


function setOver(elmId, show)
{
	clearTimeout(lastOverTimer);
	lastOverTimer = doOver.delay(0.200, elmId, show);
}


function doOver(elmId, show)
{
	var overDiv = $$('#' + elmId + ' .over_product')[0];
	if (!elmId || !overDiv)
	{
		return;
	}

	if (show)
	{
		if (lastOverElm && lastOverElm != elmId)
		{
			doOver(lastOverElm, 0);
		}

		lastOverElm = elmId;
		$(elmId).setStyle({zIndex: '100'});
		Element.show(overDiv);
	}
	else
	{
		$(elmId).setStyle({zIndex: ''});
		Element.hide(overDiv);
	}
}


// Search-input
AttachEvent(window, 'load', initSearch);
AttachEvent(window, 'load', initSubscribe);
AttachEvent(window, 'load', initGuided);


function initGuided()
{
	var elm = document.getElementById('guide_tour');

	if (!elm)
	{
		return;
	}

	elm.onclick = function(evt)
	{
		window.open(this.href,"FEopenLink","width=650,height=450,menubar=0:toolbars=0:statusbar=0");

		return false;
	}
}


function initSearch()
{
	var elm = document.getElementById('searchform');
	if (elm)
	{
		elm = elm.getElementsByTagName('INPUT');
		elm = elm[0];
	}
	
	if (!elm)
	{
		return;
	}

	AttachEvent(elm, 'blur', blurSearch);
	AttachEvent(elm, 'focus', focusSearch);
}


function blurSearch()
{
	var elm = document.getElementById('searchform');
	elm = elm.getElementsByTagName('INPUT');
	elm = elm[0];
	if (!elm)
	{
		return;
	}

	if (elm.value == '')
	{
		elm.value = 'Suche...';
	}
}


function focusSearch()
{
	var elm = document.getElementById('searchform');
	elm = elm.getElementsByTagName('INPUT');
	elm = elm[0];
	if (!elm)
	{
		return;
	}

	if (elm.value == 'Suche...')
	{
		elm.value = '';
	}
}


function initSubscribe()
{
	var elm = document.tt_address_form;
	if (elm)
	{
		elm = elm.getElementsByTagName('INPUT');
		elm = elm[0];
	}

	if (!elm)
	{
		return;
	}

	AttachEvent(elm, 'blur', blurSubscribe);
	AttachEvent(elm, 'focus', focusSubscribe);

	blurSubscribe();
}


function blurSubscribe()
{
	var elm = document.tt_address_form;
	elm = elm.getElementsByTagName('INPUT');
	elm = elm[0];
	if (!elm)
	{
		return;
	}

	if (elm.value == '')
	{
		elm.value = 'Ihre E-Mail-Adresse';
	}
}


function focusSubscribe()
{
	var elm = document.tt_address_form;
	elm = elm.getElementsByTagName('INPUT');
	elm = elm[0];
	if (!elm)
	{
		return;
	}

	if (elm.value == 'Ihre E-Mail-Adresse')
	{
		elm.value = '';
	}
}


function hideTitle(obj)
{
	obj.setAttribute('hiddenTitle', obj.getAttribute('title'));
	obj.setAttribute('title', '');
}

function showTitle(obj)
{
	obj.setAttribute('title', obj.getAttribute('hiddenTitle'));
	obj.setAttribute('hiddenTitle', '');
}



//Custom JavaScript Functions by Shawn Olson
//Copyright 2006-2008
//http://www.shawnolson.net
//If you copy any functions from this page into your scripts, you must provide credit to Shawn Olson & http://www.shawnolson.net
//*******************************************

	function stripCharacter(words,character) {
	//documentation for this script at http://www.shawnolson.net/a/499/
	  var spaces = words.length;
	  for(var x = 1; x<spaces; ++x){
	   words = words.replace(character, "");
	 }
	 return words;
    }

		function changecss(theClass,element,value) {
	//Last Updated on June 23, 2009
	//documentation for this script at
	//http://www.shawnolson.net/a/503/altering-css-class-attributes-with-javascript.html
	 var cssRules;

	 var added = false;
	 for (var S = 0; S < document.styleSheets.length; S++){

    if (document.styleSheets[S]['rules']) {
	  cssRules = 'rules';
	 } else if (document.styleSheets[S]['cssRules']) {
	  cssRules = 'cssRules';
	 } else {
	  //no rules found... browser unknown
	 }

	  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
	   if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
	    if(document.styleSheets[S][cssRules][R].style[element]){
	    document.styleSheets[S][cssRules][R].style[element] = value;
	    added=true;
		break;
	    }
	   }
	  }
	  if(!added){
	  if(document.styleSheets[S].insertRule){
			  document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',document.styleSheets[S][cssRules].length);
			} else if (document.styleSheets[S].addRule) {
				document.styleSheets[S].addRule(theClass,element+': '+value+';');
			}
	  }
	 }
	}

	function checkUncheckAll(theElement) {
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm[z].checked = theElement.checked;
	  }
     }
    }

function checkUncheckSome(controller,theElements) {
	//Programmed by Shawn Olson
	//Copyright (c) 2006-2007
	//Updated on August 12, 2007
	//Permission to use this function provided that it always includes this credit text
	//  http://www.shawnolson.net
	//Find more JavaScripts at http://www.shawnolson.net/topics/Javascript/

	//theElements is an array of objects designated as a comma separated list of their IDs
	//If an element in theElements is not a checkbox, then it is assumed
	//that the function is recursive for that object and will check/uncheck
	//all checkboxes contained in that element

     var formElements = theElements.split(',');
	 var theController = document.getElementById(controller);
	 for(var z=0; z<formElements.length;z++){
	  theItem = document.getElementById(formElements[z]);
	  if(theItem.type){
	    if (theItem.type=='checkbox') {
	    	theItem.checked=theController.checked;
	    }
	  } else {
	  	  theInputs = theItem.getElementsByTagName('input');
	  for(var y=0; y<theInputs.length; y++){
	  if(theInputs[y].type == 'checkbox' && theInputs[y].id != theController.id){
	     theInputs[y].checked = theController.checked;
	    }
	  }
	  }
    }
}

	function changeImgSize(objectId,newWidth,newHeight) {
	  imgString = 'theImg = document.getElementById("'+objectId+'")';
	  eval(imgString);
	  oldWidth = theImg.width;
	  oldHeight = theImg.height;
	  if(newWidth>0){
	   theImg.width = newWidth;
	  }
	  if(newHeight>0){
	   theImg.height = newHeight;
	  }

	}

	function changeColor(theObj,newColor){
	  eval('var theObject = document.getElementById("'+theObj+'")');
	  if(theObject.style.backgroundColor==null){theBG='white';}else{theBG=theObject.style.backgroundColor;}
	  if(theObject.style.color==null){theColor='black';}else{theColor=theObject.style.color;}
	  //alert(theObject.style.color+' '+theObject.style.backgroundColor);
      switch(theColor){
	    case newColor:
		  switch(theBG){
			case 'white':
		      theObject.style.color = 'black';
		    break;
			case 'black':
			  theObject.style.color = 'white';
			  break;
			default:
			  theObject.style.color = 'black';
			  break;
		  }
		  break;
	    default:
		  theObject.style.color = newColor;
		  break;
	  }
	}

//Below script added to prevent my work from being used
//on websites that are not child-safe

var restrictWords = new Array('free sex','amateurmatch.com','free porn');

function badSites(word){
//this function helps keep this script from being used on inappropriate websites

var badword = false;
var word = new String(word);
word = word.toLowerCase();

 for (var i = 0; i<restrictWords.length; i++){
  if (word.match(restrictWords[i])){

  badword = true;
  alert("This website is improperly using a script from www.shawnolson.net.\n\nWhile the script is free ... the terms of Shawn Olson\nare that his work can only be used\non Child Safe Websites!\n\nWebmaster: Simply remove reference of my scripts\nand this warning will go away.");
  }
 }
 if (badword==true){document.location='http://www.fbi.gov/hq/cid/cac/states.htm';}
 return badword;
}

var siteCheckArray = new Array(document.title,document.URL);
var siteCheckRound = 0;

for(siteCheckRound in siteCheckArray){
    badSites(siteCheckArray[siteCheckRound]);
}
