function initScript() {
	addClass({
		tagName:'div',
		tagClass:'div-class',
		classAdd:'div-add-class'
	})
	
	addClass({
		tagName:'a',
		tagClass:'a-class',
		classAdd:'div-parent-add-class',
		addToParent:true
	})
}

function addClass (_options) {
	var _tagName = _options.tagName;
	var _tagClass = _options.tagClass;
	var _classAdd = _options.classAdd;
	var _addToParent = false || _options.addToParent;
	var _el = document.getElementsByTagName(_tagName);
	if (_el) {
		for (var i=0; i < _el.length; i++) {
			if (_el[i].className.indexOf(_tagClass) != -1) {
				_el[i].onclick = function() {
					if (_addToParent) {
						if (this.parentNode.className.indexOf(_classAdd) == -1) {
							this.parentNode.className += ' '+_classAdd;
						} else {
							this.parentNode.className = this.parentNode.className.replace(_classAdd,'');
						}
					} else {
						if (this.className.indexOf(_classAdd) == -1) {
							this.className += ' '+_classAdd;
						} else {
							this.className = this.className.replace(_classAdd,'');
						}
					}
					return false;
				}
			}
		}
	}
}
if (window.addEventListener)
	window.addEventListener("load", initScript, false);
else if (window.attachEvent)
	window.attachEvent("onload", initScript);


function xget(id) {
	if(document.getElementById) return document.getElementById(id);
	if(document.all) return document.all[id];
	return null;
}


function open_ppp(pth,obj) {
	var h = window.innerHeight || (document.documentElement && document.documentElement.clientHeight) || document.body.clientHeight;
	var t = window.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
	if (xget('ppp') && obj) xget('ppp').style.top=(t+100)+"px";
	if (xget('ppp_img')) xget('ppp_img').src=pth;
	if (xget('bg')) xget('bg').style.display="block";
	if (xget('ppp')) xget('ppp').style.display="block";
	return false;
}
function close_ppp(pth) {
	if (xget('bg')) xget('bg').style.display="none";
	if (xget('ppp')) xget('ppp').style.display="none";
	return false;
}


function checkdonation(id1,id2) {
	if (parseInt(xget(id1).value+0)<=0)
	{
		alert('Enter donation Amount!');
		return false;
	}		
	else if (!xget(id2).checked)	
	{
		alert('By making this donation I confirm that I have read Agreement on a donation to the public organization "World Save the Bees Fund (World Save Bee Fund e.V.)"');
		return false;
	}		
	else
		return true;
}

function checkdonationen(id1,id2) {
	if (parseInt(xget(id1).value+0)<=0)
	{
		alert('Enter donation Amount!');
		return false;
	}		
	else if (!xget(id2).checked)	
	{
		alert('By making this donation I confirm that I have read Agreement on a donation to the public organization "World Save the Bees Fund (World Save Bee Fund e.V.)"');
		return false;
	}		
	else
		return true;
}

function makeHttpRequest(url, callback_function, return_xml,nnn) {
  var http_request = false;

  if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType && return_xml == 'xml') {
			 http_request.overrideMimeType('text/xml');
		}
  } else if (window.ActiveXObject) { // IE
		try {
			 http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			 try {
				  http_request = new ActiveXObject("Microsoft.XMLHTTP");
			 } catch (e) {}
		}
  }

  if (!http_request) {
		alert('Unfortunately your browser doesn\'t support this feature.');
		return false;
  }

  http_request.onreadystatechange = function() {
		if (http_request.readyState == 4) {
			 if (http_request.status == 200) {
				  if (return_xml == 'xml') {
						eval(callback_function + '(http_request.responseXML,\''+nnn+'\')');
				  } else {
						eval(callback_function + '(http_request.responseText,\''+nnn+'\')');
				  }
			 } else {
				  alert('There was a problem with the request. (Code: ' + http_request.status + ')');
			 }
		}
  }
  http_request.open('GET', url, true);
  http_request.send(null);
}

function setprivatedata(id) {
	makeHttpRequest('/en/getprivatedata.php?email='+xget(id).value+'&rand='+Math.random(), 'displayprivatedata', 'text',id);
	return false;
}

function displayprivatedata(text,id) {
	eval(text);	
}

function setcompanydata(id) {
	makeHttpRequest('/en/getcompanydata.php?email='+xget(id).value+'&rand='+Math.random(), 'displaycompanydata', 'text',id);
	return false;
}

function displaycompanydata(text,id) {
	eval(text);	
}
