// JavaScript Document
//<![CDATA[

var tip_call=''

function init() {
//	X = document.getElementById('foerster').style.display;
//	document.getElementById('foersterhaus').innerHTML=X;
//	X=200;
//	ttcall = "TagToTip('foersterhaus',FIX,['foerster',0,0],PADDING,0,BGCOLOR,'none',FONTSIZE,'18px',STICKY,true,CLICKSTICKY,true,DURATION,5000,FADEOUT,2000)"

//	ttcall = "fade('foersterhaus',FIX,['foerster',0,0],PADDING,0,BGCOLOR,'none',FONTSIZE,'18px',STICKY,true,CLICKSTICKY,true,DURATION,5000,FADEOUT,2000)"

//	fhaus_fade = document.getElementById('foerster').style.opacity='.';

//	setInterval ('eval(ttcall)',1000)
//startClock()
//	fade_slogan()
//
	ticker_slogan('slogan')
//	divScroller('slogan','h',3,300)
}

function ticker_slogan(n) {
	if (!n) n=0
	var slogan = "       +++       Kulturinsel für Bramfeld. Jetzt!       "
	var sl = document.getElementById('slogan')

//
	if (n==slogan.length) n=0;

	part1=slogan.substring(n,n+slogan.length)
	part2=slogan.substring(0,n)

	sl.innerHTML=part1+part2
	n++
	setTimeout('ticker_slogan('+ n +')',480)
}


function fade_slogan(n) {
	var sl = new FadeObjectClass('slogan')
	sl.min=1
	
	var slogan = [
		"Kultur und der ganze Hof",
		"Kulturinsel f&uuml;r Bramfeld Jetzt!"
	]

	if (!n) n=0
	
	if (n==slogan.length) n=0

	var thisObj = sl
//	setTimeout(function(){ thisObj.fade_in()},2000 );
//	setTimeout(sl+".fade_out()",2000)
	if (sl.trans==10 )setTimeout(function(){ thisObj.fade_out()},4000 );

/*
	var min = 0
	var max = slogan.length -1
	var r = parseInt( Math.random() * ( max+1 ) )
	n = r + min <= max ? r + min : r
*/

	slogid = document.getElementById('slogan')
	slogidtxt = slogid.innerHTML

	slogid.innerHTML= slogan[n]
//
	thisObj.fade_in()
	n++
	setTimeout("fade_slogan("+n+")",6000)
//	sl.dyndelay = [1010,1010,10,10,100,10,150,150,150,1240]
}

function show_widget(ajax_request,obj) {
	if (document.getElementById("widget")) {
    if (document.getElementById("widget").style.display=="block")
			{
			document.getElementById("widget").style.display="none";
			return
			}
	}

//
  tip_call = obj;
	var myAjax = new Ajax.Request(
	  ajax_request,
	  { method: 'get', onComplete: ajax_zeige_ergebnis }
	);

	return false;
}

var fadeBackground =  function (dynback) {
//		if (this.fontcolors[this.trans]) {
			bg = '#ccc'
//		big = 10 + this.trans
			document.getElementById('dynback').style.display="block"
//		}
	}


