﻿var pausecontent = new Array()
pausecontent[0] = 'I just wanted to thank you for your wonderful training course and let you know that I am more than happy to recommend your training services to anyone wishing to pursue bookkeeping.I had previously done a TAFE course to assist my job training and found it got me through the basics but I never really got a handle on the more advanced tasks I had to do. I struggled trying to remember the more advanced tasks I had to complete. Your tuition has thoroughly taught me every aspect of bookkeeping needed to excel in my job, which in turn has bought a promotion and turned me into a very confident bookkeeper now able to handle any related task thrown my way. I cannot recommend you highly enough and just wanted to thank you again for your patience and practical easy-to-understand manner in which you train.<strong> Many thanks</strong><br /><b>N. Bodanac</b><br />'
pausecontent[1] = 'Excellent training course. You made learning Quickbooks easy and enjoyable. Will be recommending you to associates.<strong> Thank You</strong><br /><b>A. Gates</b><br />'
pausecontent[2] = 'I wanted to write and thank you for the fantastic training you have given me. Your tuition has helped me to find a much better paid job and I am very happy with my bookkeeping skill level now.I highly recommend you as a trainer in all facets of bookkeeping.<strong> Many thanks</strong><br /><b>T. Sheils</b><br />'
pausecontent[3] = 'I would just like to say I attended a MYOB class that was delivered by Annette. Although I was apprehensive as any &lsquo;new&rsquo; student is - I was quickly placed at ease by Annette&#39;s professionalism and teaching manner. Annette made the mystery of MYOB clear and understandable to such a point I now feel comfortable using it in my day to day business. I would recommend Annette and her MYOB class to anyone that wants to learn in a friendly knowledgeable environment.<strong> Thank You</strong><br /><b>Kay Wilson</b><br />'
pausecontent[4] = 'I found Annette, the trainer, to be very helpful, very knowledgeable, very informative, easy to get along with and a very pleasant person to be around. She is very good at her job. Anyone wanting to learn MYOB would do well to come to Execaid and be taught by Annette. Thanks heaps, Annette!<br /><b>Loz MacDonald – MYOB for Beginners</b><br />15/1/2010<br />'
pausecontent[5] = 'Annette was very clear in her presentation and explained everything very well for a complete novice like me. Love the showbags!<br /><b>Elizabeth Quinn – MYOB for Beginners</b><br />15/1/2010<br />'
pausecontent[6] = 'A very beneficial course. Would definitely recommend the MYOB course to my fellow peers.<br /><b>Caroline Cramer – MYOB for Beginners</b><br />15/1/2010<br />'


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 is to split content */
    if (content[0].length > 159) {
        var client = content[0].split('<br /><b>')[1]
        if (client != null) {
            //content[0] = content[0].substring(0, 155) + "...<br /><b>" + client + "<br />"
            content[0] = content[0].split('<br /><b>')[0].substring(0, 155) + " ...<br /><b>" + client + "<br />"
        }
        else {
            content[0] = content[0].substring(0, 170)
        }
    }
    /* End */

    /* This is to split content */
    if (content[1].length > 159) {
        var client = content[1].split('<br /><b>')[1]
        if (client != null) {
            //content[1] = content[1].substring(0, 155) + "...<br /><b>" + client + "<br />"
            content[1] = content[1].split('<br /><b>')[0].substring(0, 155) + " ...<br /><b>" + client + "<br />"
        }
        else {
            content[1] = content[1].substring(0, 170)
        }
    }
    /* End */
    
    document.write('<div id="' + divId + '" class="' + divClass + '" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="' + divId + '1">' + content[0] + '</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="' + divId + '2">' + content[1] + '</div></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() {
    this.tickerdiv = document.getElementById(this.tickerid)
    this.visiblediv = document.getElementById(this.tickerid + "1")
    this.hiddendiv = document.getElementById(this.tickerid + "2")
    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 }
    if (window.attachEvent) //Clean up loose references in IE
        window.attachEvent("onunload", function() { scrollerinstance.tickerdiv.onmouseover = scrollerinstance.tickerdiv.onmouseout = null })
    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
    if (parseInt(this.hiddendiv.style.top) > (this.visibledivtop + 5)) {
        this.visiblediv.style.top = parseInt(this.visiblediv.style.top) - 5 + "px"
        this.hiddendiv.style.top = parseInt(this.hiddendiv.style.top) - 5 + "px"
        setTimeout(function() { scrollerinstance.animateup() }, 50)
    }
    else {
        this.getinline(this.hiddendiv, this.visiblediv)
        this.swapdivs()
        setTimeout(function() { scrollerinstance.setmessage() }, this.delay)
    }
}


// swapdivs()- Swap between which is the visible and which is the hidden div


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


pausescroller.prototype.setmessage = function() {
    var scrollerinstance = this
    if (this.mouseoverBol == 1) //if mouse is currently over scoller, do nothing (pause it)
        setTimeout(function() { scrollerinstance.setmessage() }, 100)
    else {
        var i = this.hiddendivpointer
        var ceiling = this.content.length
        this.hiddendivpointer = (i + 1 > ceiling - 1) ? 0 : i + 1
        /* This is to split content */
        if (this.content[this.hiddendivpointer].length > 159) {
            var client = this.content[this.hiddendivpointer].split('<br /><b>')[1]
            if (client != null) {
                //this.content[this.hiddendivpointer] = this.content[this.hiddendivpointer].substring(0, 155) + "...<br /><b>" + client + "<br />"
                if (this.content[this.hiddendivpointer].split('<br /><b>')[0].length > 150) {
                    this.content[this.hiddendivpointer] = this.content[this.hiddendivpointer].split('<br /><b>')[0].substring(0, 150) + " ...<br /><b>" + client + "<br />"
                }
                else {
                    this.content[this.hiddendivpointer] = this.content[this.hiddendivpointer].split('<br /><b>')[0].substring(0, this.content[this.hiddendivpointer].split('<br /><b>')[0].length) + "<br /><b>" + client + "<br />"
                }
            }
            else {
                this.content[this.hiddendivpointer] = this.content[this.hiddendivpointer].substring(0, 170)
            }
        }
        /* End */
        /*alert(this.content[this.hiddendivpointer].length);*/
        this.hiddendiv.innerHTML = this.content[this.hiddendivpointer]
        this.animateup()
    }
}

pausescroller.getCSSpadding = function(tickerobj) { //get CSS padding value, if any
    if (tickerobj.currentStyle)
        return tickerobj.currentStyle["paddingTop"]
    else if (window.getComputedStyle) //if DOM2
        return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
    else
        return 0
}