function popup_planung(ziel_id,secure_id)
{
	 var breite=800;
	 var hoehe=400;
	 var positionX=((screen.availWidth / 2) - breite / 2);
	 var positionY=((screen.availHeight / 2) - hoehe / 2);
	 var url='war_'+ziel_id+'_'+secure_id+'.html';
	 pop=window.open('',url,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,fullscreen=0,width='+breite+',height='+hoehe+',top=10000,left=10000');
	 pop.resizeTo(breite,hoehe);
	 pop.moveTo(positionX,positionY);
	 pop.location=url;
}

function select_status(angriff_id)
{
	return "<iframe src=\'about:blank\' id=\'select\' name=\'select\' height=\'0\' width=\'0\' frameborder=\'0\'></iframe><form name=\'select_form\' id=\'select_form\' method=\'post\' action=\'travian/war_select.php\' target=\'select\'><input name=\'status\' id=\'status\' type=\'hidden\' /><input name=\'angriff_id\' type=\'hidden\' value=\'"+angriff_id+"\' /><input type=\'image\' onClick=\'document.select_form.status.value=0;\' src=\'travian/img/status/fragezeichen.jpg\' /><input type=\'image\' onClick=\'document.select_form.status.value=1;\' src=\'travian/img/status/ok.gif\' /><input type=\'image\' onClick=\'document.select_form.status.value=2;\' src=\'travian/img/status/close.gif\' /></form>";
}

function datumuhr()
{
	var jahr;
	var monat;
	var tag;
	var stunden;
	var minuten;
	var sekunden;
	var AktuellesDatum=new Date();

	jahr=AktuellesDatum.getFullYear ();
	monat=AktuellesDatum.getMonth ()+1;
	tag=AktuellesDatum.getDate ();
	stunden=AktuellesDatum.getHours ();
	minuten=AktuellesDatum.getMinutes ();
	sekunden=AktuellesDatum.getSeconds ();

	if (stunden<10) stunden="0"+String(stunden);
	if (minuten<10) minuten="0"+String(minuten);
	if (sekunden<10) sekunden="0"+String(sekunden);
	if (tag<10) tag="0"+String(tag);
	if (monat<10) monat="0"+String(monat);

	var uhrzeit = tag+"."+monat+"."+jahr+" "+stunden+":"+minuten+":"+sekunden;

	document.getElementById("uhrzeit").innerHTML = uhrzeit;
	window.setTimeout ('datumuhr()',1000);
}

function select_box_select_all(select_id) {
	var s = document.getElementById(select_id);
	for(var i=0; i < s.options.length; i++) {
		s.options[i].selected = true;
	}
}

function select_box_remove_element(select_id) {
	var s = document.getElementById(select_id);
	var last_pos = -1;
	for(var i=s.options.length-1; i >= 0; i--) {
		if(s.options[i].selected == true) {
			s.options[i] = null;
			last_pos = i;
		}
	}
	if(s.options.length == 0 || last_pos == -1) return true;
	while(s.options[last_pos] == undefined) {
		last_pos--;
		if(last_pos == -1) return true;
	}
	s.options[last_pos].selected = true;
}

function select_box_add_element(select_id, input_id) {
	var e = document.getElementById(input_id);
	e.value = e.value.replace(/^\s+/, '').replace(/\s+$/, '');
	if(e.value == '') return false;
	var new_element = document.createElement('option');
	var new_innerHTML = document.createTextNode(e.value);
	new_element.appendChild(new_innerHTML);
	new_element.setAttribute('value', e.value);
	document.getElementById(select_id).appendChild(new_element);
	e.value = '';
	e.focus();
}

function switch_show(div)
{
	element = document.getElementById(div);

	if(element.style.display=='none')	element.style.display='inline';
	else							 	element.style.display='none';
}

function setLyr(obj,lyr)
{
	var coors = findPos(obj);
	var x = document.getElementById(lyr);
	x.style.top = (coors[1]+25) + 'px';
	x.style.left = coors[0] + 'px';
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function findResolution() {
	var width,height;
	if (self.innerHeight) {
		width = self.innerWidth;
		height = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		width = document.documentElement.clientWidth;
		height = document.documentElement.clientHeight;
	} else if (document.body) {
		width = document.body.clientWidth;
		height = document.body.clientHeight;
	}
	return [width,height];
}

/* ganze Seite ausgrauen */
function ausgrauenStart() {
	ausgrauen = document.getElementById('ausgrauen');
	if(ausgrauen == null)
	{
		ausgrauen = document.createElement('div');
		ausgrauen.setAttribute('id', 'ausgrauen');
		ausgrauen.setAttribute('style', 'display: none; position:fixed; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%; background-color: #F1F1F1; filter:Alpha(opacity=85); -moz-opacity: 0.85; opacity: 0.85;');
		ausgrauen.style.zIndex = 99;
		document.getElementsByTagName('body')[0].appendChild(ausgrauen);
	}
	ausgrauen.style.display = 'block';
}

function ausgrauenEnde() {
	ausgrauen.style.display = 'none';
}

/* Funktion zum Onload-Event hinzufügen */
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

// http://www.mediaevent.de/javascript/event_listener.html
function addEvent( obj, type, fn) {
   if (obj.addEventListener) {
      obj.addEventListener( type, fn, false );
   } else if (obj.attachEvent) {
      obj["e"+type+fn] = fn;
      obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
      obj.attachEvent( "on"+type, obj[type+fn] );
   }
}

function removeEvent( obj, type, fn) {
   if (obj.removeEventListener) {
      obj.removeEventListener( type, fn, false );
   } else if (obj.detachEvent) {
      obj.detachEvent( "on"+type, obj[type+fn] );
      obj[type+fn] = null;
      obj["e"+type+fn] = null;
   }
}

// Bewertungen erstellen
function add_rating() {
	var myLinks = document.getElementsByTagName('a');
	for (i=0; i<myLinks.length; i++) {
		if(myLinks[i].className == 'rating') {

			myLinks[i].myActualRating = document.createElement('span');
			myLinks[i].myActualRating.style.width = myLinks[i].getAttribute('href').match(/(\d+)/)[0] * 12;
			myLinks[i].appendChild(myLinks[i].myActualRating);

			myLinks[i].myHiddenInput = document.createElement('input');
			myLinks[i].myHiddenInput.type = 'hidden';
			myLinks[i].myHiddenInput.value = '0';
			myLinks[i].myHiddenInput.name = myLinks[i].getAttribute('onclick');
			myLinks[i].appendChild(myLinks[i].myHiddenInput);

			myLinks[i].onmousemove = function (e) {
				this.myActualRating.style.backgroundImage='url(/travian/img/rating_over.gif)';
				obj = this;
				this.absXPos = obj.offsetLeft;
				while (obj.offsetParent) {
					obj = obj.offsetParent;
					this.absXPos += obj.offsetLeft;
				}
				var e = e || window.event;
				var relPos = e.clientX || e.pageX;
				this.myActualRating.style.width = Math.ceil((relPos - this.absXPos)/12)*12 + 'px';
			}
			myLinks[i].onmouseover = myLinks[i].onmousemove;
			myLinks[i].onmouseout = function () {
				this.myActualRating.style.width = this.getAttribute('href').match(/(\d+)/)[0] * 12 + 'px';
				this.myActualRating.style.backgroundImage='url(/travian/img/rating_on.gif)';
			}
			myLinks[i].onclick = function () {
				this.onmouseout = function () {
					this.myActualRating.style.width = this.myHiddenInput.value + '%';
				};
				this.myHiddenInput.value = Math.round(this.myActualRating.offsetWidth*100/this.offsetWidth);
				e = this;
				while(e = e.parentNode) {
					if(e.tagName == 'FORM') { e.submit(); break; }
				}
				return false;
			}
		}
	}
}

/* Fügt einen Paramter an alle Formulare und Links mit bestimmten Elementen */
function addParameter(_Name, _Value, _Parameter) {
	addParameterToLinks(_Name, _Value, _Parameter);
	addParameterToForms(_Name, _Value, _Parameter);
}

function addParameterToLinks(_Name, _Value, _Parameter) {
	for(i=0; ;i++) {
		l = document.links[i];
		if(l == undefined) break;
		if(_Parameter != "" && l.href.indexOf("?"+_Parameter+"=") == -1 && l.href.indexOf("&"+_Parameter+"=") == -1) continue;	// nur wenn es ein Element mit dem Namen "_Parameter" gibt
		if(l.href.indexOf("&"+_Name+"=") > 0) continue;	// überspringen, falls bereits ein Parameter mit dem Namen existiert
		key = "&"+_Name+"="+_Value;
		pos = l.href.indexOf("#");
		if(pos != -1) l.href = l.href.substring(0, pos) + key + l.href.substring(pos, l.href.length)
		else l.href += key;
	}
}

function addParameterToForms(_Name, _Value, _Parameter) {
	for(i=0; ;i++) {
		f = document.forms[i];
		if(f == undefined) break;
		if(_Parameter != "" && eval('f.'+_Parameter) == undefined) continue;	// nur wenn es ein Element mit dem Namen "_secureKeyParameter" gibt
		if(eval('f.'+_Name) != undefined) continue;	// überspringen, falls bereits ein Element mit dem Namen existiert
		e = document.createElement("input");
		e.setAttribute("type", "hidden");
		e.setAttribute("name", _Name);
		e.setAttribute("value", _Value);
		f.appendChild(e);
	}
}

/* Schnee */

///////////////////////////////////////////////////////////////////////////
// CONFIGURATION STARTS HERE
///////////////////////////////////////////////////////////////////////////

// Set the number of snowflakes (more than 30 - 40 not recommended)
var snowmax = 25;
// Set the colors for the snow. Add as many colors as you like
var snowcolor = new Array('#eeeeff', '#ffffdd', '#eeeedd', '#ffffff');
// Set the fonts, that create the snowflakes. Add as many fonts as you like
var snowtype = new Array('Arial Black', 'Arial Narrow', 'Times', 'Comic Sans MS');
var snowletter = '*';
// Set the speed of sinking (recommended values range from 0.3 to 2)
var sinkspeed = 0.3;
var snowmaxsize = 48;
var snowminsize = 10;
// Set the snowing-zone
var snowposleft = 345;
var snowposright = snowposleft+550;
var snowpostop = 270;
var snowposbottom = snowpostop+296;

///////////////////////////////////////////////////////////////////////////
// CONFIGURATION ENDS HERE
///////////////////////////////////////////////////////////////////////////

var snow = new Array();

function randommaker(range) {
	return Math.floor(range * Math.random());
}

function initsnow() {
	var snowsizerange = snowmaxsize - snowminsize;

	for (var i = 0; i <= snowmax; i++) {
		snow[i] = document.createElement("span");
		snow[i].id ="s" + i;
		snow[i].innerHTML = snowletter;
		snow[i].style.fontFamily = snowtype[randommaker(snowtype.length)];
		snow[i].size = randommaker(snowsizerange) + snowminsize;
		snow[i].style.fontSize = snow[i].size;
		snow[i].style.color = snowcolor[randommaker(snowcolor.length)];
		snow[i].crds = 0;
		snow[i].lftrght = Math.random() * 15;
		snow[i].speedy = sinkspeed * snow[i].size / 5;
		snow[i].speedx = 0.03 + Math.random() / 10;
		snow[i].posx = randommaker(snowposright - snowposleft) + snowposleft;
		snow[i].posy = randommaker(snowposbottom - snowpostop) + snowpostop;
		snow[i].style.left = snow[i].posx;
		snow[i].style.top = snow[i].posy;
		snow[i].style.position = 'absolute';
		document.getElementsByTagName('body')[0].appendChild(snow[i]);
	}
	movesnow();
}

function movesnow() {
	for (var i = 0; i <= snowmax; i++) {
		snow[i].crds += snow[i].speedx;
		snow[i].posy += snow[i].speedy;
		snow[i].style.left = snow[i].posx + snow[i].lftrght * Math.sin(snow[i].crds);
		snow[i].style.top = snow[i].posy;
		if (snow[i].posy >= snowposbottom) {
			snow[i].posx = randommaker(snowposright - snowposleft) + snowposleft;
			snow[i].posy = snowpostop;
		}
	}
	setTimeout('movesnow();', 50); //Wert von 10 bis 100
}