function FadeObjectClass (obj) {
	this.obj = obj
	this.min = 1
	this.max = 10
	this.delay = 150
	this.test = 0
	this.dir = "in"
	this.fade_style = [1,2,3,4,5,6,7,8,9,10]
	this.dyndelay = [10,20,30,40,50,80,100,250,500,1000]
	this.dyndelay = [10,10,10,50,10,150,50,50,150,240]
	this.fontsizes = [,,,17,,,18,,17]
	this.fontcolors = ['#088','#088','#088','#077','#088','#0a8','#088','#588','#a99']
	this.defaultFontsize = document.getElementById(this.obj).style.fontSize;
	this.inout = ""
	this.infodiv
	this.timer=0
	this.speed=10


	this.visible = function () {
		var vis
		if (document.getElementById)	vis = document.getElementById(this.obj).style.display;
		if (vis == "none") return false
		if (vis == "block") return true
		if (vis == "inline") return true
		if (vis == "inline-block") return true
		if (vis == "") return false

		return vis;
	}

	this.current_trans = function() {
    var opac = document.getElementById(this.obj).style
		if (document.all) return document.all[this.obj].filters.alpha.opacity /10
		if (opac.opacity)	return opac.opacity *10
		if (opac.MozOpacity)	return opac.MozOpacity *10
		if (opac.KhtmlOpacity)	return opac.KhtmlOpacity *10
		return document.getElementById(this.obj).style.opacity *10
		}

	this.minmax = function (min,max) {
		if (min) this.min = min
		if (max) this.max = max
	}

	this.pumpIt= function (trans) {
		if (dyndelay = this.dyndelay[trans]) {
		  this.delay = this.dyndelay[trans]
		}
	}

	this.make_trans= function (trans) {
			if (!trans) trans = this.trans
      opac = document.getElementById(this.obj).style
			opac.opacity = (trans / 10);
	    opac.MozOpacity = (trans / 10);
	    opac.KhtmlOpacity = (trans / 10);
	    opac.filter = "alpha(opacity=" + trans * 10 + ")";
	}

	this.fade_in = function (i) {
		if (i) this.trans = i;

		if (document.all) {
//			if (document.all[this.obj].filters.alpha.opacity >= 10) this.trans=0;
		}

		if (this.trans > this.max) {
		  this.stop()
			return;
		}

		this.speed = this.trans*10
		this.make_trans()
		this.css_show()
		this.trans++
		var thisObj = this;
		this.timer = setTimeout(function(){ thisObj.fade_in()},this.delay );
	}

	this.fade_out = function (i) {
		if (i) this.trans = i;

		if (this.trans == 0) {
			this.css_hide()
		  this.stop()
			return;
		}

		this.speed = this.trans*10

		this.make_trans()
		this.trans--
		var thisObj = this; this.timer = setTimeout(function(){ thisObj.fade_out()},this.delay );
	}

	this.fade_inout = function () {
		if (this.trans == this.min) {
			this.dir = "in"
		}

		if (this.trans == this.max)  {
			this.dir = "out"
		}

		if (this.dir == "in") this.trans++
		if (this.dir == "out") this.trans--

		this.make_trans()
		var thisObj = this;
		this.timer = setTimeout(function(){ thisObj.fade_inout()},this.delay );
	}

	this.css_show = function () {
		document.getElementById(this.obj).style.display="block"
	}

	this.css_hide = function () {
		document.getElementById(this.obj).style.display="none"
	}


	this.info = function(info) {
		test = "min " + this.min
		+ " :: max "+ this.max
		+ " :: trans "+ this.trans
		+ " :: current_trans "+ 		this.current_trans()
		+ " :: delay "+ this.delay
		+ " :: timer "+ this.timer
		+ " :: this.vis "+ this.visible()

		if (info) test += info
		self.defaultStatus= test;
	}

	this.show_infodiv = function (info) {
		if (!document.infodiv) {
			document.infodiv = document.createElement('div')
			document.body.appendChild(document.infodiv);
		}
		document.infodiv.className ='info'
		document.infodiv.innerHTML =info
	}
	
	this.stop  = function (){
		clearTimeout(this.timer)
	}

	this.vis = this.visible()
	this.trans = this.current_trans ()

/*
	this.fadeFontSize =  function (trans) {
		if (this.fontsizes[this.trans]) {
			big = this.fontsizes[this.trans]
			document.getElementById(this.obj).style.fontSize = big  +"px"
		}
	}

	this.fadeFontColors =  function (trans) {
		if (this.fontcolors[this.trans]) {
			color = this.fontcolors[this.trans]
			document.getElementById(this.obj).style.color = color
		}
	}
*/

} // END CLASS



function pfeil_ani (obj,step) {
	var chars = ['#029','#039','#049','#059','#056','#099','#079','#056','#049','#039']
	if (!step) step = 0;
	if (step == chars.length) step = 0
	pobj = document.getElementById(obj);
	pobj.style.border = "1px dotted "+chars[step]
	step++
	setTimeout('pfeil_ani("' +obj+'",'+step+')',300)
}

function toggle_display(id,attr,min,max) {
//	if (document.all) alert(document.all[id].filters.alpha.opacity)

	var fo = new FadeObjectClass(id)
	var tobj = document.getElementById(id)
//			fo.info()

//	tobjvis = tobj.style.display;
//	document.all[id].style.visibility="hidden"
//	if (document.all) tobjvis =document.all[id].style.visibility
//	alert(tobjvis)
	if (min) fo.min = min
	if (max) fo.max = max

	if (attr=="fade_in" ){
		if (!fo.visible()) fo.fade_in()
		return
	}

	if (attr=="fade_out" ){
		fo.fade_out()
		return;
	}

	if (attr=="fade_inout" ){
		fo.fade_inout()
		return;
	}

	if (!fo.visible()){
		fo.fade_in()
		return
	}

	if (fo.visible()){
		fo.fade_out()
		return
	}
//	if (attr) tobj.style.display = attr;
}


	function ajax_show_content( originalRequest ) {
		var myAjax = new Ajax.Request(
		  ajax_request,
		  { method: 'get', onComplete: ajax_zeige_ergebnis }
		);
	}

	function ajax_zeige_ergebnis( originalRequest ) {
	  test =""
//
		+"<div class='titlebar'>"
//
		+"<a id='closebutton' class='closebtn' href='javascript:void(0);' onclick='UnTip(); tt_HideInit()'>"
//
		+"<img src='loading.gif' /></a>"
//
		+"</div>"
		+"<div id='widget_id'>"
		+ originalRequest.responseText
		+"</div>" ;

		if (tip_call)
			eval('Tip(test,'+tip_call+')')
		else
		Tip(test)

		document.getElementById('closebutton').innerHTML = widget_closbtn;
	}



function pdf_window(file) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	
	pdf = window.open(file,"pdf","width=600,height="+myHeight+",left=260,top=0,toolbar=no,menubar=no,scrollbars=yes");
//	pdf.innerHeight=h;
//	pdf.document.documentElement.clientHeight=h;
}

function changeColor(style) {
	farbe = document.getElementById('farbe');
//	farbe.innerHTML='<link rel="stylesheet" href="'+ style +'.css" media="screen" type="text/css" />';
}


function ex_init() {
//
	fade_spot_1 = new SpotObject('spot_1','fade_spot_1');
	fade_spot_2 = new SpotObject('spot_2','fade_spot_2');
}
//]]>


