var cycler;
var currentImage = 0;
var maxImages = 3;
var imageToSwap = "home_image";

var imageArray = new Array();
//replace these with Image objects
imageArray[0]="../images/headers/direct/direct_default.jpg";
imageArray[1]="../images/headers/connect/connect_default.jpg";
imageArray[2]="../images/headers/logistics/logistics_default.jpg";

function doImageCycle() {
	cycler = setTimeout("doImageCycle()",5000);
	currentImage += 1;
	if(currentImage >= maxImages) {
		currentImage = 0;
	}
	swapImage(imageArray[currentImage]);
}

function stopCycle() {
	currentImage -= currentImage > 0 ? 1 : 0;
	clearTimeout(cycler);
}

function swapImageOnHover(imageNumber) {
	stopCycle();
	swapImage(imageArray[imageNumber]);
}

/*do an image switcherooo */
function swapImage(image) {
	if(document.images) {
		document.images[imageToSwap].src=image;
	}
}

$(document).ready(function(){

	 	/* Nissan --- START */
	   $("#nissan_key_benefits").click(function(event){
		   	$("#nissan_quote_1").dialog('open');
		     event.preventDefault();
		   });
	   
	   $("#nissan_client_says").click(function(event){
		   	$("#nissan_quote_2").dialog('open');
		     event.preventDefault();
		   });	   
	   
	   $("#nissan_quote_1").dialog( { 
		   show: 'blind', hide: 'blind',
          /*buttons: { "Close": function() { jQuery(this).dialog("close"); }},*/
          autoOpen: false, modal: true, resizable: false, draggable: false 
          });
	   
	   $("#nissan_quote_2").dialog( { 
		   show: 'blind', hide: 'blind',
          autoOpen: false, modal: true, resizable: false, draggable: false 
          });	   
	   
	   /* Nissan --- END */
	   
	   /* Hse --- START */
	   $("#hse_vital_stats").click(function(event){
		   	$("#hse_quote_1").dialog('open');
		     event.preventDefault();
		   });
	   
	   $("#hse_partnership").click(function(event){
		   	$("#hse_quote_2").dialog('open');
		     event.preventDefault();
		   });
	   
	   $("#hse_new_website").click(function(event){
		   	$("#hse_quote_3").dialog('open');
		     event.preventDefault();
		   });
	   
	   $("#hse_quote_1").dialog( { 
		   show: 'blind', hide: 'blind',
         /*buttons: { "Close": function() { jQuery(this).dialog("close"); }},*/
         autoOpen: false, modal: true, resizable: false, draggable: false 
         });
	   
	   $("#hse_quote_2").dialog( { 
		   show: 'blind', hide: 'blind',
         autoOpen: false, modal: true, resizable: false, draggable: false 
         });
	   
	   $("#hse_quote_3").dialog( { 
		   show: 'blind', hide: 'blind',
         autoOpen: false, modal: true, resizable: false, draggable: false 
         });	
	   /* Hse --- END */
	   
	   /* Tearfund --- Start */
	   $("#tearfund_client_says").click(function(event){
		   	$("#tearfund_quote_1").dialog('open');
		     event.preventDefault();
		   });
	   
	   $("#tearfund_quote_1").dialog( { 
		   show: 'blind', hide: 'blind',
         autoOpen: false, modal: true, resizable: false, draggable: false 
         });	   
	   /* Tearfund --- End */
	   
	 	/* BHF --- START */
	   $("#bhf_impressive_results").click(function(event){
		   	$("#bhf_quote_1").dialog('open');
		     event.preventDefault();
		   });
	   
	   $("#bhf_keep_healthy").click(function(event){
		   	$("#bhf_quote_2").dialog('open');
		     event.preventDefault();
		   });
	   
	   $("#bhf_quote_1").dialog( { 
		   show: 'blind', hide: 'blind',
          autoOpen: false, modal: true, resizable: false, draggable: false 
          });
	   
	   $("#bhf_quote_2").dialog( { 
		   show: 'blind', hide: 'blind',
          autoOpen: false, modal: true, resizable: false, draggable: false 
          });
	   /* BHF --- END */	
	   
	   /* RSPB --- START */	   
	   $("#services_on_demand_for_RSPB").click(function(event){
		   	$("#rspb_quote_1").dialog('open');
		     event.preventDefault();
		   });
	   
	   $("#what_RSPB_customers_are_telling_us").click(function(event){
		   	$("#rspb_quote_2").dialog('open');
		     event.preventDefault();
		   });	  
	   
	   $("#rspb_quote_1").dialog( { 
		   show: 'blind', hide: 'blind',
          /*buttons: { "Close": function() { jQuery(this).dialog("close"); }},*/
          autoOpen: false, modal: true, resizable: false, draggable: false 
          });
	   
	   $("#rspb_quote_2").dialog( { 
		   show: 'blind', hide: 'blind',
          autoOpen: false, modal: true, resizable: false, draggable: false 
          });	     
	   /* RSPB --- END */
	   
	   /* Haiti Earthquake --- START */	   
	   $("#what_oxfam_says").click(function(event){
		   	$("#haiti_earthquake_quote_1").dialog('open');
		     event.preventDefault();
		   });
	   
	   $("#what_cafod_says").click(function(event){
		   	$("#haiti_earthquake_quote_2").dialog('open');
		     event.preventDefault();
		   });	
	   
	   $("#thankyou").click(function(event){
		   	$("#haiti_earthquake_quote_3").dialog('open');
		     event.preventDefault();
		   });	
	   
	   $("#haiti_earthquake_quote_1").dialog( { 
		   show: 'blind', hide: 'blind',
          /*buttons: { "Close": function() { jQuery(this).dialog("close"); }},*/
          autoOpen: false, modal: true, resizable: false, draggable: false 
          });
	   
	   $("#haiti_earthquake_quote_2").dialog( { 
		   show: 'blind', hide: 'blind',
          autoOpen: false, modal: true, resizable: false, draggable: false 
          });	
	   
	   $("#haiti_earthquake_quote_3").dialog( { 
		   show: 'blind', hide: 'blind',
          autoOpen: false, modal: true, resizable: false, draggable: false 
          });	
	   /* RSPB --- END */
 });

