<script>// CREDITS:
// Floating and fadeing message boxes
// Peter Gehrig
// Copyright (c) 2010 Peter Gehrig. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.fabulant.com
// IMPORTANT:
// If you add this script to a script-library or script-archive
// you have to add a highly visible link to
// http://www.fabulant.com on the webpage
// where this script will be featured
// CONFIGURATION:
// Go to http://www.fabulant.com
// and create your own text animation
// with our new Text Factory.
var text=new Array()
var textlink=new Array()
var texttarget=new Array()
var textsplashcolors=new Array()
/////////////////////////////////////////////////////////////////////
// EDIT VALUES BELOW THIS LINE
// Add or delete as many floating message boxes as you like.
// Just proceed as shown below (this sample creates three message boxes)
// Set the text, link and the target for your first floating message box
text[0]="Hello you"
textlink[0]="http://www.fabulant.com"
texttarget[0]="_blank"
// Set the text, link and the target for the second floating message box
text[1]="Welcome"
textlink[1]="http://www.google.com"
texttarget[1]="_blank"
// Set the text, link and the target for the third floating message box
text[2]="Have a nice time"
textlink[2]="http://www.yahoo.com"
texttarget[2]="_blank"
// Set the font
var textfont="Arial"
// Set the font-weight to "bold" or "normal"
var textweight="normal"
// Set the rollover-color
var textfontcolorrollover="#ff0000"
// Set the font-size
var textfontsize=10
// Set the font-color
var textfontcolor="#000000"
// Set the background-color
var textbgcolor="#dddddd"
// Set the border-color
var textbordercolor="#ff9000"
// Set the border-width
var textborder=2
// Speed. Higher is faster
var floatingspeed=2
// DO NOT EDIT VALUES BELOW THIS LINE
/////////////////////////////////////////////////////////////////////
var textdecoration="none"
var textfontsizeHTML=3
var textweightA="<b>"
var textweightB="</b>"
var textitalic="normal"
var textitalicA=""
var textitalicB=""
var textredirurl="http://"
var textalign="center"
var textvalign="middle"
var ns4=document.layers?1:0
var ns6=document.getElementById&&!document.all?1:0
var ie=document.all?1:0
var tempo=20
var numberofmessages=text.length-1
var stepx=new Array()
var stepy=new Array()
var spancontent=new Array()
for (i=0;i<=numberofmessages;i++) {
stepx=randommaker(floatingspeed)
stepy=randommaker(floatingspeed)
}
var boxwidth=new Array()
var boxheight=new Array()
for (i=0;i<=numberofmessages;i++) {
boxwidth=10
boxheight=10
}
var x,y
var marginbottom
var marginleft=0
var margintop=0
var marginright
var timer
var i_fadestrength=new Array()
var i_fadestep=new Array()
var i_fadenow=new Array()
var i_fadenowmax=new Array()
for (i=0;i<=text.length;i++) {
i_fadenowmax=randommaker(10)+2
i_fadestrength=randommaker(99)
i_fadestep=1
i_fadenow=0
}
getcontent()
function getcontent() {
for (i=0;i<=numberofmessages;i++) {
var content=""
if (ie || ns6) {
content="<table cellpadding="+textborder+" cellspacing=0 border=0><tr valign="+textvalign+"><td align="+textalign+">"
content+="<a href=\""+textlink+"\" target=\""+texttarget+"\" style=\"position:relative;font-family:\'"+textfont+"\';font-size:"+textfontsize+"pt;font-weight:"+textweight+";text-decoration:"+textdecoration+";color:"+textfontcolor+";font-style:"+textitalic+";\" onMouseOver=\"this.style.color=\'"+textfontcolorrollover+"\'\" onMouseOut=\"this.style.color=\'"+textfontcolor+"\'\">"
content+=text
content+="</a></td></tr></table>"
}
else {
content="<table cellpadding="+textborder+" cellspacing=0 bgcolor="+textbgcolor+" border="+textborder+"><tr valign="+textvalign+"><td align="+textalign+">"
content+="<a href=\""+textlink+"\" target=\""+texttarget+"\">"
content+=textweightA
content+=textitalicA
content+="<font face=\""+textfont+"\" size="+textfontsizeHTML+" color=\""+textfontcolor+"\">"
content+=text
content+="</font>"
content+=textitalicB
content+=textweightB
content+="</a></td></tr></table>"
}
spancontent=content
}
}
function setValues() {
if (ie) {
marginbottom=document.body.clientHeight-5
marginright=document.body.clientWidth-5
for (i=0;i<=numberofmessages;i++) {
var thisspan = eval("document.all.span"+i)
thisspan.innerHTML=spancontent
var thisspan = eval("document.all.span"+i)
boxwidth=thisspan.offsetWidth
boxheight=thisspan.offsetHeight
var maxleftstart=marginright-boxwidth
var maxtopstart=marginbottom-boxheight
var thisspan = eval("document.all.span"+(i)+".style")
thisspan.posLeft=randommaker(maxleftstart)
thisspan.posTop=randommaker(maxtopstart)
}
checkmovement()
}
if (ns4) {
marginbottom=window.innerHeight-5
marginright=window.innerWidth-5
for (i=0;i<=numberofmessages;i++) {
var thisspan=eval("document.span"+i+".document")
thisspan.write(spancontent)
thisspan.close()
var thisspan=eval("document.span"+i+".document")
boxwidth=thisspan.width
boxheight=thisspan.height
var maxleftstart=marginright-boxwidth
var maxtopstart=marginbottom-boxheight
var thisspan=eval("document.span"+i)
thisspan.left=randommaker(maxleftstart)
thisspan.top=randommaker(maxtopstart)
}
checkmovement()
}
if (ns6) {
marginbottom=window.innerHeight-11
marginright=window.innerWidth-11
for (i=0;i<=numberofmessages;i++) {
var thisspan=document.getElementById('span'+i)
thisspan.innerHTML=spancontent
var thisspan=document.getElementById('span'+i)
boxwidth=parseInt(thisspan.offsetWidth)
boxheight=parseInt(thisspan.offsetHeight)
var maxleftstart=marginright-boxwidth
var maxtopstart=marginbottom-boxheight
var thisspan=document.getElementById('span'+i).style
thisspan.left=parseInt(thisspan.left)+randommaker(maxleftstart)
thisspan.top=parseInt(thisspan.top)+randommaker(maxtopstart)
}
checkmovement()
}
}
function randommaker(range) {
rand=Math.floor(range*Math.random())
if (rand==0) {rand=Math.ceil(range/2)}
return rand
}
function checkmovement() {
checkposition()
movepictures()
timer=setTimeout("checkmovement()",tempo)
}
function movepictures() {
if (ie) {
for (i=0;i<=numberofmessages;i++) {
var thisspan=eval("document.all.span"+(i)+".style")
thisspan.posLeft+=stepx
thisspan.posTop+=stepy
var thisfilter=eval("span"+i)
i_fadenow++
if (i_fadenow>=i_fadenowmax) {
i_fadenow=0
if (i_fadestrength>=100) {i_fadestep=i_fadestep*-1}
else if (i_fadestrength<=-20) {i_fadestep=i_fadestep*-1}
}
i_fadestrength+=i_fadestep
thisfilter.filters.alpha.opacity=Math.round(i_fadestrength)
}
}
if (ns6) {
for (i=0;i<=numberofmessages;i++) {
var thisspan=document.getElementById('span'+i).style
thisspan.left=parseInt(thisspan.left)+stepx
thisspan.top=parseInt(thisspan.top)+stepy
i_fadenow++
if (i_fadenow>=i_fadenowmax) {
i_fadenow=0
if (i_fadestrength>=100) {i_fadestep=i_fadestep*-1}
else if (i_fadestrength<=-20) {i_fadestep=i_fadestep*-1}
}
i_fadestrength+=i_fadestep
document.getElementById('span'+i).style.opacity=Math.round(i_fadestrength)/100
}
}
if (ns4) {
for (i=0;i<=numberofmessages;i++) {
var thisspan = eval("document.span"+i)
thisspan.left+=stepx
thisspan.top+=stepy
}
}
}
function checkposition() {
if (ie) {
for (i=0;i<=numberofmessages;i++) {
var thisspan=eval("document.all.span"+i+".style")
if (thisspan.posLeft>marginright-boxwidth-floatingspeed) {
thisspan.posLeft-=Math.abs(stepx+1)
stepx=randommaker(floatingspeed)*-1
}
if (thisspan.posLeft<marginleft) {
thisspan.posLeft+=Math.abs(stepx)
stepx=randommaker(floatingspeed)
}
if (thisspan.posTop>marginbottom-boxheight-floatingspeed) {
thisspan.posTop-=Math.abs(stepy)
stepy=randommaker(floatingspeed)*-1
}
if (thisspan.posTop<margintop) {
thisspan.posTop+=Math.abs(stepy)
stepy=randommaker(floatingspeed)
}
}
}
if (ns4) {
for (i=0;i<=numberofmessages;i++) {
var thisspan=eval("document.span"+i)
if (thisspan.left>marginright-boxwidth-floatingspeed) {
thisspan.left-=Math.abs(stepx+1)
stepx=randommaker(floatingspeed)*-1
}
if (thisspan.left<marginleft) {
thisspan.left+=Math.abs(stepx)
stepx=randommaker(floatingspeed)
}
if (thisspan.top>marginbottom-boxheight-floatingspeed) {
thisspan.top-=Math.abs(stepy)
stepy=randommaker(floatingspeed)*-1
}
if (thisspan.top<margintop) {
thisspan.top+=Math.abs(stepy)
stepy=randommaker(floatingspeed)
}
}
}
if (ns6) {
for (i=0;i<=numberofmessages;i++) {
var thisspan=document.getElementById('span'+i).style
var leftx=parseInt(thisspan.left)
var topy=parseInt(thisspan.top)
if (leftx>marginright-boxwidth-floatingspeed) {
thisspan.left=leftx-Math.abs(stepx+1)
stepx=randommaker(floatingspeed)*-1
}
if (leftx<marginleft) {
thisspan.left=leftx+Math.abs(stepx)
stepx=randommaker(floatingspeed)
}
if (topy>marginbottom-boxheight-floatingspeed) {
thisspan.top=topy-Math.abs(stepy)
stepy=randommaker(floatingspeed)*-1
}
if (topy<margintop) {
thisspan.top=topy+Math.abs(stepy)
stepy=randommaker(floatingspeed)
}
}
}
}
if (ie || ns6) {
for (i=0;i<=numberofmessages;i++) {
document.write("<span id='span"+i+"' style='position:absolute;top:0px;left:0px;filter:alpha(opacity=0);opacity:0;border-style:solid;border-color:"+textbordercolor+";border-width:"+textborder+"px;background-color:"+textbgcolor+";'></span>")
document.close()
}
}
if (ns4) {
for (i=0;i<=numberofmessages;i++) {
document.write("<layer name='span"+i+"' left=0 top=0>"+spancontent+"</layer>")
document.close()
}
}
window.onload=setValues
</script>