/***********************************************
EDITABLE TESTIMONIAL CONTENT
This is the content for the scroller testimonials.
***********************************************/
var item=new Array()

item[0] = '"The information was presented in a very clear and structured manner.  One of the best presented workshops I’ve been to in a long time"<div class="author">Pat Nichols - Endeavour Foundation</div>'
item[1] = '"The practical application of the sequential approach was great. I would like to see this and the follow up workshop repeated on an annual basis.  It will help me with staff coaching"<div class="author">Maree Kondisenko – Innisfail Respite Service</div>'
item[2] = '"Thank you. This workshop was very practical. A great template to overlay what can often be a very perplexing situation!"<div class="author">Sharon Wallace-Yarrow - Birdwood High</div>'
item[3] = '"The course was informative and understandable and I enjoyed it.  I loved the understanding that it gives of how the world is for an ASD person "<div class="author">Sue Dawes - Parent</div>'
item[4] = '"As a presenter. Tan was very calming and well presented.  Lots of useful strategies and examples were given. Informative and not too technical."<div class="author">Kevin Busch - Communities (Youth Justice Conferencing )</div>'
item[5] = '"Thank you Tan for providing an interesting approach to an ordinary day in the life of a parent with ASD. I will be able to implement many of these strategies in our home."<div class="author">Kylie Mott – Parent</div>'
item[6] = '"Great strategies for improving/assisting the lives of people we support plus implementing the sequence of Behaviour.  Excellent and easy to understand"<div class="author">Sandra Hammond - Endeavour Foundation</div>'
item[7] = '"I appreciated the real life examples which were very easy to follow and understand"<div class="author">Andy Antl - Bluecare</div>'
item[8] = '"Well presented – Congratulations.  Clear, concise and relevant. Presenter knew her stuff!"<div class="author">Cheryl Martin - Angle Vale Primary</div>'
item[9] = '"Very pleased with the course.  Completely different understanding on how to help my autistic son."<div class="author">Bronwyn Goulding - Parent</div>'
item[10] = '"The whole concept of collecting data is very useful to me. The thermometer concept is excellent!"<div class="author">Joan Sibley - DEECD</div>'
item[11] = '"Many thanks Tan.  A very informative session.  I have learned a lot about ASD"<div class="author">John Wylie - Finding Workable Solutions </div>'
item[12] = '"I found this course really understandable and I could use what I had learned right away and put it into practice."<div class="author">Kathy Mason - Parent</div>'


var pausecontent=new Array()
pausecontent[0]=item[0] + "<br>" + item[1]

pausecontent[1]=item[2] + "<br>" + item[3]

pausecontent[2]=item[4] + "<br>" + item[5]

pausecontent[3]=item[6] + "<br>" + item[7]



//scrollerinstance.block = used to block scrolling of old calls, replaced by new.

/****************************************************************************
IMPORTANT : DO NOT EDIT BEYOND THIS POINT

*****************************************************************************/

/***********************************************
* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function pausescroller(content, divId, divClass, delay){

	this.content=content //message array content
	this.tickerid=divId //ID of ticker div to display information
	this.delay=delay //Delay between msg change, in miliseconds.
	this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
	this.hiddendivpointer=1 //index of message array for hidden div

	this.fast=0
	this.force = 0
	this.block = 0
	this.scrolling = 0



	var ceiling=this.content.length
	var start= parseInt((Math.random() * (ceiling)))
	var next = (start+1>ceiling)? 0 : start+1

	this.hiddendivpointer = start


	document.write('<div id="testimonial_header">Testimonials</div><div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[start]+'</div><div class="innerDiv" 	style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div><div id="'+divId+'_next">Next Testimonial</div>')

	var scrollerinstance=this

	if (window.addEventListener) //run onload in DOM2 browsers
		window.addEventListener("load", function(){scrollerinstance.initialize()}, false)

	else if (window.attachEvent) //run onload in IE5.5+
		window.attachEvent("onload", function(){scrollerinstance.initialize()})

	else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
		setTimeout(function()
		{
			scrollerinstance.initialize()
		}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){

	// select the first two elements.
	this.tickerdiv=document.getElementById(this.tickerid)

	this.visiblediv=document.getElementById(this.tickerid+"1")//+start

	this.hiddendiv=this.hiddendiv=document.getElementById(this.tickerid+"2")//+next
	this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))

	//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
	this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
	this.getinline(this.visiblediv, this.hiddendiv)
	this.hiddendiv.style.visibility="visible"

	var scrollerinstance=this
	document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
	document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}

	document.getElementById(this.tickerid+'_next').onclick=function() {scrollerinstance.animatefast()}

	if (window.attachEvent) //Clean up loose references in IE
		window.attachEvent("onunload", function()
		{
			scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null
		})

	// this starts the action...
	setTimeout(function(){
		scrollerinstance.animateup()
	}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){

	var scrollerinstance=this


	// need to block second click through!

	// move it up a little bit - come back in 50 milliseconds
	if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
		this.scrolling = 1

		this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
		this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
		if(scrollerinstance.fast==0)
			setTimeout(function(){scrollerinstance.animateup()}, 50)
		else
			setTimeout(function(){scrollerinstance.animateup()}, 20)

		scrollerinstance.force = 0

	}

	// this happens at the END of the scroll
	else{
		if(scrollerinstance.force==0) {
			scrollerinstance.fast=0
		}
				// visible	// top of screen
		this.getinline(this.hiddendiv, this.visiblediv) // setting to predefined final place
		this.swapdivs()
		setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
		

		this.scrolling = 0
	}
}



// works for:
// if half way through
pausescroller.prototype.animatefast=function(){

	var scrollerinstance=this

	// go to the next one if we aren't scrolling
	if(scrollerinstance.scrolling==0) {

		scrollerinstance.block+=1
		scrollerinstance.scrolling==1
		var start = this.hiddendivpointer
		scrollerinstance.hiddendivpointer = (start+1>this.content.length)? 0 : start+1
		scrollerinstance.animateup()

	} else {
	
		if(scrollerinstance.fast == 0) {
			scrollerinstance.fast=1
		}
		else {
			alert('spill')
		}
	}
}



// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------
// put hidden in visible after moved.
pausescroller.prototype.swapdivs=function(){

	var tempcontainer=this.visiblediv
	this.visiblediv=this.hiddendiv
	this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){

	div1.style.top=this.visibledivtop+"px"
	div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------


// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------
// this is activated at the start!

// pre-hidden has been placed in visible
// post- new slide placed into hidden[next slide]

pausescroller.prototype.setmessage=function()
{
	var scrollerinstance=this



	// kills primary loop - because another route created
	if(scrollerinstance.block>0) {
		scrollerinstance.block-=1
		return
	}



	//if mouse is currently over scoller, do nothing (pause it)
	//if (this.mouseoverBol==1) 
	//	setTimeout(function(){scrollerinstance.setmessage()}, 100)

	else {
		// grab
		var i=this.hiddendivpointer
		var ceiling=this.content.length

		this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
		this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]

		this.animateup()
	}
}

//get CSS padding value, if any
pausescroller.getCSSpadding=function(tickerobj)
{

	if (tickerobj.currentStyle)
		return tickerobj.currentStyle["paddingTop"]

	else if (window.getComputedStyle) //if DOM2
		return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")

	else
		return 0
}

