function BrowserDetection(){
  this.appName = "unbekannt";
  this.appVersion = -1;
  this.isIE = this.isFF = this.isNetscape = this.isOpera = this.isSafari =  this.isIpad = false;
  this.UA = navigator.userAgent.toLowerCase();

  // IE
  if(this.UA.search(/msie/) != -1){
    this.appName = "IE";
    this.isIE = true;
    this.appVersion = parseFloat(/(msie[^;]*)/.exec(this.UA)[0].split(" ")[1]);
  // Opera
  }else if(this.UA.search(/opera/) != -1){
    this.appName = "Opera";
    this.isOpera = true;
    this.appVersion = parseFloat(/(opera[^\s]*)/.exec(this.UA)[0].split("/")[1]);
  // Firefox
  }else if(this.UA.search(/firefox/) != -1){
    this.appName = "Firefox";
    this.isFF = true;
    this.appVersion = parseFloat(/(firefox[^\s]*)/.exec(this.UA)[0].split("/")[1]);
	//IPad
	}else if(this.UA.search(/iPad/i) != -1){
    this.appName = "ipad";
    this.isIpad = true;
		this.appVersion = parseFloat(/(ipad[^\s]*)/.exec(this.UA)[0].split("/")[1]);
  //Iphone
	}else if(this.UA.search(/iPhone/i) != -1){
    this.appName = "ipad";
    this.isIpad = true;
		this.appVersion = parseFloat(/(iphone[^\s]*)/.exec(this.UA)[0].split("/")[1]);
	// Safari
  }else if(this.UA.search(/khtml/) != -1){
    this.appName = "Safari (Win)";
    this.isSafari = true;
    this.appVersion = parseFloat(/(version[^\s]*)/.exec(this.UA)[0].split("/")[1]);
  // Safari
  }else if(this.UA.search(/safari/) != -1){
    this.appName = "Safari";
    this.isSafari = true;
    this.appVersion = parseFloat(/(version[^\s]*)/.exec(this.UA)[0].split("/")[1]);
  // Netscape
  }else if(this.UA.search(/mozilla/) != -1){
    this.appName = "Mozilla";
    this.isNetscape = true;
    this.appVersion = parseFloat(/(mozilla[^\s]*)/.exec(this.UA)[0].split("/")[1]);
  // Netscape
  }else if(this.UA.search(/netscape/) != -1){
    this.appName = "Netscape";
    this.isNetscape = true;
    this.appVersion = parseFloat(/(netscape[^\s]*)/.exec(this.UA)[0].split("/")[1]);
	}
}

var objUA = new BrowserDetection();
if(objUA.appName == 'IE' && objUA.appVersion < 7){
	document.location.href = "oldbrowser.php";
}

// pseudo-class for IE start

function sfIEStart(type, tag, parentId) {
	if (window.attachEvent) {
		window.attachEvent("onload", function() {
			var sfEls = (parentId==null)?document.getElementsByTagName(tag):document.getElementById(parentId).getElementsByTagName(tag);
			type(sfEls);
		});
	}
}

sfHover = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

sfFocus = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onfocus=function() {
			this.className+=" sffocus";
		}
		sfEls[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
		}
	}
}

sfActive = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmousedown=function() {
			this.className+=" sfactive";
		}
		sfEls[i].onmouseup=function() {
			this.className=this.className.replace(new RegExp(" sfactive\\b"), "");
		}
	}
}

sfTarget = function(sfEls) {
	var aEls = document.getElementsByTagName("A");
	document.lastTarget = null;
	for (var i=0; i<sfEls.length; i++) {
		if (sfEls[i].id) {
			if (location.hash==("#" + sfEls[i].id)) {
				sfEls[i].className+=" sftarget";
				document.lastTarget=sfEls[i];
			}
			for (var j=0; j<aEls.length; j++) {
				if (aEls[j].hash==("#" + sfEls[i].id)) aEls[j].targetEl = sfEls[i];
				aEls[j].onclick = function() {
					if (document.lastTarget) docu.lastTarget.className = document.lastTarget.className.replace(new RegExp(" sftarget\\b"), "");
					if (this.targetEl) this.targetEl.className+=" sftarget";
					document.lastTarget=this.targetEl;
					return true;
				}
			}
		}
	}
}

