// CREDITS:
// Floating Christmas-Scroller with shadow-font and snowing-animation
// by Urs Dudli and Peter Gehrig 
// Copyright (c) 2000 Peter Gehrig and Urs Dudli. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Distributed by http://www.hypergurl.com

// ******************************************************************************

// EDIT THE VARIABLES/VALUES BELOW:

// messages. Add as many messages as you like
var message=new Array()
message[0]="Merry Christmas from Hypergurl.com!"
message[1]="We hope to see you again next year."
message[2]="Have a good time and enjoy life!"

// links of the messages (you need to set up link for each message)
var messageurl=new Array()
messageurl[0]="http://www.hypergurl.com"
messageurl[1]="http://www.hypergurl.com"
messageurl[2]="http://www.hypergurl.com"

// targets of the links  (you need to set up a target for each message)
// accepted values are '_blank' or '_top' or '_parent' or '_self'
// or the name of your target-window (for instance 'main')
var messagetarget=new Array()
messagetarget[0]="_blank"
messagetarget[1]="_blank"
messagetarget[2]="_blank"

// color of the messages
var textcolor="orange"

// color of the message-shadows
var textshadowcolor="blue"

// speed 1: lower means faster
var pause=20

// speed 2: higher means faster
var step=2

// font-size of messages
var fntsize=14

// font-family of messages
var fntfamily="Impact"

// font-weight: 1 means bold, 0 means normal
var fntweight=0

// backgroundcolor of scroller
var backgroundcolor="000000"

// borderwidth of scroller (pixels)
var borderwidth=2

// scroller-distance from the top of your browser-window (pixels)
var topdistance=220

//**********************************************************************************

// DO  NOT EDIT ANYTHING BELOW THIS LINE!!!!
var snowani=new Array("snowani0.gif", "snowani1.gif", "snowani2.gif")
var snowani0=new Image()
snowani0.src="snowani0.gif"
var snowani1=new Image()
snowani1.src="snowani1.gif"
var snowani2=new Image()
snowani2.src="snowani2.gif"
var cellpad=10
var scrollerwidth=220
var scrollerheight=30
var shadowsize=1
var scrollerleft
var scrollertop
var screenwidth
var clipleft,clipright,cliptop,clipbottom
var i_message=0
var i_snowani=0
var timer
var textwidth
var textcontent=""
var textshadowcontent=""
var bgcontent=""
if (fntweight==1) {fntweight="bold"}
else {fntweight="normald"}
topdistance=topdistance+cellpad

function doanimation() {
	if (i_snowani>=3) {i_snowani=0}
	if (document.all) {
		bgcontent="<img src='"+snowani[i_snowani]+"'>"
		bgscroller.innerHTML=bgcontent
	}
	if (document.layers) {
		document.bgscroller.document.snowpic.src=snowani[i_snowani]
	}
	i_snowani++
	var animation_timer=setTimeout("doanimation()",200)
}

function init() {
	doanimation()
	gettextcontent()
	if (document.all) {gettextshadowcontent()}
    if (document.all) {
		screenwidth=document.body.clientWidth
		scrollertop=document.body.scrollTop
		scrollerleft=screenwidth/2-scrollerwidth/2
		text.innerHTML=textcontent
		textshadow.innerHTML=textshadowcontent
		textwidth=text.offsetWidth
		document.all.bgscroller.style.posTop=scrollertop-cellpad+topdistance
        document.all.bgscroller.style.posLeft=scrollerleft-cellpad
		document.all.text.style.posTop=scrollertop+topdistance
        document.all.text.style.posLeft=scrollerleft+scrollerwidth
		document.all.textshadow.style.posTop=scrollertop+shadowsize+topdistance
        document.all.textshadow.style.posLeft=scrollerleft+scrollerwidth+shadowsize
		clipleft=0
		clipright=0
		cliptop=0
		clipbottom=scrollerheight
		document.all.text.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
		document.all.textshadow.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
        scrolltext()
    }
	if (document.layers) {
		screenwidth=window.innerWidth
		scrollertop=pageYOffset
		scrollerleft=screenwidth/2-scrollerwidth/2
		document.text.document.write(textcontent)
		document.text.document.close()

		textwidth=document.text.document.width
		
		document.bgscroller.top=scrollertop-cellpad+topdistance
        document.bgscroller.left=scrollerleft-cellpad
		document.text.top=scrollertop+topdistance
		document.text.left=scrollerleft+scrollerwidth
		
		document.text.clip.left=0
		document.text.clip.right=0
		document.text.clip.top=0
		document.text.clip.bottom=scrollerheight

        scrolltext()
    }
}

function scrolltext() {
    if (document.all) {
		if (document.all.text.style.posLeft>=scrollerleft-textwidth) {
			document.all.text.style.posLeft-=step
			document.all.textshadow.style.posLeft=document.all.text.style.posLeft+shadowsize
			clipright+=step
			if (clipright>scrollerwidth) {
				clipleft+=step
			}
			scrollertop=document.body.scrollTop
			document.all.text.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
			document.all.textshadow.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
			document.all.bgscroller.style.posTop=scrollertop-cellpad+topdistance
			document.all.text.style.posTop=scrollertop+topdistance
			document.all.textshadow.style.posTop=scrollertop+shadowsize+topdistance
			var timer=setTimeout("scrolltext()",pause)
		}
		else {
			changetext()
		}
	}
   if (document.layers) {
		if (document.text.left>=scrollerleft-textwidth) {
			document.text.left-=step
			document.text.clip.right+=step
			if (document.text.clip.right>scrollerwidth) {
				document.text.clip.left+=step
			}
			scrollertop=pageYOffset
			document.bgscroller.top=scrollertop-cellpad+topdistance
			document.text.top=scrollertop+topdistance
			var timer=setTimeout("scrolltext()",pause)
		}
		else {
			changetext()
		}
	}
}

function changetext() {
    i_message++
	if (i_message>message.length-1) {i_message=0}
	gettextcontent()
	if (document.all) {gettextshadowcontent()}
	if (document.all) {
		text.innerHTML=textcontent
		textshadow.innerHTML=textshadowcontent
		textwidth=text.offsetWidth
		
        document.all.text.style.posLeft=scrollerleft+scrollerwidth
		document.all.textshadow.style.posLeft=scrollerleft+scrollerwidth+shadowsize
		clipleft=0
		clipright=0
		document.all.text.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
document.all.textshadow.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
		
        scrolltext()
	}

	if (document.layers) {
   		document.text.document.write(textcontent)
		document.text.document.close()
		textwidth=document.text.document.width

		document.text.left=scrollerleft+scrollerwidth
		document.text.clip.left=0
		document.text.clip.right=0
		
        scrolltext()
	}
}

function gettextcontent() {
	textcontent="<span style='position:relative;font-size:"+fntsize+"pt;font-family:"+fntfamily+";font-weight:"+fntweight+"'>"
	textcontent+="<a href="+messageurl[i_message]+" target="+messagetarget[i_message]+">"
	textcontent+="<nobr><font color="+textcolor+">"+message[i_message]+"</font></nobr></a></span>"
	
}

function gettextshadowcontent() {
	textshadowcontent="<span style='position:relative;font-size:"+fntsize+"pt;font-family:"+fntfamily+";font-weight:"+fntweight+"'>"
	textshadowcontent+="<a href="+messageurl[i_message]+" target="+messagetarget[i_message]+">"
	textshadowcontent+="<nobr><font color="+textshadowcolor+">"+message[i_message]+"</font></nobr></a></span>"
}


window.onresize=init;
window.onload=init;
