function wechsel(bildname,bildsrc){
	if (document.images) {
	bildquelle=eval('document.images.' + bildname);
	bildquelle.src = bildsrc;
	}
}

function sync(zeit,gold,gold_eink,eisen2,eisen_eink2,eisen,eisen_eink,stein2,stein_eink2,stein,stein_eink,holz2,holz_eink2,holz,holz_eink,pferde,pferde_eink,essen2,essen_eink2,essen3,essen_eink3,essen,essen_eink,kohle,kohle_eink,waffen,waffen_eink,rang,runde,punkte,ehre,titel,username){
	if(parent.goben){
			if(parent.goben.nexttick){
				parent.goben.nexttick = zeit;
				parent.goben.update(gold,gold_eink,eisen2,eisen_eink2,eisen,eisen_eink,stein2,stein_eink2,stein,stein_eink,holz2,holz_eink2,holz,holz_eink,pferde,pferde_eink,essen2,essen_eink2,essen3,essen_eink3,essen,essen_eink,kohle,kohle_eink,waffen,waffen_eink,rang,runde,punkte,ehre,titel,username);
			}
	}
	var ie = (document.all) ? true : false;	
	if(!ie){
		var wert = "fixed";
	}else{
		var wert = "absolute";
	}
	if(document.getElementById('linkerrand')) document.getElementById('linkerrand').style.position = wert;
	if(document.getElementById('rechterrand')) document.getElementById('rechterrand').style.position = wert;
	object = null;
	draganddrop(); // Initialisiert das verschiebbare div für das Tutorial
}
function frame(){
	var ie = (document.all) ? true : false;	
	if(!ie){
		var wert = "fixed";
	}else{
		var wert = "absolute";
	}
	if(document.getElementById('linkerrand')) document.getElementById('linkerrand').style.position = wert;
	if(document.getElementById('rechterrand')) document.getElementById('rechterrand').style.position = wert;
}
function screen(){
	var ie = (document.all) ? true : false;
	if(!ie){
		document.forms['demo'].screen.value = 1;
	}else{
		document.forms['demo'].screen.value = 0;
	}
}
function Nachrichten(i){
	if(i==1){
		c = "#ff0000";
	}else{
		c = "#3C3115";
	}
	if(parent.links){
		if(parent.links.document.getElementById("NR")){
			parent.links.document.getElementById("NR").style.color = c;
			parent.links.document.Nachrichtenlink = c;
		}
	}
}

function Forum(i){
	if(i==1){
		c = "#ff0000";
	}else{
		c = "#3C3115";
	}
	if(parent.links){
		if(parent.links.document.getElementById("FR")){
			parent.links.document.getElementById("FR").style.color = c;
			parent.links.document.Forumlink = c;
		}
	}
}

function Schnellstart(i){
	if(i==1){
		c = "#ff0000";
	}else{
		c = "#3C3115";
	}
	if(parent.links){
		if(parent.links.document.getElementById("SR")){
			parent.links.document.getElementById("SR").style.color = c;
			parent.links.document.Schnellstartlink = c;
		}
	}
}

function Bonus(i){
	if(i==1){
		c = "#ff0000";
	}else{
		c = "#3C3115";
	}
	if(parent.links){
		if(parent.links.document.getElementById("BR")){
			parent.links.document.getElementById("BR").style.color = c;
			parent.links.document.Bonuslink = c;
		}
	}
}

var himmelsrichtung = new Array();

himmelsrichtung[0] = new Array();
himmelsrichtung[0]['N'] = "N";
himmelsrichtung[0]['S'] = "S";
himmelsrichtung[0]['W'] = "W";
himmelsrichtung[0]['O'] = "O";
himmelsrichtung[0]['NO'] = "NO";
himmelsrichtung[0]['SO'] = "SO";
himmelsrichtung[0]['NW'] = "NW";
himmelsrichtung[0]['SW'] = "SW";
himmelsrichtung[0]['-'] = "-";

himmelsrichtung[1] = new Array();
himmelsrichtung[1]['N'] = "N";
himmelsrichtung[1]['S'] = "S";
himmelsrichtung[1]['W'] = "W";
himmelsrichtung[1]['O'] = "E";
himmelsrichtung[1]['NO'] = "NE";
himmelsrichtung[1]['SO'] = "SE";
himmelsrichtung[1]['NW'] = "NW";
himmelsrichtung[1]['SW'] = "SW";
himmelsrichtung[1]['-'] = "-";

if(document.getElementById) {
    window.confirm = function(form,txt,title,heroe) {
        createCustomAlert(form,txt,title,heroe);
    }
}

var ie = (document.all) ? true : false;	
var tt = 0;

