
var ua = navigator.userAgent.toLowerCase();
var browseHeight = 0;

function Fensterhoehe() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body &&  document.body.clientHeight ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  
  return myHeight;
}


// This function sets the height of the table
// so that the table fits into the window without scrollbars
function setHeight()
{
	scr_h = Fensterhoehe();
	
	if (document.layers){
	//Netscape 4 specific code
		pre = 'document.';
		post = '';
		post1 = '';
	}
	if (document.getElementById){
		//Netscape 6 specific code
		pre = 'document.getElementById("';
		post = '").style';
		post1 = '")';
	}
	if (document.all){
		//IE4+ specific code
		pre = 'document.all.';
		post = '.style';
		post1 = '';		
	}

	// scr_h - value > 0 ==> scrollbar; scr_h - value < 0 ==> loch
	if(browseHeight != scr_h - 30)
	{
		//src_h - 194
		browseHeight = scr_h - 30;
		
		if(ua.indexOf('msie') == -1)
			browseHeight += 5;
			
		if(browseHeight < 1) browseHeight=1;
		
		if(eval(pre + 'center' + post1) != null)
		{
			var myNews = eval(pre + 'center' + post);
			if(ua.indexOf('msie') != -1){
				if(browseHeight > 50)
					myNews.height = browseHeight - 50+"px";
				else myNews.height = 0+"px";
			}
			else{
				if(browseHeight > 55)
					myNews.height = browseHeight - 55+"px";
				else myNews.height = 0+"px";
			}
		}	
		
		if(eval(pre + 'left' + post1) != null)
		{
			var myNews = eval(pre + 'left' + post);
			if(ua.indexOf('msie') != -1){
				if(browseHeight > 50)
					myNews.height = browseHeight - 50+"px";
				else myNews.height = 0+"px";
			}
			else{
				if(browseHeight > 55)
					myNews.height = browseHeight - 55+"px";
				else myNews.height = 0+"px";
			}
			
		}
		if(eval(pre + 'right' + post1) != null)
		{
			var myNews = eval(pre + 'right' + post);
			if(ua.indexOf('msie') != -1){
				if(browseHeight > 100)
					myNews.height = browseHeight - 100+"px";
				else myNews.height = 0+"px";
			}
			else{
				if(browseHeight > 105)
					myNews.height = browseHeight - 105+"px";
				else myNews.height = 0+"px";
			}
		}
		
		if(eval(pre + 'contentscroll' + post1) != null)
		{
			var myNews = eval(pre + 'contentscroll' + post);
			if(browseHeight > 80)
				myNews.height = browseHeight - 80+"px";	
			else myNews.height = 0+"px";
		}
		
		if(eval(pre + 'templatescroll' + post1) != null)
		{
			var myNews = eval(pre + 'templatescroll' + post);
			if(ua.indexOf('msie') != -1){
				if(browseHeight > 106)
				myNews.height = browseHeight - 106+"px";	
			else myNews.height = 0+"px";	
			}
			else{
				if(browseHeight > 109)
				myNews.height = browseHeight - 109+"px";	
			else myNews.height = 0+"px";
			}
		}
		
		if(eval(pre + 'inhaltdiv' + post1) != null)
		{
			var myNews = eval(pre + 'inhaltdiv' + post);
			if(ua.indexOf('msie') != -1){
				if(browseHeight > 150)
				myNews.height = browseHeight - 150+"px";	
			else myNews.height = 0+"px";	
			}
			else{
				if(browseHeight > 165)
				myNews.height = browseHeight - 165+"px";	
			else myNews.height = 0+"px";
			}
		}
		
		if(eval(pre + 'clubdiv' + post1) != null)
		{
			var myNews = eval(pre + 'clubdiv' + post);
			if(ua.indexOf('msie') != -1){
				if(browseHeight > 180)
				myNews.height = browseHeight - 180+"px";	
			else myNews.height = 0+"px";	
			}
			else{
				if(browseHeight > 195)
				myNews.height = browseHeight - 195+"px";	
			else myNews.height = 0+"px";
			}
		}
		
		if(eval(pre + 'archivscroller' + post1) != null)
		{
			var myNews = eval(pre + 'archivscroller' + post);
			if(ua.indexOf('msie') != -1){
				if(browseHeight > 201)
				myNews.height = browseHeight - 201+"px";	
			else myNews.height = 0+"px";	
			}
			else{
				if(browseHeight > 241)
				myNews.height = browseHeight - 241+"px";	
			else myNews.height = 0+"px";
			}
		}
		
		if(eval(pre + 'rightimage' + post1) != null)
		{
			var myNews = eval(pre + 'rightimage' + post);
			if(ua.indexOf('msie') != -1){
				if(browseHeight > 477)
					myNews.top = browseHeight - 497+"px";
				else myNews.top = 0+"px";	
			}
			else{
				if(browseHeight > 494)
					myNews.top = browseHeight - 494+"px";	
				else myNews.top = 0+"px";	
			}
		}
		
			
		if(eval(pre + 'previewDiv' + post1) != null)
		{
			var myNews = eval(pre + 'previewDiv' + post);
		
			if(ua.indexOf('msie') != -1){
				if(browseHeight > 193)
					myNews.height = browseHeight - 193+"px";	
				else myNews.height = 0+"px";
			}
			else{
				if(browseHeight > 175)
				 myNews.height = browseHeight - 175+"px";
				else myNews.height = 0+"px";
			}
		}
		
		if(eval(pre + 'imageDiv' + post1) != null)
		{
			var myNews = eval(pre + 'imageDiv' + post);
			if(ua.indexOf('msie') != -1){
				if(browseHeight > 210)
					myNews.height = browseHeight - 210+"px";	
				else myNews.height = 0+"px";
			}
			else{
				if(browseHeight > 255)
					myNews.height = browseHeight - 255+"px";	
				else myNews.height = 0+"px";
			}
		}
		
	}	
	if(ua.indexOf('netscape') == -1)
		var Id = window.setTimeout("setHeight();",300);
	else 
		var Id = window.setTimeout("setHeight();",10000);
}

