// -------------------------------------------------------------------
// gAjax RSS Pausing Scroller- By Dynamic Drive, available at: http://www.dynamicdrive.com
// Created: Aug 2nd, 2007 Updated: n/a
// REQUIRES: gfeedfetcher.js class, available at http://dynamicdrive.com/dynamicindex18/gajaxrssdisplayer.htm
// -------------------------------------------------------------------

var gfeedfetcher_loading_image="http://www.berlin-original.de/img/indicator.gif" //Specify full URL to "loading" image. Overwrites same var from gfeedfetcher.js


function gfeedpausescroller(divid, divClass, delay, linktarget){
	this.tickerid=divid //ID of outermost scroller div
	this.delay=parseInt(delay) //Default delay between msg change, in miliseconds.
	this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
	this.hiddendivpointer=1 //index of RSS feed array's entry for hidden div
	this.itemsperpage=1 //Entries to show per page
	document.write('<div id="'+divid+'" class="'+divClass+'" style="position: relative; overflow: hidden">')
	document.write('<div class="innerDiv" style="position: absolute; width: 100%" id="'+divid+'1"><span style="position: absolute">Initializing RSS scroller...</span></div>')
	document.write('<div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divid+'2"></div>')
	gfeedfetcher.call(this, divid+"unneeded", divClass+"unneeded", linktarget) //inherit properties from "gfeedfetcher" class, but feed it bogus ID/Class, as we won't be using the DIV generated by "gfeedfetcher"
	document.write('</div>')
	this.itemcontainer="<div>" //default element wrapping around each RSS entry
	this.feedcontainer.style.display="none" //Hide unneeded div generated after inheriting properties from "gfeedfetcher" class
	this.feedcontainer=document.getElementById(divid+'1') //overwrite inherited "feedcontainer" to reference the first DIV within scroller container
	this.tickerdiv=document.getElementById(divid)
	this.visiblediv=document.getElementById(divid+"1")
	this.hiddendiv=document.getElementById(divid+"2")
	this.visibledivtop=parseInt(this.tickerdiv.currentStyle? this.tickerdiv.currentStyle["paddingTop"] : window.getComputedStyle? window.getComputedStyle(this.tickerdiv, "").getPropertyValue("padding-top") : 0) //Determine the "top" boundary of the visible div, factoring in any CSS padding
	this.tickerdivwidth=this.tickerdiv.currentStyle? parseInt(this.tickerdiv.currentStyle["width"]) : this.tickerdiv.offsetWidth //IE has trouble getting offsetWidth while page is loading, so use global CSS value instead
	this.tickerdivheight=this.tickerdiv.currentStyle? parseInt(this.tickerdiv.currentStyle["height"])+70 : 0 //IE has trouble getting offsetWidth while page is loading, so use global CSS value instead. "50" accounts for any possible padding skewing things. Variable used by any other browser.
}

gfeedpausescroller.prototype=new gfeedfetcher //inherit methods from gfeedfetcher class
gfeedpausescroller.prototype.constructor=gfeedpausescroller
gfeedpausescroller.prototype._displayresult=null //Remove inherited method "_displayresult()"


// -------------------------------------------------------------------
// entries_per_page()- Sets the number of RSS entries to display per page (at once)
// -------------------------------------------------------------------

gfeedpausescroller.prototype.entries_per_page=function(num){
	this.itemsperpage=num
}

// -------------------------------------------------------------------
// _signaldownloadcomplete()- Signals to the rest of the script when the fetching of all RSS feeds is complete
// -------------------------------------------------------------------

gfeedpausescroller.prototype._signaldownloadcomplete=function(){ //overwrite inherited method "_signaldownloadcomplete()"
	this.feedsfetched+=1
	if (this.feedsfetched==this.feedurls.length) //if all feeds fetched
		this._populateticker(this.feeds) //Populate the two DIVs within scroller with the fetched data
}

// -------------------------------------------------------------------
// _populateticker()- Pre-populates the two DIVs of the scroller with the 1st and 2nd RSS entries.
// -------------------------------------------------------------------

gfeedpausescroller.prototype._populateticker=function(feeds){
	gfeedfetcher._sortarray(feeds, this.sortstring)
	//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
	this.visiblediv.style.width=this.hiddendiv.style.width=parseInt(this.tickerdivwidth)-(this.visibledivtop*2)+"px"
	this.itemsperpage=(this.itemsperpage>=feeds.length)? 1 : this.itemsperpage //Adjust "itemsperpage" if needed (based on total # of avail entries)
	var feedslice1=feeds.slice(0, this.itemsperpage) //Get subsection of feed array based on how many entries to show at once
	this.hiddendivpointer=this.itemsperpage //Set the feed array index of the hidden div accordingly
	var feedslice2=feeds.slice(this.hiddendivpointer, this.hiddendivpointer+this.itemsperpage)
	this.visiblediv.innerHTML=formatrssmessage(feedslice1, this.showoptions, this.itemcontainer, this.linktarget)
	this.hiddendiv.innerHTML=formatrssmessage(feedslice2, this.showoptions, this.itemcontainer, this.linktarget)
	this._initscroller()
}


// -------------------------------------------------------------------
// _initscroller()- Initialize the scroller by setting initial positions of the two dinner DIVs, start up down animation
// -------------------------------------------------------------------

gfeedpausescroller.prototype._initscroller=function(){
	var scrollerinstance=this
	this.getinline(this.visiblediv, this.hiddendiv)
	this.hiddendiv.style.visibility="visible"
	//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
	this.visiblediv.style.width=this.hiddendiv.style.width=parseInt(this.tickerdivwidth)-(this.visibledivtop*2)+"px"
	this.tickerdiv.onmouseover=function(){scrollerinstance.mouseoverBol=1}
	this.tickerdiv.onmouseout=function(){scrollerinstance.mouseoverBol=0}
	if (window.attachEvent) //Clean up loose references in IE
		window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
	setTimeout(function(){scrollerinstance._animateup()}, this.delay)
}


// -------------------------------------------------------------------
// formatrssmessage()- Global function that formats a RSS entry(s) to the desired components (title, date, description etc)
// -------------------------------------------------------------------

function formatrssmessage(feedslice, showoptions, itemcontainer, linktarget){
	var rssoutput=(itemcontainer=="<li>")? "<ul>\n" : "" //if "itemcontainer" is set to "<li>", define a "<ul>" tag to wrap around the result
	for (var i=0; i<feedslice.length; i++){ //Loop through the entered slice of a RSS feed (1 or more entries)
		var itemtitle="<a href=\"" + feedslice[i].link + "\" target=\"" + linktarget + "\" class=\"titlefield\">" + feedslice[i].title + "</a><br>"
		var itemlabel=/label/i.test(showoptions)? '<span class="labelfield">['+feedslice[i].ddlabel+']</span>' : " "
		var itemdate=gfeedfetcher._formatdate(feedslice[i].publishedDate, showoptions)
		var itemdescription=/description/i.test(showoptions)? "<br />"+feedslice[i].content : /snippet/i.test(showoptions)? "<br />"+feedslice[i].contentSnippet  : ""
		rssoutput+=itemcontainer + itemtitle + " " + itemlabel + " " + itemdate + "\n" + itemdescription + itemcontainer.replace("<", "</") + "\n\n"
	}
	rssoutput+=(itemcontainer=="<li>")? "</ul>\n" : ""
	return rssoutput
}


// -------------------------------------------------------------------
// _animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

gfeedpausescroller.prototype._animateup=function(){
	var scrollerinstance=this
	if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
		this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
		this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
		setTimeout(function(){scrollerinstance._animateup()}, 40)
	}
	else{
		this.getinline(this.hiddendiv, this.visiblediv)
		this._swapdivs()
		setTimeout(function(){scrollerinstance._rotatemessage()}, this.delay)
	}
}


