function printWindow() {
  Browser = parseInt(navigator.appVersion);
  if (Browser >= 4) window.print();
}
  
function confirmLink(theLink, theText) {
  // Confirmation is not required if the browser is Opera (crappy js implementation)
  if (typeof(window.opera) != 'undefined') {return true;}
  var is_confirmed = confirm(theText);
  if (is_confirmed) {theLink.href += '&is_js_confirmed=1';}
  return is_confirmed;
}

function imgXY(imgID) {
  /* This function returns the upperleft x,y coordinates of the specified image */
  var XY = new Object();
  var imgObj = document.images[imgID];
  if (imgObj == null) return false;
  if (document.layers) {
		XY.x = eval(imgObj).x;
		XY.y = eval(imgObj).y;
  }else{
		var x,y, tempEl;
		x = eval(imgObj).offsetLeft;
		y = eval(imgObj).offsetTop;
		tempEl = eval(imgObj).offsetParent;
	  while (tempEl != null) {
	  	x += tempEl.offsetLeft;
			y += tempEl.offsetTop;
	  	tempEl = tempEl.offsetParent;
	  }
		XY.x = x;
		XY.y = y;
  }
  return XY;
}

function displayMenu(menu) {
	var imgPos; 
	imgPos = imgXY(menu); 
	if (imgPos){
  	showPermPanel('Main',imgPos.x, imgPos.y);
	}	
} 

function showDiv(doshow, div) {
  if(doshow){
  	document.getElementById(div).style.display=''
  }else{
  	document.getElementById(div).style.display='none'
  }  	
}

function buttonDisable(id) {
	var btn;
	btn = document.getElementById(id);
	if(btn){
    btn.style.backgroundColor='gray';
    btn.style.cursor='default';
    btn.disabled='true'
	}
}

function buttonEnable(id) {
	var btn;
	btn = document.getElementById(id);
	if(btn){
    btn.style.backgroundColor='red';
    btn.style.cursor='point';
    btn.disabled='false'
	}
}

function checkSelection(typ, val, fkt) {
  switch(typ) {
    case "obj":
  	  switch(val) {
  	  	case "16":
  	  	  eval(fkt+'('+val+',"'+typ+'",40,0)');
  	  	  break;  
   	  	default:
  	  	  eval(fkt+'('+val+',"'+typ+'")');
  	  }
      break;   
  	case "erg":
  	  //alert('Wert: ' + val);
  	  switch(val) {
  	  	case "2":
  	  	  eval(fkt+'('+val+',"'+typ+'",20,0)');
  	  	  break;  
  	  	case "14": //Ergebnis Einzel -> Abfrage Anzahl Gewichtsklassen und Teilnehmer pro Klasse
          var gk = prompt("Bitte geben Sie die Anzahl der Gewichtsklassen an.","4");
          var tn = prompt("Bitte geben Sie die Anzahl der Teilnehmer ja Gewichtsklasse an.","6");
          if (!tn | !gk){
          	alert('Verarbeitung abgebrochen');
          }else{          	
 	          if (tn<1 | tn>9 | gk<1 | gk>50){
 	          	alert('Teilnehmeranzahl: 1-9, Gewichtsklassen: 1-50');
 	          }else{
            	eval(fkt+'('+val+',"'+typ+'",'+gk+','+tn+')');
 	          }	
          }  	  	  
  	  	  break;
  	  	case "15":
  	  	  eval(fkt+'('+val+',"'+typ+'",1,30)');
  	  	  break;  
  	  	default:
  	  	  eval(fkt+'('+val+',"'+typ+'")');
  	  }
  	break;
  	default:
  	  alert('Fehler checkSelection: Der Typ ' + typ + ' wird nicht unterstuetzt.');
  }
}