function openPopupPlayerDetailsWindow( dat, width, height ) {
	fenster = window.open('core.php' + dat,'fcbpopup','width=' +  width + ',height=' + height + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no,left=0,top=0,screenX=0,screenY=0');
	fenster.moveTo(0,0);
	fenster.focus();
}

function openPopup( url, width, height ) {
	fenster = window.open(url,'fcbpopup','width=' +  width + ',height=' + height + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no,left=0,top=0,screenX=0,screenY=0');
	fenster.moveTo(0,0);
	fenster.focus();
}

function openPrintPopup(dat, width, height ){
	fenster = window.open('core.php'+dat,'printpopup','width=' +  width + ',height=' + height + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no,left=0,top=0,screenX=0,screenY=0');
	fenster.moveTo(0,0);
	fenster.focus();
}

function changeButton( name, pic ){
	document.getElementById(name).src = pic;
}

function changePic(imgname,imgsrc){
	document.getElementById(imgname).src = imgsrc;
}

function toggleDiv(divElement){

	
	for(var i=0;i<document.getElementsByTagName("div").length;i++){
		
		document.getElementsByTagName("div")[i].style.display = "none"; 
	}
	
	if(Boolean(document.getElementById(divElement))) {
		document.getElementById(divElement).style.display = ""; 
	}
}

function showStatistic(name){
	var docname = 'document.select.'+name;
	var url = 'core.php';
	var selected = document.getElementsByName(name)[0].value;	
	location.href = url + selected;
}

function showYear(){
	var value = document.getElementsByName("active_year")[0].value;
	location.href = "core.php" + value;
}

function resizeVerticalBlankFrame(){
		var blankFrameHeight = (document.getElementById('boxContentVerticalBlank').offsetHeight);
		if(blankFrameHeight > 2){
			window.document.getElementById('boxContentVerticalBlank').style['height'] = '2px';
		}
		var leftFrameHeight = (document.getElementById('leftFrame').offsetHeight);
		var rightFrameHeight = (document.getElementById('rightFrame').offsetHeight);
		var contentHeight = (document.getElementById('contentFrame').offsetHeight);
		var windowHeight = Math.max(leftFrameHeight,contentHeight,rightFrameHeight);
		var diffFrames = windowHeight - contentHeight;
		var bodyHeight = (document.getElementsByTagName('body')[0].offsetHeight);
		if (   (navigator.userAgent.indexOf('MSIE')  != -1) && (navigator.userAgent.indexOf('Opera') == -1)) {
			if( bodyHeight > windowHeight ){
				var blankSpace = bodyHeight - windowHeight + diffFrames + 2;
			}else{
				var blankSpace = windowHeight - contentHeight + 2;
			}
			if( blankSpace > 0 ){
				window.document.getElementById('boxContentVerticalBlank').style['height'] = blankSpace + 'px';
			}
		}else{
			if( bodyHeight > windowHeight ){
				var blankSpace = bodyHeight - windowHeight + diffFrames + 39;
			}else{
				var blankSpace = diffFrames + 39;
			}
			if( blankSpace > 0 ){
				window.document.getElementById('boxContentVerticalBlank').style['height'] = blankSpace + 'px';
			}
		}
}

function resizeMatchreportBoxes(key){
	var heightTimeBox = document.getElementById('time'+key).offsetHeight;
	var heightHomeBox = document.getElementById('home'+key).offsetHeight;
	var heightGuestBox = document.getElementById('guest'+key).offsetHeight;
	var heightStandingBox = document.getElementById('standing'+key).offsetHeight;
	var boxHeight = Math.max(heightTimeBox,heightHomeBox,heightGuestBox,heightStandingBox);
	document.getElementById('home'+key).style['height'] = boxHeight + 'px';
	document.getElementById('guest'+key).style['height'] = boxHeight + 'px';
	document.getElementById('standing'+key).style['height'] = boxHeight + 'px';
	if(key == 'flag'){
		boxHeight = boxHeight + 38;
	}
	document.getElementById('time'+key).style['height'] = boxHeight + 'px';
}

function reloadUrl(name){
	var url = document.getElementsByName(name)[0].value;
	location.href = url;
}

function reloadNewstickerUrl(url){
	location.href = url;
}

var keyStr = "ABCDEFGHIJKLMNOP" +
            "QRSTUVWXYZabcdef" +
            "ghijklmnopqrstuv" +
            "wxyz0123456789+/" +
            "=";
function encode(input) {
   var output = "";
	  var chr1, chr2, chr3 = "";
	  var enc1, enc2, enc3, enc4 = "";
	  var i = 0;

  do {
     chr1 = input.charCodeAt(i++);
     chr2 = input.charCodeAt(i++);
     chr3 = input.charCodeAt(i++);

     enc1 = chr1 >> 2;
     enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
     enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
     enc4 = chr3 & 63;

     if (isNaN(chr2)) {
        enc3 = enc4 = 64;
     } else if (isNaN(chr3)) {
        enc4 = 64;
     }

     output = output + 
        keyStr.charAt(enc1) + 
        keyStr.charAt(enc2) + 
        keyStr.charAt(enc3) + 
        keyStr.charAt(enc4);
     chr1 = chr2 = chr3 = "";
     enc1 = enc2 = enc3 = enc4 = "";
      } while (i < input.length);

      return "?dat=" + output;
   }
   
function bannerChange(id){
	//var url = 'component=bannerchange&action=showBanner&id='+id+'&tpl=skel_banner.tpl';
	//url = encode(url);
	var url = 'banner.php?id=' + id;
	location.replace(url);
}
// change Banner
function changeBanner(){
	//alert ("gr?sse"+bannerId.length);
	//alert ("position"+currentBannerPosition);
	//alert ("delay"+bannerDelay[currentBannerPosition]);
	if( ( bannerId.length - 1 ) > currentBannerPosition ){
		currentBannerPosition++;
	}else{
		currentBannerPosition = 0;		
	}
	document.getElementById('bannerPic').src = bannerSrc[currentBannerPosition];
	//alert('Sekunden:'+bannerDelay[currentBannerPosition]);
	setTimeout('changeBanner();',bannerDelay[currentBannerPosition]*1000);
}
// open Banner Url
function goToUrl(){
	var url = 'core.php' + encode('component=bannerchange&action=clickBanner&bannerchangeID='+bannerId[currentBannerPosition]+'&tpl=skel_banner_click.tpl');
	fenster = window.open(url,'bannerPopup');
	fenster.moveTo(0,0);
	fenster.focus();
}

function showNewsticker(){
	if(ntTxt.length == currentNewstickerPosition){
		currentNewstickerPosition = 0;
	}
	document.getElementById('NewstickerText'+lastNewstickerSequence).style['display'] = 'none';
	document.getElementById('NewstickerText'+ntSeq[currentNewstickerPosition]).style['display'] = 'block';
	lastNewstickerSequence = ntSeq[currentNewstickerPosition];
	currentNewstickerPosition++;

	setTimeout('showNewsticker()',3500);
}

function validatePlayerratingForm(){
	var int_playerratingID = 0;
	var error = true;
	for(var i = 0; i < PlayerratingArray.length; i++){
		int_playerratingID = PlayerratingArray[i];
		if(document.getElementsByName(int_playerratingID)[0].checked == true){
			error = false;
		}
		if(document.getElementsByName(int_playerratingID)[1].checked == true){
			error = false;
		}
		if(document.getElementsByName(int_playerratingID)[2].checked == true){
			error = false;
		}
		if(document.getElementsByName(int_playerratingID)[3].checked == true){
			error = false;
		}
	}
	if(error == true){
		alert("Bitte bewerten Sie alle Spieler!");
		return false;
	}else{
		return true;
	}
}
function browserCheck() {
	var version = navigator.appVersion;
	browser = (
		((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4 ))
		|| 
		((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ))
		|| 
		((navigator.appName == "Microsoft Internet Explorer") && (version.search(/MSIE 6.+/) != -1 ))
		|| 
		((navigator.appName == "Microsoft Internet Explorer") && (version.search(/MSIE 5\.5.+/) != -1 ))
		|| 
		((navigator.appName == "Safari") && (parseInt(navigator.appVersion) >= 1 ))
	);

	if (browser == 0)	location='html/browsercheck.html';
}

function detectingFLASH() {
	var browser = navigator.userAgent.toLowerCase();
	flashVersion = 0;
	// NS3+, Opera3+, IE5+ Mac
	if ( navigator.plugins != null && navigator.plugins.length > 0 ) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if ( typeof flashPlugin == 'object' ) {
			if ( flashPlugin.description.indexOf('7.') != -1 ) flashVersion = 7;
			else if ( flashPlugin.description.indexOf('6.') != -1 ) flashVersion = 6;
			else if ( flashPlugin.description.indexOf('5.') != -1 ) flashVersion = 5;
			else if ( flashPlugin.description.indexOf('4.') != -1 ) flashVersion = 4;
			else if ( flashPlugin.description.indexOf('3.') != -1 ) flashVersion = 3;
		}
	} else if ( browser.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && browser.indexOf("win")!= -1 && browser.indexOf("16bit")== -1 ) {
		// IE4+ Win32 (VBscript)
		document.write('<scr' + 'ipt language="VBScript"\> \n');
		document.write('on error resume next \n');
		document.write('DIM obFlash \n');
		document.write('SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.7") \n');
		document.write('IF IsObject(obFlash) THEN \n');
		document.write('flashVersion = 7 \n');
		document.write('ELSE SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.6") END IF \n');
		document.write('IF flashVersion < 7 and IsObject(obFlash) THEN \n');
		document.write('flashVersion = 6 \n');
		document.write('ELSE SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.5") END IF \n');
		document.write('IF flashVersion < 6 and IsObject(obFlash) THEN \n');
		document.write('flashVersion = 5 \n');
		document.write('ELSE SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.4") END IF \n');
		document.write('IF flashVersion < 5 and IsObject(obFlash) THEN \n');
		document.write('flashVersion = 4 \n');
		document.write('ELSE SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.3") END IF \n');
		document.write('IF flashVersion < 4 and IsObject(obFlash) THEN \n');
		document.write('flashVersion = 3 \n');
		document.write('END IF');
		document.write('</scr' + 'ipt\> \n');
	} else {
		// no Flash
		flashVersion = -1;
	}
	return flashVersion;
}
