var gallery_pos = 1;
var curr_image = 0;

function next_image()
{
	my_int = setTimeout('rotate_image()', 3e3);
}

function rotate_image()
{
	var images = window.gallery_images.split(',');
	var old_image = window.curr_image;
	window.curr_image = window.curr_image * -1 + 1;
	if( ++window.gallery_pos == images.length ) window.gallery_pos = 0;
	$('#image_'+old_image).fadeOut(1500, function() {
		$('#image_'+old_image).attr('src','/_images/gallery/'+images[gallery_pos]);
		next_image();
  	});
	$('#image_'+window.curr_image).fadeIn(1500)
}

$(document).ready(function() {
	
	/* open links with rel="external" in new window and amend link title */
	$('a[rel*="external"]').each(function() {
		var title = $(this).attr('title') ? $(this).attr('title') + ' (opens in a new tab or window)' : 'This link will open in a new tab or window';
		$(this).attr('title',title).click(function() {
			window.open($(this).attr('href'));
			return false;
		});
	});
	
	// execute sIRF after DOM load
	if(typeof sIFR == "function"){
		sifr_exec();
	};
	
	$('.quote_block').mouseover(function() {
		$(this).css('cursor', 'pointer');
	});
	
	$('.quote_block').click(function() {
		window.location = '/contact-us/';
	});
	
	$('#quote_block embed').click(function() {
		window.location = '/contact-us/';
	});
	
	next_image();
	
});

