Learn how to use jQuery at the Blog

English UK North « visit

  • Added 11 months ago
  • 59 Lines of Code shown
  • 2 Links of Interest
http://englishuknorth.com
This is my Source Code and I don't want to show it here
View Source Code only (as overlay)
// That code snippet belongs to English UK North - http://englishuknorth.com

// image load callback
$.fn.image = function(src, f){ 
	return this.each(function(){ 
    	var i = new Image(); 
		i.onload = f; 
    	i.src = src; 
     	this.appendChild(i);
   	}); 
}

// ensure images are loaded before auto slideshow starts
var heroTimer;
var startWhenLoaded = true;
var imagesLoaded = 1;
function imageLoaded() {
	imagesLoaded++;
	if(imagesLoaded==12) {
		if(startWhenLoaded)	{
			heroTimer = setTimeout("heroSwitch(0)", 5000);
		}	
	}
}

$(document).ready(function() {

	// right-align captions
	$("div.hero-inner").each(function() {
		c = $(this).find("span.caption");
		c.css("margin-left", 640-((c.width()+10)) + "px");
	});
	
	// preload images
	
	$("div#preload").image("/media/web/hero/ambleside.jpg", function() { imageLoaded(); });
	
	$("div#preload").image("/media/web/hero/bradford.jpg", function() { imageLoaded(); });
	
	$("div#preload").image("/media/web/hero/chester.jpg", function() { imageLoaded(); });
	
	$("div#preload").image("/media/web/hero/halifax.jpg", function() { imageLoaded(); });
	
	$("div#preload").image("/media/web/hero/harrogate.jpg", function() { imageLoaded(); });
	
	$("div#preload").image("/media/web/hero/leeds.jpg", function() { imageLoaded(); });
	
	$("div#preload").image("/media/web/hero/liverpool.jpg", function() { imageLoaded(); });
	
	$("div#preload").image("/media/web/hero/manchester.jpg", function() { imageLoaded(); });
	
	$("div#preload").image("/media/web/hero/newcastle.jpg", function() { imageLoaded(); });
	
	$("div#preload").image("/media/web/hero/scarborough.jpg", function() { imageLoaded(); });
	
	$("div#preload").image("/media/web/hero/sheffield.jpg", function() { imageLoaded(); });
	
	$("div#preload").image("/media/web/hero/york.jpg", function() { imageLoaded(); });
	
	
});