//URL to "scrollerbridge.php" on your server:
var bridgepath="http://www.gay.it/webmasters/lastrss/scrollerbridge.php"


/*
======================================================================
Pausing RSS scroller JavaScript engine- © Dynamic Drive (http://www.dynamicdrive.com)
Docs: http://www.dynamicdrive.com/dynamicindex17/rsspausescroller/
Last modified: March 16th, 2006.
======================================================================
*/

//Advanced users: Edit below function to format the RSS feed output as desired
//formatrssmessage(divid, message_index_within_array, linktarget, logicswitch)

function formatrssmessage(divid, msgnumber, linktarget, logicswitch){
var rsscontent=rsscontentdata[divid][msgnumber]
var linktitle='<span class="rsstitle"><a href="'+unescape(rsscontent.link)+'" target="'+linktarget+'">'+unescape(rsscontent.title)+'</a></span>'
var description='<div class="rssdescription"><a style="font-weight:normal;" href="'+unescape(rsscontent.link)+'" target="'+linktarget+'">'+unescape(rsscontent.description)+'</a></div>'
var feeddate='<span class="rssdate">'+unescape(rsscontent.date)+'</span>'
if (logicswitch.indexOf("description")!=-1 && logicswitch.indexOf("date")!=-1) //Logic switch- Show description and date
return linktitle+"<br />"+feeddate+description
else if (logicswitch.indexOf("description")!=-1) //Logic switch- Show just description
return linktitle+"<br />"+description
else if (logicswitch.indexOf("date")!=-1) //Logic switch- Show just date
return linktitle+"<br />"+feeddate
else
return linktitle //Default- Just return hyperlinked RSS title
}

//////NO NEED TO EDIT BEHIND HERE///////////////////////////

var rsscontentdata=new Array() //global array to hold RSS feeds contents

//rsspausescroller(RSS_id, divId, divClass, delay, linktarget, optionalswitch)

function rsspausescroller(RSS_id, divId, divClass, delay, linktarget, logicswitch){
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.linktarget=(typeof linktarget!="undefined")? linktarget : ""
this.logicswitch=(typeof logicswitch!="undefined")? logicswitch : ""
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
this.js_is_loaded=0
this.number_of_tries=0
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1"><span style="position: absolute">Initializing RSS scroller...</span></div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2"></div></div>')
if (document.getElementById){ //perform basic DOM browser support
var parameters="id="+encodeURIComponent(RSS_id)+"&divid="+divId+"&bustcache="+new Date().getTime()
rsspausescroller.getRSScontentJS(bridgepath+"?"+parameters)
this.do_onjsload()
}
}

// -------------------------------------------------------------------
// do_onjsload()- Checks if external JS containing RSS feed is loaded yet
// -If not, continue to check until yes, or abort after certain tries.
// -------------------------------------------------------------------

rsspausescroller.prototype.do_onjsload=function(){
var scrollerinstance=this
if (typeof rsscontentdata[this.tickerid]=="undefined" && this.number_of_tries<40){ //if JS array holding RSS content not yet loaded
this.number_of_tries++
setTimeout(function(){scrollerinstance.do_onjsload()}, 200) //recheck
}
else if (typeof rsscontentdata[this.tickerid]!="undefined"){ //if JS array has loaded
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(rsspausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIV to outer DIV width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.visiblediv.innerHTML=formatrssmessage(this.tickerid, 0, this.linktarget, this.logicswitch)
this.hiddendiv.innerHTML=formatrssmessage(this.tickerid, 1, this.linktarget, this.logicswitch)
this.do_ondivsinitialized()
}
else
document.getElementById(this.tickerid).innerHTML=rsscontentdata+"<br />I give up trying to fetch RSS feed."
}

// -------------------------------------------------------------------
// do_ondivsinitialized()- Checks if two divs of scroller is each populated with RSS message yet
// -If not, continue to check until yes, or abort after certain tries.
// -------------------------------------------------------------------

rsspausescroller.prototype.do_ondivsinitialized=function(){
var scrollerinstance=this
if (parseInt(this.visiblediv.offsetHeight)==0 || parseInt(this.hiddendiv.offsetHeight)==0)
setTimeout(function(){scrollerinstance.do_ondivsinitialized()}, 100)
else
this.initialize()
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

rsspausescroller.prototype.initialize=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=this.tickerdiv.offsetWidth-(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)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------


rsspausescroller.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()}, 50)
}
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
// -------------------------------------------------------------------

rsspausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

rsspausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// rotatemessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

rsspausescroller.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=rsscontentdata[this.tickerid].length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=formatrssmessage(this.tickerid, this.hiddendivpointer, this.linktarget, this.logicswitch)
this.animateup()
}
}

// -------------------------------------------------------------------
// getRSScontentJS()- Fetch RSS feed as external JavaScript
// -------------------------------------------------------------------

rsspausescroller.getRSScontentJS=function(scripturl){
var scriptref=document.createElement('script')
scriptref.setAttribute("type","text/javascript")
scriptref.setAttribute("src", scripturl)
document.getElementsByTagName("head").item(0).appendChild(scriptref)
}


rsspausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}

/*
=========================================================================
Box personalizzabile per ricevere le notizie sempre aggiornate da Gay.It 
=========================================================================
*/

function stampaHeaderBox(forma, bgcolor, bordercolor, textcolor) {
	
	if (forma == 'ticker') {
		codice = '<script type="text/javascript" src="http://wwww.gay.it/webmasters/rsspausescroller.js"></script><script type="text/javascript"> new stampaHeaderBox("ticker", "#FFFFFF", "#696969", "#000000"); </script><script type="text/javascript"> new rsspausescroller("gayit1", "ticker", "rssclass", 5000, "_blank", "description");</script><script type="text/javascript"> new stampaFooterBox("ticker", "#FFFFFF", "#696969", "#000000"); </script>';
		document.write('<style type="text/css">#ticker {width: 360px; height: 20px;	padding: 3px; background-color: ' + bgcolor + '; margin: 0px 0; text-align:left; } #box { width: 250px; height: 90px; border: 0; padding: 5px; background-color: ' + bgcolor + ';	margin: 0px; text-align: left; font-size: 11px; } .rssclass .rssdate { color: gray; } .rsstitle {	background-color: ' + bgcolor + '; font-size: 12px; font-weight: bold; margin: 4px 0; } .rssclass a { color: ' + textcolor + '; text-decoration: none; } </style> <script type="text/javascript" src="http://www.gay.it/webmasters/rsspausescroller.js"></' + 'script> <br><TABLE style="border: ' + bordercolor + ' 1px solid; background-color: ' + bgcolor + ';" align="center" rules="all" bordercolor="' + bordercolor + '"  cellpadding="0" cellspacing="0" style="height:28px" width="100">	<TR style=" background-color:#E3E1E2; border:0;">	<TD style=" background-color: ' + bgcolor + ';  border:0; border-right: ' + bordercolor + ' 1px solid;" valign="middle"><a href="http://www.gay.it" target="_blank" title="Gay.it :: be yourself"><IMG SRC="http://www.gay.it/webmasters/logo_gayit.jpg" BORDER="0" HEIGHT="28" ALT="Gay.it :: Il primo media gay e lesbico italiano"></a></TD><TD  valign="middle" style=" width:240; background-color: ' + bgcolor + '; border:0; border-right: ' + bordercolor + ' 1px solid; " align="left" valign="top"><div id="embed" class="invisibile" style="position:absolute; background-color:#CCCCCC; width:366px; height:22px; z-index:2; border:0; margin:0;"><form name="f"><nobr>&nbsp;&nbsp;<span style="font-family:Verdana; font-size:9px; color:#787878;"><b>copia e incolla il codice</b></span> <textarea wrap=off name="txt" style="margin-top:3px; height:13px; font-size:11px; width:225px; overflow:hidden;" onclick="selezionatutto();"><script type="text/javascript" src="http://wwww.gay.it/webmasters/rsspausescroller.js"></'+'script><script type="text/javascript"> new stampaHeaderBox("ticker", "#FFFFFF", "#696969", "#000000"); </'+'script><script type="text/javascript"> new rsspausescroller("gayit1", "ticker", "rssclass", 5000, "_blank", "description");</'+'script><script type="text/javascript"> new stampaFooterBox("ticker", "#FFFFFF", "#696969", "#000000"); </'+'script></textarea></nobr></form></div><span style=" background-color: ' + bgcolor + '; color:' + textcolor + '">');
	} else if (forma == 'box') {
		codice = '<script type="text/javascript" src="http://wwww.gay.it/webmasters/rsspausescroller.js"></script><script type="text/javascript"> new stampaHeaderBox("box", "#FFFFFF", "#696969", "#000000"); </script><script type="text/javascript"> new rsspausescroller("gayit1", "box", "rssclass", 5000, "_blank", "description");</script><script type="text/javascript"> new stampaFooterBox("box", "#FFFFFF", "#696969", "#000000"); </script>';
		document.write('<style type="text/css">#ticker {width: 360px; height: 20px;	padding: 3px; background-color: ' + bgcolor + '; margin: 0px 0; text-align:left; } #box { width: 250px; height: 90px; border: 0; padding: 5px; background-color: ' + bgcolor + ';	margin: 0px; text-align: left; font-size: 11px; } .rssclass .rssdate { color: gray; } .rsstitle {	font-size: 12px; font-weight: bold; margin: 4px 0; } .rssclass a { color: ' + textcolor + '; text-decoration: none; } </style> <script type="text/javascript" src="http://www.gay.it/webmasters/rsspausescroller.js"></' + 'script> <br><TABLE style="width:250px; height:124px; border: ' + bordercolor + ' 1px solid; overflow:hidden" align="center" rules="all" bordercolor="' + bordercolor + '"  cellpadding="0" cellspacing="0" >	<TR style=" background-color:#E3E1E2;"> 		<TD style="border:0; " border="0" valign="middle"><table width="100%" cellspacing="0" cellpadding="0"><tr><td align="left"><a href="http://www.gay.it" target="_blank" title="Gay.it :: be yourself"><IMG SRC="http://www.gay.it/webmasters/logo_gayit.jpg" HEIGHT="28" BORDER="0" ALT="Gay.it :: Il primo media gay e lesbico italiano"></a></TD><td align="right" style="border:0" border="0" ><strong><a href="http://www.gay.it/webmasters" target="_blank" title="Vai al sito web" style="font-family:Verdana; font-size:9px; color:#787878; border:0; text-decoration:none; ">&lt;+&gt;</a><br><a href="#" onClick="aComparsa();return false;" title="Scarica il codice" style="font-family:Verdana; font-size:9px; color:#787878; border:0; text-decoration:none;">&lt;embed&gt;</a></strong></td></tr></table></td>	</TR><TR style="border: ' + bordercolor + ';"> <td style="border:0; margin:0; border-top: ' + bordercolor + ' 1px solid;background-color: ' + bgcolor + '; "><div style="height:95px; overflow:hidden; padding:0; margin:0; position:relative;"><div id="embed" class="invisibile" style="border-color:#999999; background-color:#CCCCCC; width:260px; height:33px; margin:0;"><form name="f"><center><span style="font-family:Verdana; font-size:9px; color:#787878;"><b>copia e incolla il codice</b></span><br><textarea name="txt" wrap=off style="height:13px; font-size:11px; width:240px; overflow:hidden;" onclick="selezionatutto();"><script type="text/javascript" src="http://wwww.gay.it/webmasters/rsspausescroller.js"></'+'script><script type="text/javascript"> new stampaHeaderBox("box", "#FFFFFF", "#696969", "#000000"); </'+'script><script type="text/javascript"> new rsspausescroller("gayit1", "box", "rssclass", 5000, "_blank", "description");</'+'script><script type="text/javascript"> new stampaFooterBox("box", "#FFFFFF", "#696969", "#000000"); </'+'script></textarea></center></form></div>');
	}
}

function stampaFooterBox(forma, bgcolor, bordercolor, textcolor) {
	if (forma == 'ticker') {
		document.write('</span></TD><td align="right" style="border:0;" ><strong><a title="Vai al sito web" href="http://www.gay.it/webmasters" target="_blank" style="font-family:Verdana; font-size:9px; color:#787878; border:0; text-decoration:none; ">&lt;+&gt;</a><span style="font-size:9px;"><br>&nbsp;&nbsp;&nbsp;</span><a title="Scarica il codice" onClick="aComparsa();return false;" href="#" style="font-family:Verdana; font-size:9px; color:#787878; border:0; text-decoration:none;">&lt;embed&gt;</a></strong></td></tr></table>');
	} else if (forma == 'box') {
		document.write('</div></TD>	</TR> </TABLE>');
	}
}

function selezionatutto() {
	  txtarea = eval("document.f.txt");
	  txtarea.focus();
	  txtarea.select();
}

function aComparsa() {
   var which = document.getElementById("embed"); 
   if (which.className=="invisibile") { 
      which.className="visibile";
	  selezionatutto();
	  } 
   else { 
		which.className="invisibile";
	}
   return false; } 