// resize leftnavi
function leftnaviresize(id, plusheight, minusheight) {
	// Leftnavi
	var leftnavi = document.getElementById('leftnavi');
	var contentheight = document.getElementById(id).offsetHeight;
	var contentheightnew = contentheight + plusheight - minusheight;
	leftnavi.style.height=(contentheightnew)+'px';
}


// open a new window
function zoom(url,name,width,height) {
 if (document.all)
     var xMax = screen.width, yMax = screen.height;
 else

 if (document.layers)
     var xMax = window.outerWidth, yMax = window.outerHeight;
 else
     var xMax = 640, yMax=480;

     var xOffset = (xMax - width)/2, yOffset = (yMax - height)/2;

var popupWindow;
popupWindow=eval("window.open('" +url+ "', '" +name+ "', 'width="+width+",height="+height+",screenX="+xOffset+",screenY="+yOffset+", top="+yOffset+",left="+xOffset+",toolbar=no,status=no,scrollbars=yes,resizable=yes,menubar=no')");
popupWindow.focus();
}


// send mail function (spam blocker) (by netzmacher)
function sendMail(username,domainname,subject) {
	var strEMail = "mailto:" + username+ "@" + domainname +"?subject=" + subject;
	window.location = strEMail;
}


// send mail function (spam blocker)
function linkTo_UnCryptMailto(CryptedString)	{
	location.href=UnCryptMailto(CryptedString);
}

function UnCryptMailto(CryptedString) {
	var n=0;
	var r="";
	for(var i=0; i < CryptedString.length; i++) {
		n=CryptedString.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(8));
	}
	return r;
}


// select-box sorter
function keySort(dropdownlist,caseSensitive) {
  // check the keypressBuffer attribute is defined on the dropdownlist 
  var undefined; 
  if (dropdownlist.keypressBuffer == undefined) { 
    dropdownlist.keypressBuffer = ''; 
  } 
  // get the key that was pressed 
  var key = String.fromCharCode(window.event.keyCode); 
  dropdownlist.keypressBuffer += key;
  if (!caseSensitive) {
    // convert buffer to lowercase
    dropdownlist.keypressBuffer = dropdownlist.keypressBuffer.toLowerCase();
  }
  // find if it is the start of any of the options 
  var optionsLength = dropdownlist.options.length; 
  for (var n=0; n < optionsLength; n++) { 
    var optionText = dropdownlist.options[n].text; 
    if (!caseSensitive) {
      optionText = optionText.toLowerCase();
    }
    if (optionText.indexOf(dropdownlist.keypressBuffer,0) == 0) { 
      dropdownlist.selectedIndex = n; 
      return false; // cancel the default behavior since 
                    // we have selected our own value 
    } 
  } 
  // reset initial key to be inline with default behavior 
  dropdownlist.keypressBuffer = key; 
  return true; // give default behavior 
} 
