// JScript source code
/***********************************************
* Memory Scroller script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var memorywidth="715px" //scroller width
var memoryheight="14px" //scroller height
var memorybgcolor="#DCDFD9" //scroller background
var memorycontent=''
//var memorypadding="1px" //padding applied to the scroller. 0 for non.
//var borderCSS="border: 1px solid black;" //Border CSS, applied to scroller to give border.

var memoryspeed=2 //Scroller speed (larger is faster 1-10)
var pauseit=1 //Pause scroller onMousever (0=no. 1=yes)?

var persistlastviewedmsg=1 //should scroller's position persist after users navigate away (1=yes, 0=no)?
var persistmsgbehavior="onload" //set to "onload" or "onclick".

//Specify the scroller's content (don't delete <nobr> tag)
//Keep all content on ONE line, and backslash any single quotations (ie: that\'s great):
//Specify path to xml file
var xmlsource="./scripts/" + document.title + " quotes.xml"


var combinedcssTable="width:"+(parseInt(memorywidth)+6)+"px;background-color:"+memorybgcolor
var combinedcss="width:"+memorywidth+";height:"+memoryheight+";"

var divonclick=(persistlastviewedmsg && persistmsgbehavior=="onclick")? 'onClick="savelastmsg()" ' : ''
memoryspeed=(document.all)? memoryspeed : Math.max(1, memoryspeed-1) //slow speed down by 1 for NS
var copyspeed=memoryspeed
var pausespeed=(pauseit==0)? copyspeed: 0
var iedom=document.all||document.getElementById
if (iedom)
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-10000px">'+memorycontent+'</span>')

var actualwidth=''
var memoryscroller

//load xml file
if (window.ActiveXObject)
	var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
else if (document.implementation && document.implementation.createDocument)
	var xmlDoc= document.implementation.createDocument("","doc",null);
if (typeof xmlDoc!="undefined"){
	//document.write(tickercontainer)
	xmlDoc.load(xmlsource)
}

//Regular expression used to match any non-whitespace character
var notWhitespace = /\S/

function init_ticker(){
//Cache "messages" element of xml file
tickerobj=xmlDoc.getElementsByTagName("xmlticker")[0]

//REMOVE white spaces in XML file. Intended mainly for NS6/Mozilla

for (var i=0;i<tickerobj.childNodes.length;i++){
	if ((tickerobj.childNodes[i].nodeType == 3)&&(!notWhitespace.test(tickerobj.childNodes[i].nodeValue))) {
	tickerobj.removeChild(tickerobj.childNodes[i])
	i--
	}

}
//document.getElementById("container").innerHTML=tickerobj.childNodes[1].firstChild.nodeValue
msglength=tickerobj.childNodes.length
currentmsg=2
themessage=''
memorycontent='<span style="font: 11px Arial; font-weight: bold;">'
getAllMessages();
memorycontent+='</span>'
populatescroller();
actualwidth = tickerobj.childNodes[0].firstChild.nodeValue

//setInterval("rotatemsg()",tickerobj.childNodes[0].firstChild.nodeValue);
}
function getAllMessages(){
	for(var i=1; i<msglength - 1; i++){
	themessage=''
	var msgsobj=tickerobj.childNodes[currentmsg]
	if (msgsobj.getAttribute("url")!=null){
		themessage='<a href="'+msgsobj.getAttribute("url")+'"'
		if (msgsobj.getAttribute("target")!=null)
			themessage+=' target="'+msgsobj.getAttribute("target")+'"'
		themessage+='>'
	}
	
	themessage+="\"" + msgsobj.firstChild.nodeValue + "\""
	if (msgsobj.getAttribute("url")!=null)
		themessage+='</a>'
	
	memorycontent+= themessage + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
	currentmsg++
	
	}

}
function rotatemsg(){
	
	var msgsobj=tickerobj.childNodes[currentmsg]
	if (msgsobj.getAttribute("url")!=null){
		themessage='<a href="'+msgsobj.getAttribute("url")+'"'
	if (msgsobj.getAttribute("target")!=null)
		themessage+=' target="'+msgsobj.getAttribute("target")+'"'
		themessage+='>'
	}
	themessage+=msgsobj.firstChild.nodeValue
	if (msgsobj.getAttribute("url")!=null)
		themessage+='</a>'
	
	//Rotate msg and display it in DIV:
	//document.getElementById("container").innerHTML=themessage
	memorycontent='<span style="font: 11px Arial">' + themessage + '</span>'
	//document.write(memorycontent);
	currentmsg=(currentmsg<msglength-1)? currentmsg+1 : 1
	themessage=''
	

}

function fetchxml(){

	if (xmlDoc.readyState==4){

		init_ticker()

	}
	else
		setTimeout("fetchxml()",10)
}


/*
if (window.addEventListener)
window.addEventListener("load", populatescroller, false)
else if (window.attachEvent)
window.attachEvent("onload", populatescroller)
else if (document.all || document.getElementById)
window.onload=populatescroller
*/