sfIEStart(sfFocus, "INPUT");
sfIEStart(sfFocus, "TEXTAREA");
sfIEStart(sfFocus, "SELECT");
sfIEStart(sfActive, "SELECT");
sfIEStart(sfHover, "LI");


var isBlurLinks = false;
function BlurLinks(){
	isBlurLinks = true;
	lnks=document.getElementsByTagName('a');
	for(i=0;i<lnks.length;i++){lnks[i].onfocus=new Function("this.blur()");}
}

var viewportwidth;
var viewportheight;

function getViewportDim(){

 // kleiner IE6
 if (objUA.isIE == true && objUA.appVersion < 6){
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
       viewportheight = document.getElementsByTagName('body')[0].clientHeight;
			 footerMove();
 }
// IE6
else if (objUA.isIE == true && objUA.appVersion == 6){
       viewportwidth = document.documentElement.clientWidth;
       viewportheight = document.documentElement.clientHeight;
			 footerMove();
 }
 // ipad/iphone
 else if (objUA.isIpad == true){
     viewportwidth = window.innerWidth;
     viewportheight = window.innerHeight;
	//	 var docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
	//	 viewportheight = docHeight;
 	//	 document.getElementById('footer').style.top = ( viewportheight - 60) +'px';
 } 
 // mozilla/netscape/opera/IE7
 else {
      viewportwidth = window.innerWidth;
      viewportheight = window.innerHeight;
 }
 
 if(!isBlurLinks) BlurLinks();
}

function setFooterBar(){
	if (objUA.isIpad == true){
		var docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
		viewportheight = docHeight;
		document.getElementById('footer').style.top = (viewportheight - 60) + 'px';
//	alert(viewportheight);
	}
}
function footerMove(){
	if(viewportheight > 0){
		if(viewportwidth < 1018){
			document.getElementById('footer').style.bottom = '17px';
			document.getElementById('footer').style.width  =  (viewportwidth - 17) + 'px';
			document.getElementById('footer-inner').style.width  =  (viewportwidth - 17) + 'px';
		}
		else{
			document.getElementById('footer').style.bottom = '0px';
			document.getElementById('footer-inner').style.width  =  '1000px';
			document.getElementById('footer').style.width  = '1000px';
		}
	}
}

var sm_on_id = '';
function initmenutoggle(evt){
	if (!evt) evt = window.event;
	var liObj = document.getElementById("hm").getElementsByTagName("a");
	var liQty=liObj.length;
	var ididx = 0;
	if(sm_on_id == ''){
		var ar = document.getElementById("hm").getElementsByTagName("ul");
		sm_on_id = 1;
		for (var i=0; i < ar.length; i++){
			if(ar[i].className == 'sm on'){
				 sm_on_id = ar[i].id.substr(2,1);
				 i = ar.length;
			}
		}
		if(!document.getElementById("sm" + sm_on_id)){
			for (var i=0; i < ar.length; i++){
				sm_on_id = ar[i].id.substr(2,1);
				i = ar.length;
			}	
		}
	}
	for (var liIdx=0; liIdx < liQty; liIdx++){
		liObj[liIdx].onmousemove=function(){
			ididx = this.id.substr(7, 1);		
			if(ididx != sm_on_id){
				document.getElementById("sm" + sm_on_id).className = 'sm off';
				document.getElementById("hm-item" + sm_on_id).style.backgroundPosition = "20px 0px";
			}
			document.getElementById("sm" + ididx).className = 'sm on';
			document.getElementById("hm-item" + ididx).style.backgroundPosition = "20px -17px";
		}
		liObj[liIdx].onmouseout=function(){
			ididx = this.id.substr(7, 1);		
			if(ididx != sm_on_id){
				document.getElementById("sm" + sm_on_id).className = 'sm on';
				document.getElementById("hm-item" + sm_on_id).style.backgroundPosition = "20px -17px";
			}
			ulObj = document.getElementById("sm" + ididx);
			ulObj.className = 'sm on';			
			if(ididx != sm_on_id){
				ulObj.className = 'sm off';
				document.getElementById("hm-item" + ididx).style.backgroundPosition = "20px 0px";
			}	
			else{
				ulObj.className = 'sm on';
			}	
		}
		liObj[liIdx].onclick=function(){
			ididx = this.id.substr(7, 1);		
			if(ididx != sm_on_id){
				document.getElementById("sm" + sm_on_id).className = 'sm off';
				document.getElementById("hm-item" + sm_on_id).style.backgroundPosition = "20px 0px";
			}
			document.getElementById("sm" + ididx).className = 'sm on';
			document.getElementById("hm-item" + ididx).style.backgroundPosition = "20px -17px";
			sm_on_id = ididx;
		}		
	}
}

