var ns=false, ie=false;
var windowWidth, windowHeight;
var objRef, styleSwitch, pixSwitch, leftSwitch, topSwitch;
var gen5, elementID, diffX, diffY;
var timer;
checkBrowser();


// Browsererkennung
function checkBrowser() {
        if( (parseInt( navigator.appVersion )) >= 4 ) {
                ( navigator.appName.indexOf("etscape") != -1 ) ? ns = true : ns = false;
                ( navigator.appName.indexOf("xplorer") != -1 ) ? ie = true : ie = false;
                gen5 = document.getElementById ? 1 : 0; // check if it is a 5th generation Browser
        }
}

// CrossBrowser objRefekte erstellen
function makeObj( elementID ) {
        if ( gen5 ) {
                objRef = 'document.getElementById("' + elementID + '")';
                styleSwitch = ".style";
        }
        if( ns ) {
                // if ( !gen5 ) {objRef = 'document.all["' + elementID + '"]'};
                if ( !gen5 ) {objRef = 'document.layers["' + elementID + '"]'};
                if ( !gen5 ) {styleSwitch = ""};
                leftSwitch = ".left";
                topSwitch = ".top";
                widthSwitch = ".clip.right";
                heightSwitch = ".clip.bottom";
        }
        else if( ie ) {
                if ( !gen5 ) {objRef = 'document.all["' + elementID + '"]'};
                if ( !gen5 ) {styleSwitch = ".style"};
                leftSwitch = ".pixelLeft";
                topSwitch = ".pixelTop";
                widthSwitch = ".width";
                heightSwitch = ".height";
        }

		if ( eval( objRef ) ) {
			
			this.obj = eval( objRef );
			this.css = eval( objRef + styleSwitch );
			this.css.left = eval( objRef + styleSwitch + leftSwitch );
			this.css.top = eval( objRef + styleSwitch + topSwitch );
			this.css.visibility = eval( objRef + styleSwitch + '.visibility' );
			this.css.width = eval( objRef + styleSwitch + widthSwitch );
			this.css.height = eval( objRef + styleSwitch + heightSwitch );
			
			var Xleft = parseInt( this.css.left );
			var Ytop = parseInt( this.css.top );
			var Xright = parseInt( this.css.left ) + parseInt( this.css.width );
			var Ybottom = parseInt( this.css.top ) + parseInt( this.css.height );
			
			layerXY = [Xleft, Xright, Ytop, Ybottom];
		
		}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/***************************************************/

function checkLigaJoin() {
	rad1 = document.forms["register"].ligajoin[0].checked;
	f1 = document.forms["register"].liga_name;
	f2 = document.forms["register"].liga_password;
	
	if (rad1) {
		f1.disabled = true;
		f2.disabled = true;	
	} else {
		f1.disabled = false;
		f2.disabled = false;	
		f1.focus();
	}
}

function agb() {
	win = window.open("agb.html", "agb", "width=400,height=300,scroll=1,scrollbars=1");
}
function datenschutz() {
	win = window.open("datenschutz.html", "datenschutz", "width=400,height=300,scroll=1,scrollbars=1");
}
function impressum() {
	win = window.open("impressum.html", "impressum", "width=400,height=300,scroll=1,scrollbars=1");
}
function hilfe() {
	win = window.open("hilfe.html", "hilfe", "width=335,height=580,scroll=1,scrollbars=1");
}
function sms(p,d) {
	turl = "short_message.php?r="+p;
	if (d) {
		turl += "&d="+d;
	}
	win = window.open(turl, "sms", "width=310,height=330,scroll=0,scrollbars=0, status=1");
}

function keyPressed() {
	var n = document.forms[0].nachricht;
	var s = n.value;
	rest = 254 - s.length;
	if (rest<0) {
		alert("Die maximale Länge von 255 Zeichen ist erreicht.");
		n.value = n.value.substring(0,254);
	} else {
		makeObj( "restChars" );
		this.obj.innerHTML = "<b>Nachricht (noch "+rest+" Zeichen)</b>";
	}
}

function extraWindow(u,w,h) {
	popup = window.open(u, "popup", "resizable=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=auto,copyhistory=0,width="+w+",height="+h);
}