function formatrssmessage(divid, msgnumber, linktarget, logicswitch){
var rsscontent=rsscontentdata[divid][msgnumber]
var linktitle='<a target="_blank" href="'+unescape(rsscontent.link)+'" class="titlu_stire" target="'+linktarget+'">'+unescape(rsscontent.title)+'</a>'
var description='<div class="text_stire">'+unescape(rsscontent.description)+'</div>'
var feeddate='<span class="data_creare_stire">'+unescape(rsscontent.date)+'</span>'
if (logicswitch.indexOf("description")!=-1 && logicswitch.indexOf("date")!=-1)
return linktitle+"<br />"+feeddate+description
else if (logicswitch.indexOf("description")!=-1)
return linktitle+"<br />"+description
else if (logicswitch.indexOf("date")!=-1)
return linktitle+"<br />"+feeddate
else
return linktitle
}

var rsscontentdata=new Array()

function incarca_stiri_noi(){
var divId = "panoustiri";
var divClass = "clasastiri";
var delay = 3000;
var linktarget = "";
var logicswitch = "date+description";

this.tickerid=divId
this.delay=delay
this.linktarget=(typeof linktarget!="undefined")? linktarget : ""
this.logicswitch=(typeof logicswitch!="undefined")? logicswitch : ""
this.mouseoverBol=0
this.hiddendivpointer=1
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">Se incarca...</span></div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2"></div></div>')
if (document.getElementById){

var parameters="divid="+divId+"&bustcache="+new Date().getTime()
incarca_stiri_noi.getRSScontentJS("http://incarca-stiri.ziarulimobiliar.ro/get.php?"+parameters)
this.do_onjsload()
}
}

incarca_stiri_noi.prototype.do_onjsload=function(){
var scrollerinstance=this
if (typeof rsscontentdata[this.tickerid]=="undefined" && this.number_of_tries<40){
this.number_of_tries++
setTimeout(function(){scrollerinstance.do_onjsload()}, 200)
}

else if (typeof rsscontentdata[this.tickerid]!="undefined"){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(incarca_stiri_noi.getCSSpadding(this.tickerdiv))

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 />Stirile nu au putut fi incarcate."
}

incarca_stiri_noi.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()
}


incarca_stiri_noi.prototype.initialize=function(){
var scrollerinstance=this
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"

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)
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}

incarca_stiri_noi.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)
}
}

incarca_stiri_noi.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

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

incarca_stiri_noi.prototype.rotatemessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1)
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()
}
}

incarca_stiri_noi.getRSScontentJS=function(scripturl){
var scriptref=document.createElement('script')
scriptref.setAttribute("type","text/javascript")
scriptref.setAttribute("src", scripturl)
document.getElementsByTagName("head").item(0).appendChild(scriptref)
}

incarca_stiri_noi.getCSSpadding=function(tickerobj){
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle)
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}