function OvToggleTxt(ovid, stat, showtxt){
	var objPi = '';
	var objTxt = '';
	var objNb = '';
	
	if(document.getElementById('ov-txt' + ovid)){
		objTxt = document.getElementById('ov-txt' + ovid);
		objPi = document.getElementById('print-item' + ovid);
		if(document.getElementById('new-ban' + ovid)) objNb = document.getElementById('new-ban' + ovid);
		
		if(stat == 1){
			if(showtxt == 1){
				objTxt.style.display = 'block';
				objPi.style.backgroundPosition = '0px -200px';		
				if(objNb != '') objNb.style.display = 'none';
			}
			objPi.className = 'on';
			document.getElementById("leftmnuitem-" + ovid).className = 'on';
			//fadeOpacity1(objPi, -1, 100);
			//if(objNb != '') fadeOpacity2(objNb, -1, 100);
		}
		else{
			if(showtxt == 1){
				objTxt.style.display = 'none';
				objPi.style.backgroundPosition = '0px 0px';		
				if(objNb != '') objNb.style.display = 'block';	
			}
			objPi.className = 'off';
			document.getElementById("leftmnuitem-" + ovid).className = 'off';
			//fadeOpacity1(objPi, 1, 0);
			//if(objNb != '') fadeOpacity2(objNb, 1, 0);
		}
	}
}


function fadeOpacity1(obj, mod, opa) {
		setOpacity(obj, opa);
		if(mod==1){
			opa += 10;
		}
		else{
			opa -= 10;
		}		
		if(opa >= 0 && opa <= 100){
			setTimeout(function() {fadeOpacity1(obj, mod, opa); }, 20);	
		}	
}
function setOpacity(obj, opa) {
    obj.style.opacity = opa/100;
    obj.style.MozOpacity = opa/100;
    obj.style.KhtmlOpacity = opa/100;
    obj.style.filter = 'alpha(opacity=' + opa + ')';
}



var memPreviousWallpaper = '';
function change_wp(id, imgSrc) {
	if(document.getElementById("wpimglarge")){

		memPreviousWallpaper = document.getElementById("wpimglarge").src;
		document.getElementById("wpimglarge").src = 'img/wallpapers/' + imgSrc + ".jpg";
		
		document.getElementById("wpbtnlnk_1").href = 'img/wallpapers/1280x1024/' + imgSrc + ".jpg";
		document.getElementById("wpbtnlnk_2").href = 'img/wallpapers/1680x1050/' + imgSrc + ".jpg";
		document.getElementById("wpbtnlnk_3").href = 'img/wallpapers/1920x1080/' + imgSrc + ".jpg";
		document.getElementById("wpbtnlnk_4").href = 'img/wallpapers/1920x1200/' + imgSrc + ".jpg";
		document.getElementById("wpbtnlnk_5").href = 'img/wallpapers/iphone/' + imgSrc + ".jpg";
		
		if(document.getElementById("wp-quote-img")){
			document.getElementById("wp-quote-img").src = 'img/wallpapers/' + imgSrc + "_quote.png";
		}
		
	}
}