function setColor(mod, img)
{
	if(img != aktmenu)
	{
		var src = "grafik/button_02.jpg";
		if(mod == 1)
			src = "grafik/button_01.jpg";
		if(document.getElementById(img) != null)
			document.getElementById(img).src = src;
	}
}

var aktmenu;
var opencontainer;
//funktion welche untermenüs öffnet
function showsubmenu(container)
{
	if(document.getElementById(opencontainer) != null)
	{
		document.getElementById(opencontainer).style.display = "none";
	}
	if(document.getElementById(container) != null)
	{
		document.getElementById(container).style.display = "block";
	}
	opencontainer = container;
}

function changepic()
{

	//store the quotations in arrays
	
	var anzImages = 18;
	var index = Math.floor(Math.random() * anzImages)+1;
	if(index < 10) index = "0" + index;
	
	parent.Content.document.getElementById("rightimage").src = "grafik/rechts_"+index+".jpg?";
	parent.Scroller.document.getElementById("bottomdiv").style.background = "url('grafik/unten_"+index+".jpg') no-repeat";
	window.clearTimeout(chngpic);
}

//für die kaderliste
function setKader(id)
{
	document.getElementById("akader").className = "Kader";
	document.getElementById("bkader").className = "Kader";
	document.getElementById("ckader").className = "Kader";
	document.getElementById("dkader").className = "Kader";
	document.getElementById("akaderimg").src = "grafik/kader_2.gif";
	document.getElementById("bkaderimg").src = "grafik/kader_2.gif";
	document.getElementById("ckaderimg").src = "grafik/kader_2.gif";
	document.getElementById("dkaderimg").src = "grafik/kader_2.gif";
	document.getElementById("akaderliste").style.display = "none";
	document.getElementById("bkaderliste").style.display = "none";
	document.getElementById("ckaderliste").style.display = "none";
	document.getElementById("dkaderliste").style.display = "none";
	
	document.getElementById(id).className = "selKader";
	document.getElementById(id+"img").src = "grafik/kader_1.gif";
	document.getElementById(id + "liste").style.display = "block";
}


wmtt = null;

//document.onmousemove = fly_move;


function fly_move(e) {
	x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
	width = (document.all) ?  document.body.clientWidth : window.innerWidth;
	
	if (wmtt != null) {
		if(x > (width/2 + 80))
		{
			x = x-220;	
		}
		wmtt.style.left = (x + 17) + "px";
		wmtt.style.top 	= (y + 17) + "px";
	}
	

}



/* 
text ==> text that will be written into the div 
divname ==> name of div that will be shown 
*/