if (iedom){
	with (document){
		document.write('<table border="0" cellspacing="0" cellpadding="0" style="'+combinedcssTable+'"><td>')
		write('<div style="position:relative;overflow:hidden;'+combinedcss+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=memoryspeed">')
		write('<div id="memoryscroller" style="position:absolute;left:0px;top:0px;" '+divonclick+'></div>')
		write('</div>')
		document.write('</td></table>')
	}
}
//var memorycontent='<nobr><span style="font: 11px Arial">Thank you for visiting <a href="http://www.familiesleadingplanning.co.uk/">Families Leading Planning.</a></span></nobr>'
if (window.ActiveXObject)
	fetchxml()
else if (typeof xmlDoc!="undefined")
	xmlDoc.onload=init_ticker
////NO NEED TO EDIT BELOW THIS LINE////////////
//var combinedcssTable="width:"+(parseInt(memorywidth)+6)+"px;background-color:"+memorybgcolor+";padding:"+memorypadding+";"+borderCSS+";"



function populatescroller(){
memoryscroller=document.getElementById? document.getElementById("memoryscroller") : document.all.memoryscroller
memoryscroller.style.left=parseInt(memorywidth)+8+"px"
if (persistlastviewedmsg && get_cookie("lastscrollerpos")!="")
revivelastmsg()
memoryscroller.innerHTML=memorycontent
//actualwidth=document.all? temp.offsetWidth : document.getElementById("temp").offsetWidth
lefttime=setInterval("scrollmarquee()",60)
}

function getLeft(o){var n=0;while(o.offsetParent){n+=o.offsetLeft;o=o.offsetParent;}return n;}
function getTop(o){var n=0;while(o.offsetParent){n+=o.offsetTop;o=o.offsetParent;}return n;}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function savelastmsg(){
document.cookie="lastscrollerpos="+memoryscroller.style.left
}

function revivelastmsg(){
lastscrollerpos=parseInt(get_cookie("lastscrollerpos"))
memoryscroller.style.left=parseInt(lastscrollerpos)+"px"
}

if (persistlastviewedmsg && persistmsgbehavior=="onload")
window.onunload=savelastmsg

function scrollmarquee(){
if ( parseInt(memoryscroller.style.left) > (actualwidth*(-1)+8) )
	memoryscroller.style.left = parseInt(memoryscroller.style.left)-copyspeed+"px"
else
	memoryscroller.style.left = parseInt(memorywidth)+8+"px"
}


//*****************************************************************************
// Code to handle a window resize.
//*****************************************************************************

// These variables are used to determine if a resize event is a true one.
// Necessary due to a bug in older NS4 releases.

var origWidth;
var origHeight;

// Fix for resize bug.
var isMinNS4 = document.layers
var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
var dom=document.getElementById&&!ie&&navigator.userAgent.indexOf("Opera")==-1

if (isMinNS4) {
  origWidth  = window.innerWidth;
  origHeight = window.innerHeight;
}
window.onresize = scrollerReload;

function scrollerReload() {

  // Reload page in case of a browser resize. First make sure it's a true
  // resize.

  if (isMinNS4 && origWidth == window.innerWidth && origHeight == window.innerHeight)
    return;
  window.location.href = window.location.href;
}