/* -----------------------------------------------------------------------------

	Rotation for the homepage images

	-- Note --

	Image location: .../imgs/
	Image naming: img01.jpg, img02.jpg, etc.
	
	To add an image:
	
	(1) Name it using the next image number available.

		Ex/ if the last image is "img11.jpg", name your image "img12.jpg"
	
	(2) Adjust the "num_image_files" variable below to the correct number
	
-----------------------------------------------------------------------------  */


var hm_imgs_links = new Array('hm_quote_01.gif' , 'testimonials_partnership.html'
						,'hm_quote_02.gif' , 'testimonials_private.html'
						,'hm_quote_03.gif' , 'testimonials_group.html'
						,'hm_quote_04.gif' , 'testimonials_private.html'
						,'hm_quote_05.gif' , 'testimonials_private.html'
						,'hm_quote_06.gif' , 'testimonials_group.html');

// preload images
var img1 = new Image().src = "images/hm_quote_01.gif";
var img2 = new Image().src = "images/hm_quote_02.gif";
var img3 = new Image().src = "images/hm_quote_03.gif";
var img4 = new Image().src = "images/hm_quote_04.gif";
var img5 = new Image().src = "images/hm_quote_05.gif";
var img6 = new Image().src = "images/hm_quote_06.gif";

var home_page_imgs = ''; //<a href="testimonials.html"><img src="images/hm_quote_01.gif" alt="quote" width="366" height="129" /></a>';

var row_num =-1;

function shuffle_homepage_images(){
	var num_image_files = 6;
	
	row_num++;
	if (row_num > 5){
		row_num =0;
	}
	//var row_num = Math.round(Math.random() * (num_image_files-1)); // +1;	// choose a random number from 0 to (num_image_files -1)
	//alert(row_num);
	var img_name = hm_imgs_links[(row_num*2)];
	var lnk_name = hm_imgs_links[(row_num*2)+1];
	
	home_page_imgs = '<a href="' + lnk_name +'"><img src="images/' + img_name +'" alt="quote" width="466" height="129" /></a>';

	//var img_obj = eval('img'+ (row_num+1));
	//home_page_imgs = '<a href="' + lnk_name +'"><img src="' + img_obj.src +'" alt="quote" width="404" height="129" /></a>';
	//alert(home_page_imgs);
}
    

var secs;
var timerID = null;
var timerRunning = false;
var delay = 1000;

function InitializeTimer(){
    // Set the length of the timer, in seconds
    secs = 6;
    StopTheClock();
    StartTheTimer();
}

function StopTheClock(){
    if(timerRunning){
        clearTimeout(timerID);
	}
    timerRunning = false
}

function StartTheTimer(){

    if (secs==0){

        StopTheClock();
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        shuffle_homepage_images();
		document.getElementById('hm_pg_imgs').innerHTML = home_page_imgs;
		InitializeTimer();

        //alert("You have just wasted 10 seconds of your life.")
    } else{
        //self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

shuffle_homepage_images();
InitializeTimer();
