/********************************************************************************
This script is made by and copyrighted to Thomas Brattli at www.bratta.com
Visit for more great scripts.
This may be used freely as long as this msg is intact!
********************************************************************************
Browsercheck:*/
//ie=document.all?1:0
ie=browser.ie;
//n=document.layers?1:0
n=browser.ns;
//alert(browser.info);

/********************************************************************************
Here are the variables you must set: (this is the only part you have to change)

Remember tho, if you wan't different size for the layers, different clip or anything
change that in the stylesheet.
*/

//The delay between the fades (in milliseconds) smaller value gives less time:
betweendelay=2000

//Do you wan't it to start over on the first one when it's gone trought all the news?
//(set to 0 if not)
var loop=1

//What font do you wan't it use?
FontFace='Fantasy,arial,helvetiva'

//What font-size (in pixel)?
FontSize=18

//Do you wan't it to fade out aswell? 1 for on, 0 for off
fadeback=1

speed1 = 150

//Set the colors, first color is same as background, last color is the color it stops at:
//You can have upto 7 colors, set the ones you wan't use to 0
colors=new Array()
colors[0]='#FFFFFF'
colors[1]='#FBBE00'
colors[2]='#E6AE05'
colors[3]='#C79605'
colors[4]='#936F03'
colors[5]='#604902'
colors[6]='#342701'

var tWidth = 50;

/*Dont change anything below this!
*********************************************************************************/
function fadeInit ()
{
    if (document.body.clientWidth < 1000) {document.getElementById('divBIP').style.display='none';document.getElementById('divCont').style.display='none';document.getElementById('divBIP2').style.display='none'; return;}
    oNews=new makeObj('divNews','divCont');
    fadeNews(0);
}
function makeObj(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
    this.css= document.getElementById(obj).style;
    this.writeref=document.getElementById(obj);
    this.fadeIt=b_fadeIt
    this.obj = obj + "Object"; 	eval(this.obj + "=this")
}
function b_fadeIt(text,link,font,size,speed,fn,num,c0,c1,c2,c3,c4,c5,c6){
    if(num<arguments.length && arguments[num]!=0){
        txt=text; tt='';
        if (document.body.clientWidth < 1200) {for (i=0; i<=txt.length-1; i++){tt = tt + text.substring(i,i+1)+'<br />'; } txt=tt;}
        //if (text.toLowerCase().indexOf('do odwiedzin') != -1)
        //{
        //    txt = text.substring(0,text.toLowerCase().indexOf('do odwiedzin'))
        //    + '<span style=\" cursor:pointer;\" onclick=\"BeforeSubmit(-1,0,\'admin.php\');\">do</span>'
        //    + text.substring(text.toLowerCase().indexOf('do odwiedzin')+2);
        //}
		writetext='<span style="text-decoration:none; font-size:'+size+'px">'
		+'<font face="'+font+'" color="'+arguments[num]+'">'+txt+'</font></span>'
        this.writeref.innerHTML=writetext;
		num++
		setTimeout(this.obj+'.fadeIt("'+text+'","'+link+'","'+font+'",'+size+','+speed+',"'
		+fn+'",'+num+',"'+c0+'","'+c1+'","'+c2+'","'+c3+'","'+c4+'","'+c5+'","'+c6+'")',speed)
	}else setTimeout('eval('+fn+')',betweendelay)
}
function fadeNews(num){
	if(num<news.length){
		fn=fadeback?'fadeBack('+num+')':'fadeNews('+(num+1)+')';
		oNews.fadeIt(news[num]["text"],news[num]["link"],FontFace,FontSize,speed1,fn,7,
		colors[0],colors[1],colors[2],colors[3],colors[4],colors[5],colors[6])
	}else if(loop)fadeNews(0)
}
function fadeBack(num){
	if(num>=0){
		oNews.fadeIt(news[num]["text"],news[num]["link"],FontFace,FontSize,speed1,'fadeNews('+(num+1)
		+')',7,colors[6],colors[5],colors[4],colors[3],colors[2],colors[1],colors[0])
	}
}
onload=fadeInit;
//alert(document.body.clientWidth);
//
/*End of fadescript
**********************************************************************************/

function getposOffset(ch, t)
{
    var totaloffset=(t=='top')? ch.offsetTop : ch.offsetLeft;
    var offParent=ch.offsetParent;
    while (offParent!=null){
	    if(t=='left'){
		    totaloffset=totaloffset+offParent.offsetLeft;
	    } else {
		    totaloffset=totaloffset+offParent.offsetTop;
	    }
	    offParent=offParent.offsetParent;
    }
    return totaloffset;
}
