﻿// Homepage Banner Rotation JScript File

// Rotate Divs based on a user defined class e.g. class="solutionsRotateData" and id+n e.g. id="section1"
// the numbers are sequential
// currently 9 banners per section
	
	
// CONFIG

// each section (div tag) that needs to rotate

// Solutions 
// properties are now set in a master page
// /includes/snippets/homepage/solutions/master-inc.aspx

// var solution_divs_total = 2;            // how many divs are being rotated (max = 9)
// var current_solution_div = 1;           // which div shall we start with
// var next_solution_div = 0;              // initialize to 0 it will be set later
// var solution_rotation_interval = 6000;  // how often should they rotate


// Events
// properties are now set in a master page
// /includes/snippets/homepage/events/master-inc.aspx

// var event_divs_total = 2;
// var current_event_div = 1;
// var next_event_div = 0;
// var events_rotation_interval = 7500;

// START
// moved to master controller
// EVENTS: xxx
// SOLUTIONS: xxx
// Once the html doc is fully loaded, load rotation functions into an interval
// $(document).ready(function(){
    // each section currently needs its own function, configured below (need to fix)
   // setInterval("solutionsRotateData()", solution_rotation_interval);
	// setInterval("eventsRotateData()", events_rotation_interval);
// });
	
	
// FUNCTIONS

// generic rotation (to be built)
function rotateDiv(){
   
    $("div.solutionsRotateData").each( function () {
        
        if(this.style.display=='block'){
            var myID = this.id;
            var the_length=myID.length;
            var last_char=Number(myID.charAt(the_length-1));
            
            if(last_char == solution_divs_total){
                next_solution_div = 1;
            }else{
                next_solution_div = last_char + 1;
            }
            
            $(this).fadeOut("fast",function(){
            $("div#solutionsRotateData" + next_solution_div).fadeIn("slow");
            });
            
           }

    });
}

// solutionsRotateData
function solutionsRotateData(){
   
    $("div.solutionsRotateData").each( function () {
        
        if(this.style.display=='block'){
            var myID = this.id;
            var the_length=myID.length;
            var last_char=Number(myID.charAt(the_length-1));
            
            if(last_char == solution_divs_total){
                next_solution_div = 1;
            }else{
                next_solution_div = last_char + 1;
            }
            
            $(this).fadeOut("fast",function(){
            $("div#solutionsRotateData" + next_solution_div).fadeIn("slow");
            });
            
         }

    });
}


// eventsRotateData
function eventsRotateData(){
   
    $("div.eventsRotateData").each( function () {
        
        if(this.style.display=='block'){
            var myID = this.id;
            var the_length=myID.length;
            var last_char=Number(myID.charAt(the_length-1));
            
            if(last_char == event_divs_total){
                next_event_div = 1;
            }else{
                next_event_div = last_char + 1;
            }
            
            $(this).fadeOut("fast",function(){
            $("div#eventsRotateData" + next_event_div).fadeIn("slow");
            });
            
         }

    });
}
