﻿// JScript File
//used in AGA Homepage template for rotating banner

var status = true;

var myInterval = null;

function Start() {

   //-->
    if (document.getElementById("btn")) {

        var value = document.getElementById("btn").value;

        if (value == "Start") {

            document.getElementById("btn").value = "Pause";

        }

        if (value == "Pause") {

            document.getElementById("btn").value = "Start";

        }

        var count = document.getElementById("count").value;


        if (count > 0) {


            if (document.getElementById("btn").value == "Pause") {

                myInterval = window.setInterval('TopRecipesShow()', 6000);


            }

            if (document.getElementById("btn").value == "Start") {

                window.clearInterval(myInterval);

                myInterval = null;

            }
        }
    }//end without any action
}


function TopRecipesShow() {

    var divids;

    var id;

    var count = document.getElementById("count").value;


    for (var i = 1; i <= count; i++) {


        if (document.getElementById(i).className == "hover") {

            divids = "div" + i;

            id = i;

            removehover(id);

            hidediv(divids);


            if (i == 1) {



                divids = "div2";

                id = "2";

                document.getElementById(divids).style.display = "block";

                document.getElementById(id).className = "hover";



            }




            if (i < count && i != 1) {

                var v = i + 1;

                divids = "div" + v;

                id = v;

                document.getElementById(divids).style.display = "block";

                document.getElementById(id).className = "hover";


            }

            if (i == count) {
                divids = "div1";

                id = "1";



                document.getElementById(divids).style.display = "block";

                document.getElementById(id).className = "hover";


            }

            break;

        }


    }
}

function Show(id) {

    if (myInterval != 'undefined') {

        document.getElementById("btn").value = "Start";

        window.clearInterval(myInterval);

        myInterval = null;

    }

    var count = document.getElementById("count").value;

    for (var i = 1; i <= count; i++) {

        var divids = "div" + i;

        removehover(i);

        hidediv(divids);

    }

    var divid = "div" + id;

    document.getElementById(divid).style.display = "block";

    document.getElementById(id).className = "hover";

}


function removehover(id) {

    document.getElementById(id).className = "";

}

function hidediv(id) {

    document.getElementById(id).style.display = "none";

}