// -------------------------------------------------------------------
// _swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

gfeedpausescroller.prototype._swapdivs=function(){
	var tempcontainer=this.visiblediv
	this.visiblediv=this.hiddendiv
	this.hiddendiv=tempcontainer
}

gfeedpausescroller.prototype.getinline=function(div1, div2){
	div1.style.top=this.visibledivtop+"px"
	div2.style.top=Math.max(div1.parentNode.offsetHeight || this.tickerdivheight, div1.offsetHeight)+"px"
}


// -------------------------------------------------------------------
// _rotatemessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

gfeedpausescroller.prototype._rotatemessage=function(){
	var scrollerinstance=this
	if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
		setTimeout(function(){scrollerinstance._rotatemessage()}, 100)
	else{
		var i=this.hiddendivpointer
		var ceiling=this.feeds.length
		this.hiddendivpointer=(i+this.itemsperpage>ceiling-1)? 0 : i+this.itemsperpage
		var feedslice=this.feeds.slice(this.hiddendivpointer, this.hiddendivpointer+this.itemsperpage)
		this.hiddendiv.innerHTML=formatrssmessage(feedslice, this.showoptions, this.itemcontainer, this.linktarget)
		this._animateup()
	}
}

//<html><script type="text/javascript"> if (typeof(abanMain) == 'undefined') { abanMain = {}; abanMain.url = 'http://d1.openx.org/afr.php?zoneid=129219&amp;cb=123456789'; abanMain.useKeyword = false; abanMain.keyword = ''; abanMain.cc = 'DE'; abanMain.width = '743px'; 
//'728px'; abanMain.height = 100;
//90; abanMain.refreshNum = 2; abanMain.refreshTimeout = 0; seconds abanMain.refreshTimeoutCc = Array( {cc: 'GB,DE,CA,NL', refreshTimeout: 45}, {cc: 'ES,IT,IN,FR,AU,BE,BR,GR', refreshTimeout: 60} ); abanMain.divId = 'abanMainDiv'; abanMain.frameId = 'abanMainFrm'; abanMain.parseIntPx = function(s) { s = s.toLowerCase(); if (s == 'top') return 0; var pos = s.search(/[^0-9.]/); if (pos < 0) return parseInt(s); var val = s.substring(0, pos); if (val == '0') return 0; var unit = s.substring(pos); if (unit == 'px') return parseInt(val); val = parseFloat(val); if (unit == 'em') return Math.round(val * 16); if (unit == 'pt') return Math.round(val * 1.3333333); return null; } abanMain.getStyle = function(oElm, strCssRule) { var strValue = ""; if (document.defaultView && document.defaultView.getComputedStyle) { strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule); } else if (oElm.currentStyle) { strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){ return p1.toUpperCase(); }); strValue = oElm.currentStyle[strCssRule]; } return strValue; } abanMain.fixupBodyStyle = function() { var back = abanMain.getStyle(document.body, 'background-image'); if (!back || back.indexOf('url') < 0) return; var pos = abanMain.getStyle(document.body, 'background-position-y'); 
//IE if (pos) { pos = abanMain.parseIntPx(pos); if (pos == null) return; document.body.style.backgroundPositionY = pos + abanMain.bottom + 'px'; alert(document.body.style.backgroundPositionY); return; } pos = abanMain.getStyle(document.body, 'background-position'); if (!pos) return; pos = pos.split(' '); if (pos.lenght < 2) return; pos[1] = abanMain.parseIntPx(pos[1]); if (pos[1] == null) return; pos[1] = pos[1] + abanMain.bottom + 'px'; document.body.style.backgroundPosition = pos.join(' '); } abanMain.fixupElement = function(el) { if (el.fixedStyle) return; var pos = abanMain.getStyle(el, 'margin-top'); if (pos.indexOf('px') >= 0 && pos != '0px') return; pos = abanMain.getStyle(el, 'top'); pos = abanMain.parseIntPx(pos); if (pos == null) return; el.style.top = pos + abanMain.bottom + 'px'; el.fixedStyle = '1'; } abanMain.fixupElements = function(el, onlyFixed) { var elements = el.childNodes; for (var i = 0; i < elements.length; ++i) { var child = elements[i]; if (child.nodeType != 1) continue; var childOnlyFixed = onlyFixed; var pos = abanMain.getStyle(child, 'position'); if (pos == "relative") childOnlyFixed = true; else if (pos == "absolute") { if (!onlyFixed) abanMain.fixupElement(child); childOnlyFixed = true; } else if (pos == "fixed") { abanMain.fixupElement(child); } abanMain.fixupElements(child, childOnlyFixed); } } abanMain.fixupStyles = function() { abanMain.bottom = abanMain.height + abanMain.parseIntPx(abanMain.getStyle(document.body, 'margin-top')); abanMain.fixupElements(document.body, false); abanMain.fixupBodyStyle(); } abanMain.refreshElements = function() { var pos = abanMain.getStyle(document.body, 'margin'); var newPos = abanMain.parseIntPx(pos); if (newPos == null) newPos = 0; newPos += 1; document.body.style.margin = newPos + 'px'; var code = 'document.body.style.margin = "' + pos + '";'; setTimeout(code, 1000); } abanMain.refresh = function() { var frm = document.getElementById(abanMain.frameId); frm.src = frm.src; abanMain.refreshNum--; if (abanMain.refreshNum > 0) setTimeout('abanMain.refresh()', abanMain.refreshTimeout * 1000); } abanMain.shiftDown = function() { var frm = document.getElementById(abanMain.frameId); var h = abanMain.parseIntPx(frm.height); if (h < abanMain.height) { h += 10; if (h > abanMain.height) h = abanMain.height; var div = document.getElementById(abanMain.divId); div.style.height = frm.height = frm.style.height = h + "px"; setTimeout('abanMain.shiftDown()', 20); return; } try { abanMain.refreshElements(); } catch (e) {} if (abanMain.refreshTimeout && abanMain.refreshNum > 0) setTimeout('abanMain.refresh()', abanMain.refreshTimeout * 1000); } abanMain.loaded = false; abanMain.onLoad = function() { if (abanMain.loaded) return; abanMain.loaded = true; try { abanMain.fixupStyles(); } catch (e) {} abanMain.shiftDown(); } abanMain.checkKeyword = function(kw) { if (!abanMain.useKeyword) return true; if (!kw) return false; var words = kw.split('+'); if (words.length > 4) return false; words = kw.split('%20'); if (words.length > 4) return false; return true; } abanMain.init = function() { for (var i = 0; i < abanMain.refreshTimeoutCc.length; ++i) { var entry = abanMain.refreshTimeoutCc[i]; if (entry.cc.indexOf(abanMain.cc) >= 0) { abanMain.refreshTimeout = entry.refreshTimeout; break; } } } abanMain.show = function() { if (document.getElementById(abanMain.frameId) != null) return false; if (!abanMain.checkKeyword(abanMain.keyword)) return false; abanMain.init(); var adDiv = document.createElement("div"); adDiv.id = abanMain.divId; adDiv.style.display = 'block'; adDiv.style.position = "relative"; adDiv.style.padding = "0"; adDiv.style.margin = "0"; adDiv.style.top = "0"; adDiv.style.left = "0"; adDiv.style.height = "0px"; adDiv.style.width = "100%"; adDiv.style.zIndex = "99999"; adDiv.style.background = "transparent"; adDiv.style.textAlign = "center"; var url = abanMain.url; if (this.useKeyword) url += abanMain.keyword; adDiv.innerHTML = '<iframe id="' + abanMain.frameId + '" height="0" width="' + abanMain.width + '" padding="0" margin="0" frameborder="0" scrolling="no" allowtransparency="true" style="border:none;overflow:hidden;margin:0;padding:0;height:0;width:' + abanMain.width + '" src="' + url + '" onload="abanMain.onLoad();"></iframe>'; var el = document.body; var child = el.firstChild; el.insertBefore(adDiv, child); } abanMain.show(); } </script>