function fly_start(text, divname) {
		
	if (document.layers){
	    //Netscape 4 specific code
	    pre = 'document.';
	    post = '';
		post1 = '';		
	    scr_h = window.innerHeight;
	}
	if (document.getElementById){
	    //Netscape 6 specific code
	    pre = 'document.getElementById("';
	    post = '").style';
		post1 = '")';		
	    scr_h = window.innerHeight;

	}
	if (document.all){
	    //IE4+ specific code
	    pre = 'document.all.';
	    post = '.style';
		post1 = '';		
	    scr_h = document.body.clientHeight;
	}
	
	// standard is overdiv
	if(divname == "")
		divname = "overDiv";
		
	wmtt = null;
	wmtt = eval(pre + divname + post1);	
	
	
	if (wmtt != null) 
	{
		// old style
		if(divname == "overDiv")
			wmtt.innerHTML = "<TABLE WIDTH=190 CELLPADDING=0 CELLSPACING=0 BGCOLOR='#c0c0c0' style='border-style:solid; border-color:#c0c0c0; border-width:1'><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR='#eeeeee'><TR><TD VALIGN=TOP align=center><FONT FACE='Arial,Helvetica'  SIZE='1' class='flyout'><div align=left>"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>";
		
		if(text != "" && divname != "overDiv")
			wmtt.innerHTML = text;
			
		wmtt.style.display = "block";	
	}
}


function fly_stop() {
	if (wmtt != null) 
		wmtt.style.display = "none";
		wmtt = null;
}


function showNewsDetail(id,newsid)
{
	window.location.href = "root.aspx?id="+id+"&newsid="+newsid;
}

var gAutoPrint = false; // Flag for whether or not to automatically call the print function

function printscreen(name,aid)
{
	if (document.layers){
	//Netscape 4 specific code
		pre = 'document.';
		post1 = '';
	}
	if (document.getElementById){
		//Netscape 6 specific code
		pre = 'document.getElementById("';
		post1 = '")';
	}
	if (document.all){
		//IE4+ specific code
		pre = 'document.all.';
		post1 = '';		
	}

	var myLayer = null;
	if(document.getElementById('contentscroll') != null)
		myLayer = eval(pre + 'contentscroll' + post1);
	else myLayer = eval(pre + 'printdiv' + post1);
		
	today = new Date();
	var strDateTime = today.getDate() + "." + (today.getMonth()+1) + "." + today.getFullYear() + ", " + today.toLocaleTimeString() + " Uhr";
	
	var parameter = "menubar=yes,toolbar=yes,scrollbars=yes,statusbar=no,location=no,resizable=yes,width=750px,height=520px";
	var printWin = window.open("","printSpecial",parameter);
	
	var text = "";
	text += "<table width=100%><tr><td class=printheader style=\"padding-bottom:4px\" valign=bottom><img src=\"grafik/rvotlogo.jpg\" border=\"0\">&nbsp;<b>"+name+"</b></td></tr><tr><td align=right style=\"font-size:10px\">"+strDateTime+"</td></table><br>";
	text += myLayer.innerHTML.replace(/<< back/,"").replace(/&lt;&lt; back/,"");
	text = text.replace(/<a/,"<a style='disable:true'").replace(/<A/,"<a style='disable:true'");
	text = text.replace("templatescroll","t");
	text = text.replace("inhaltdiv","t");
	text = text.replace("archivscroller","t");
	
	text = text.replace("<IMG src=\"./grafik/print.gif\" border=0>","");
	text = replaceAll( text, "onclick=\"","onclick = \"return false;");

	printWin.document.open();	
	
	printWin.document.write("<html><head><link href='ostschweiz.css' rel='stylesheet' type='text/css'></link><script src='print.js' type='text/javascript'></script></head><style> body {background-color:white;text-align:left;font-family:verdana} div {overflow:visible;} .scroll{overflow:visible;}</style><body><div class='text'><form onsubmit='return false;'>" + text + "</form></div><br><table width=100%><tr><td class=printheader style=\"font-size:10px;padding-bottom:4px\">" + document.URL + "</td></tr><tr><td align=right style=\"font-size:10px;margin-top:0px\">&copy; 2005 <FONT class=titel><SPAN class=text_fett>Regionalverband Ostschweiz Tennis</td></tr></table></body></html>");
	printWin.document.close();
	if (gAutoPrint)
		printWin.print();
}

function replaceAll( str, from, to ) {
    var idx = str.indexOf(from);

	var i = 0;
    while (idx > -1 && i<100) {
		i++;
        str = str.replace(from, to); 
        idx = str.indexOf(from);
    }
    return str;
}
