jQuery.preloadCssImages = function(c) { c = jQuery.extend({ statusTextEl: null, statusBarEl: null, errorDelay: 999, simultaneousCacheLoading: 2 }, c); var a = [], f = 0, d = [], g, e; function i() { clearTimeout(e); if (d && d.length && d[f]) { f++; if (c.statusTextEl) { var j = (d[f]) ? "Now Loading: <span>" + d[f].split("/")[d[f].split("/").length - 1] : "Loading complete"; jQuery(c.statusTextEl).html('<span class="numLoaded">' + f + '</span> of <span class="numTotal">' + d.length + '</span> loaded (<span class="percentLoaded">' + (f / d.length * 100).toFixed(0) + '%</span>) <span class="currentImg">' + j + "</span></span>") } if (c.statusBarEl) { var k = jQuery(c.statusBarEl).width(); jQuery(c.statusBarEl).css("background-position", -(k - (k * f / d.length).toFixed(0)) + "px 50%") } h() } } function h() { if (d && d.length && d[f]) { var j = new Image(); j.src = d[f]; if (!j.complete) { jQuery(j).bind("error load onreadystatechange", i) } else { i() } e = setTimeout(i, c.errorDelay) } } function b(n, y) { var v = false, r = [], p = [], z; var o = n.length; while (o--) { var x = ""; if (y && y[o]) { z = y[o] } else { var B = (n[o].href) ? n[o].href : "window.location.href"; var A = B.split("/"); A.pop(); z = A.join("/"); if (z) { z += "/" } } if (n[o].cssRules || n[o].rules) { g = (n[o].cssRules) ? n[o].cssRules : n[o].rules; var s = g.length; while (s--) { if (g[s].style && g[s].style.cssText) { var q = g[s].style.cssText; if (q.toLowerCase().indexOf("url") != -1) { x += q } } else { if (g[s].styleSheet) { r.push(g[s].styleSheet); v = true } } } } var C = x.match(/[^\("]+\.(gif|jpg|jpeg|png)/g); if (C) { var u = C.length; while (u--) { var k = (C[u].charAt(0) == "/" || C[u].match("://")) ? C[u] : z + C[u]; if (jQuery.inArray(k, d) == -1) { d.push(k) } } } if (!v && n[o].imports && n[o].imports.length) { for (var l = 0, j = n[o].imports.length; l < j; l++) { var w = n[o].imports[l].href; w = w.split("/"); w.pop(); w = w.join("/"); if (w) { w += "/" } var m = (w.charAt(0) == "/" || w.match("://")) ? w : z + w; p.push(m); r.push(n[o].imports[l]) } } } if (r.length) { b(r, p); return false } var t = c.simultaneousCacheLoading; while (t--) { setTimeout(h, t) } } b(document.styleSheets); return d };