﻿var index=0;
var splash_index=0;
var rotate_period=3500;
var splash_rotate_period=10000;
var first_load=false;
var first_splash_load=false;
var clients=[];
var splash_images=[];

function LoadClients()
{
    clients.push(new Array("city-of-los-angeles-ladot.gif","City of Los Angeles (LADOT)","Los Angeles, CA"));    
    clients.push(new Array("key-west-transit.gif","Key West Transit","Key West, FL"));
    clients.push(new Array("university-of-southern-california.gif","University of Southern California","Los Angeles, CA"));
    clients.push(new Array("uc-san-diego.gif","University of California, San Diego","La Jolla, CA"));
    clients.push(new Array("uc-irvine.gif","University of California, Irvine","Irvine, CA"));
    clients.push(new Array("the-presidio-trust.gif","The Presidio Trust","San Francisco, CA"));    
    clients.push(new Array("uc-riverside.gif","University of California, Riverside","Riverside, CA"));
    clients.push(new Array("old-dominion-university.jpg","Old Dominion University","Norfolk, VA"));
    clients.push(new Array("bp-oil.gif","BP Oil - Carson Refinery","Carson, CA"));
    clients.push(new Array("cedars-sinai-medical-center.gif","Cedars Sinai Medical Center","Los Angeles, CA"));    
    clients.push(new Array("uc-san-francisco.gif","University of California<br>San Francisco","San Francisco, CA"));
    clients.push(new Array("cal-poly-pomona.gif","Cal Poly Pomona","Pomona, CA"));
    
    clients.push(new Array("university-of-pennsylvania.jpg","University of Pennsylvania","Philadelphia, PA"));    
    clients.push(new Array("university-of-miami.gif","University of Miami","Miami, FL"));
    
    //clients.push(new Array(".gif","",""));
}

function LoadSplashImages()
{	
	
	splash_images.push("customer1.gif");
	splash_images.push("customer2.gif");
	splash_images.push("customer3.gif");
	splash_images.push("customer4.gif");
	splash_images.push("customer5.gif");	
}

function RotateCustomer()
{
    var effective_period=rotate_period;
    if (first_load)
    {        
        var image_elem = document.getElementById("client_image");
        var name_elem = document.getElementById("client_name");
        var loc_elem = document.getElementById("client_location");
        index = index+1;
        
        if (index >= clients.length)
            index=0;
            
        var client = clients[index];
        
        var img=client[0];
        var name=client[1];
        var loc=client[2];
        
        image_elem.src="/gps-bus-tracking/clients/" + img;
        
        name_elem.innerHTML=name;
        loc_elem.innerHTML=loc;
    }   
    else
    {
        effective_period=10000;
        LoadClients();
        first_load=true;     
    }        
    
    window.setTimeout(RotateCustomer,effective_period);
    

}

function RotateSplash()
{
    if (first_splash_load)
    {
        
        var image_elem = document.getElementById("main_splash_image");
        
        splash_index = splash_index+1;
        
        if (splash_index >= splash_images.length)
            splash_index=0;
            
        var image = splash_images[splash_index];
                
        image_elem.src="/gps-bus-tracking/" + image;
                
    }   
    else
    {
        LoadSplashImages();
        first_splash_load=true;     
    }        
    
    window.setTimeout(RotateSplash,splash_rotate_period);
    

}