var userw = 0;
var userh = 0;

if (self.innerHeight) {
	userw = self.innerWidth;
	userh = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) {
	userw = document.documentElement.clientWidth;
	userh = document.documentElement.clientHeight;
} else if (document.body) {
	userw = document.body.clientWidth;
	userh = document.body.clientHeight;
}

function jsWorking()
{
  document.getElementById('loader').style.display = 'block';
	document.getElementById('loader').style.width = userw+'px';
	document.getElementById('loader').style.height = '2000px';
	document.getElementById('loader').style.top = document.body.scrollTop;
	document.getElementById('loader').style.left = "0px";
	document.getElementById('loader').style.paddingTop = (userh/2);
}

function jsLoader()
{
  document.getElementById('ajax_loader').style.opacity = (1);
	document.getElementById('ajax_loader').style.MozOpacity = (1);
	document.getElementById('ajax_loader').style.KhtmlOpacity = (1);
	document.getElementById('ajax_loader').style.filter = 'alpha(opacity=100)';
	document.getElementById('ajax_loader').style.display = 'block';
	document.getElementById('ajax_loader').style.top = document.body.scrollTop+((window.screen.availHeight/2)-250);
	//document.getElementById('loader').style.left = 300;
	//document.getElementById('loader').style.top = ((window.screen.availHeight/2)) ;
	document.getElementById('ajax_loader').style.left = ((window.screen.availWidth/2)-180) ;
	document.getElementById('ajaxtext').innerHTML = 'Lädt...';
}
//#############################################################

function jsBG()
{
  document.getElementById("blank").style.display = 'block';
  document.getElementById("blank").style.width = '100%';
  document.getElementById("blank").style.height = '3000px'
	document.getElementById('blank').style.opacity = 0.5;
	document.getElementById('blank').style.MozOpacity = 0.5;
	document.getElementById('blank').style.KhtmlOpacity = 0.5;
	document.getElementById('blank').style.filter = 'alpha(opacity=50)';
  document.getElementById('blank').style.top = document.body.scrollTop;
  document.getElementsByTagName('body')[0].style.overflow = 'hidden';
}

function jsBGOff()
{
	document.getElementById("blank").style.display = 'none';
	document.getElementsByTagName('body')[0].style.overflow = 'auto';
}
//#############################################################

//################## Ajaxtest&Rdm für IE ######################
function jsTest()
{
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
    alert ("Sorry dein Browser unterstützt kein AJAX. Du kannst die Menge auf 0 setzen, dann werden die Artikel auch gelöscht!");
    return;
  }
  vRdm = 1 + 120486*(Math.random());
  vRdm = Math.round(vRdm);
}
//#############################################################


function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
  {
  // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
  // Internet Explorer
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttp;
}


function jsHideAjaxLoader(wert)
{
	wert = wert - 3;
	document.getElementById('ajax_loader').style.opacity = (wert / 100);
	document.getElementById('ajax_loader').style.MozOpacity = (wert / 100);
	document.getElementById('ajax_loader').style.KhtmlOpacity = (wert / 100);
	document.getElementById('ajax_loader').style.filter = 'alpha(opacity=' + wert + ')';
	if (wert > 0)
	{
		setTimeout(function () { jsHideAjaxLoader(wert) }, 1);
	}
	else
	{
		document.getElementById('ajax_loader').style.display = 'none';
	}
}


navHover = function() {
	var lis = document.getElementById("navmenu").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);





function jsTestPopup(vEle)
{
	if (self.innerHeight) {
  	userw = self.innerWidth;
  	userh = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
  	userw = document.documentElement.clientWidth;
  	userh = document.documentElement.clientHeight;
	} else if (document.body) {
  	userw = document.body.clientWidth;
  	userh = document.body.clientHeight;
	}
	
	SaveHeight = window.screen.availHeight-350;
  if (window.screen.availHeight < (document.getElementById('loginloader').offsetHeight+300))
	{
	  document.getElementById(vEle).style.overflowY = 'scroll';
	  document.getElementById(vEle).style.overflowX = 'hidden';
    document.getElementById(vEle).style.height = SaveHeight+'px';
  	document.getElementById('loginloader').style.top = document.body.scrollTop+((userh/2)-(document.getElementById('loginloader').offsetHeight/2));
  	document.getElementById('loginloader').style.left = (userw/2)-295;
  	document.getElementById('loginbg').style.top = document.body.scrollTop+((userh/2)-((document.getElementById('loginloader').offsetHeight+10)/2));
  	document.getElementById('loginbg').style.left = (userw/2)-300;
  	document.getElementById('loginbg').style.width = (document.getElementById('loginloader').offsetWidth+10)+'px';
  	document.getElementById('loginbg').style.height = (document.getElementById('loginloader').offsetHeight+10)+'px';
  }
  else
  {
  	document.getElementById('loginloader').style.top = document.body.scrollTop+((userh/2)-(document.getElementById('loginloader').offsetHeight/2));
  	document.getElementById('loginloader').style.left = (userw/2)-295;
  	document.getElementById('loginbg').style.top = document.body.scrollTop+((userh/2)-((document.getElementById('loginloader').offsetHeight+10)/2));
  	document.getElementById('loginbg').style.left = (userw/2)-300;
  	document.getElementById('loginbg').style.width = (document.getElementById('loginloader').offsetWidth+10)+'px';
  	document.getElementById('loginbg').style.height = (document.getElementById('loginloader').offsetHeight+10)+'px';
  }
}

function jsTestPopup2(vEle,vEle2,vEle3)
{
	if (self.innerHeight) {
  	userw = self.innerWidth;
  	userh = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
  	userw = document.documentElement.clientWidth;
  	userh = document.documentElement.clientHeight;
	} else if (document.body) {
  	userw = document.body.clientWidth;
  	userh = document.body.clientHeight;
	}
	
	SaveHeight = window.screen.availHeight-350;
  if (window.screen.availHeight < (document.getElementById(vEle2).offsetHeight+300))
	{
	  document.getElementById(vEle).style.overflowY = 'scroll';
	  document.getElementById(vEle).style.overflowX = 'hidden';
    document.getElementById(vEle).style.height = SaveHeight+'px';
  	document.getElementById(vEle2).style.top = document.body.scrollTop+((userh/2)-(document.getElementById(vEle2).offsetHeight/2));
  	if (vEle3 != "")
  	{
    	document.getElementById(vEle3).style.top = document.body.scrollTop+((userh/2)-((document.getElementById(vEle2).offsetHeight+10)/2));
    	document.getElementById(vEle3).style.width = (document.getElementById(vEle2).offsetWidth+10)+'px';
    	document.getElementById(vEle3).style.height = (document.getElementById(vEle2).offsetHeight+10)+'px';
  	}
  }
  else
  {
  	document.getElementById(vEle2).style.top = document.body.scrollTop+((userh/2)-(document.getElementById(vEle2).offsetHeight/2));
  	if (vEle3 != "")
  	{
    	document.getElementById(vEle3).style.top = document.body.scrollTop+((userh/2)-((document.getElementById(vEle2).offsetHeight+10)/2));
    	document.getElementById(vEle3).style.width = (document.getElementById(vEle2).offsetWidth+10)+'px';
    	document.getElementById(vEle3).style.height = (document.getElementById(vEle2).offsetHeight+10)+'px';
  	}
  }
}

//################## URL DE-ENcode ######################

	var URLcode = {
 
	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},
 
	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
	
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}