function createCustomAlert(form,txt,strTitle,heroe) {
    // constants to define the title of the alert and button text.
    var ALERT_TITLE = strTitle;
    var ALERT_BUTTON_TEXT = "Ok";
    var ALERT_BUTTON_TEXT2 = "Cancel";

    // shortcut reference to the document object
    d = document;

    // if the modalContainer object already exists in the DOM, bail out.
    if(d.getElementById("modalContainer")) return;

    // create the modalContainer div as a child of the BODY element
    mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
    mObj.id = "modalContainer";
     // make sure its as tall as it needs to be to overlay all the content on the page
    mObj.style.height = document.documentElement.scrollHeight + "px";

    // create the DIV that will be the alert 
    alertObj = mObj.appendChild(d.createElement("div"));
	if(heroe == 3){
		alertObj.id = "alertBox_large";
	}else{
	    alertObj.id = "alertBox";
    }
	// MSIE doesnt treat position:fixed correctly, so this compensates for positioning the alert
	var scrollPos;
	if (typeof window.pageYOffset != 'undefined') {
	   scrollPos = window.pageYOffset;
	}
	else if (typeof document.compatMode != 'undefined' &&
		 document.compatMode != 'BackCompat') {
	   scrollPos = document.documentElement.scrollTop;
	}
	else if (typeof document.body != 'undefined') {
	   scrollPos = document.body.scrollTop;
	}   
	if(d.all && !window.opera) alertObj.style.top = scrollPos + "px";
    // center the alert box
    alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 - 50 + "px";

    // create an H1 element as the title bar
    h1 = alertObj.appendChild(d.createElement("h1"));
    h1.id = "h1Alert";
    h1.appendChild(d.createTextNode(ALERT_TITLE));

    // create a paragraph element to contain the txt argument
    msg = alertObj.appendChild(d.createElement("p"));
    msg.innerHTML = txt;
	if(heroe != 2){
		// create an anchor element to use as the confirmation button. - OK
		btn = alertObj.appendChild(d.createElement("a"));
		btn.id = "okBtn";
		btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
		btn.href = "#";
		// create an anchor element to use as the confirmation button. - Cancel
		btn2 = alertObj.appendChild(d.createElement("a"));
		btn2.id = "closeBtn";
		btn2.appendChild(d.createTextNode(ALERT_BUTTON_TEXT2));
		btn2.href = "#";
		btn2.onclick = function() { removeCustomAlert();return false; }
		if(heroe==1){
			btn.onclick = function() { removeCustomAlert();opener.location.href=form; window.close(); return true;}
		}else if(typeof(form)=='string'){
			btn.onclick = function() { removeCustomAlert();d.location.href=form; return true;}
		}else{
			btn.onclick = function() { removeCustomAlert();form.submit(); return true;}
		}
	}else{
		// create an anchor element to use as the confirmation button. - OK
		btn3 = alertObj.appendChild(d.createElement("a"));
		btn3.id = "closeBtn2";
		btn3.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
		btn3.href = "#";
		btn3.onclick = function() { removeCustomAlert();return false; }
	}
}

// removes the custom alert from the DOM
function removeCustomAlert() {
    document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}  

function draganddrop() {
   document.onmousemove = drag;
   document.onmouseup = drop;
}

function moveable(obj) {
   object = obj;
   object_x = mouse_x - object.offsetLeft;
   object_y = mouse_y - object.offsetTop;
}

function drop() {
   object = null;
}

function drag(evt) {
   x1 = (ie) ? event.clientX + document.body.scrollLeft : evt.pageX;	
   y1 = (ie) ? event.clientY + document.body.scrollTop : evt.pageY;
   mouse_x = x1;
   mouse_y = y1;
   if(object != null) {
	   tutorial_x = mouse_x - object_x;
	   tutorial_y = mouse_y - object_y;
	   if(tutorial_x<-40) tutorial_x = -40;
	   if(tutorial_y<-20) tutorial_y = -20;
	   object.style.left = tutorial_x + "px";
	   object.style.top = tutorial_y + "px";
   }
	if(tt == true){
		if((ttx-x1 > 30) || (ttx-x1 < -30-ttbreite) || (tty-y1 < -30-tthoehe) || (tty-y1 > 30)){
			fadeout();
		}
	}
}

function detect_java(){
	// variable to check if Java Web Start is installed
	var jwsInstalled = 0;

	// Microsoft VM?
	var msvmInstalled = 0;

	// Sun VM?
	var sunvmInstalled = 0;


	// variable to check if client is MSIE
	isIE = "false";

	// If we are using 
	if(navigator.mimeTypes && navigator.mimeTypes.length)
	{
	  var flag = navigator.mimeTypes['application/x-java-jnlp-file'];

	  if(flag)
	  {
		jwsInstalled = 1;
	  }
	}
	else
	{
	  isIE = "true";
	}

	// We are using another browser, not MSIE
	// Opera, Mozilla, Firefox, etc...
	if(isIE == "false")
	{
		javaEnabled = window.navigator.javaEnabled();
		alert( javaEnabled );
	  if(javaEnabled)
	  {
		javaVendor = java.lang.System.getProperty("java.vendor");
		alert( javaVendor );
		if(javaVendor.indexOf("Sun ") != -1 || javaVendor.IndexOf("sun ") != -1)
		{
		  sunvmInstalled = 1;
		}
	  }
	}
	// Our client is using MSIE
	else
	{
	  // check if ActiveX objects can be created
	  try
	  {
		// Create Sun Java plugin ActiveX object
		var pluginObject = new ActiveXObject("JavaPlugin");
		// Create Java Web Start ActiveX object
		var jwsObject = new ActiveXObject("JavaWebStart.isInstalled");
	  }
	  // they cannot be created
	  catch(e)
	  {
		// Sun Java plugin and Java Web Start not installed
		sunvmInstalled = 0;
		jwsInstalled = 0;
	  }

	  // Sun Java VM object successfully created?
	  if(pluginObject)
	  {
		// Yep! We have the Sun Java VM plugin installed
		sunvmInstalled = 1;
	  }

	  // Java Web Start object successfully created?
	  if(jwsObject)
	  {
		// Yep! We have Java Web Start installed
		jwsInstalled = 1;
	  }

	  // Minimal Code Hack
	  // All versions of Windows up to 2000 have Microsoft VM installed by default
	  // No official Microsoft VM is distributed for Windows XP and above
	  // Users of Windows XP and above will be required to install the Sun Virtual Machine
	  var UserAgent = navigator.userAgent;

	  if(UserAgent.indexOf("Windows 95") != -1 || UserAgent.indexOf("Windows 98") != -1 || UserAgent.indexOf("Windows NT 5.0") != -1)
	  {
		msvmInstalled = 1;
	  }
	}
}


