jQuery.extend({
	diy_img_loaded: function (id, time) {
						jQuery(document).data('diy_current_' + id + '_loaded', jQuery(document).data('diy_current_loaded') + 1);
						if(jQuery(document).data('diy_current_' + id + '_loaded').length == jQuery(document).data('diy_' + id + '_loaded_length').length){
							if (jQuery(id).index !== -1) {
								jQuery(id).cycle({	timeout: time, speed: 2000,  next: "img.swap", slideExpr: "img.swap",  height: 'auto', sync: 1, fit: 1});
							}
						}
					}
	});

jQuery().ready(function () {
	// show me when the process begins (for those of you watching from missouri)
	// confirm("The page is ready.")
	jQuery(document).data('diy_image_uris', [["http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader\/topsitebar10a.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader\/topsitebar8a.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader\/topsitebar1a.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader\/topsitebar3a.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader\/topsitebar4a.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader\/topsitebar7a.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader\/topsitebar5a.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader\/topsitebar6a.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader\/topsitebar2a.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader\/topsitebar9a.jpg"],["http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader-shop\/topsitebar6.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader-shop\/topsitebar3.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader-shop\/topsitebar2.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader-shop\/topsitebar7.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader-shop\/topsitebar8.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader-shop\/topsitebar5.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader-shop\/topsitebar9.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader-shop\/topsitebar4.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader-shop\/topsitebar1.jpg","http:\/\/orange20bikes.com\/uploads\/galleryimages\/siteheader-shop\/topsitebar10.jpg"]]);
	jQuery(document).data('diy_options', [[5,"logoWrapper","siteheader","home"],[5,"shopLogoWrapper","siteheader-shop","bikeshop"]]);
	
	// for each option array
	jQuery.each(jQuery(document).data('diy_options'), function (i, val1) {
		jQuery(document).data('diy_#' + val1[1] + '_current_loaded', 0);
		jQuery(document).data('diy_#' + val1[1] + '_loaded_length', jQuery(document).data('diy_image_uris').length);
		// if the 2nd option is on the page,
		if(jQuery('#' + val1[1]).is('div')) {
			//alert(val1[1]); // print the css id
			
			jQuery.each(jQuery(document).data('diy_image_uris')[i], function (j, val2) {
				var id = '#' + val1[1];
				var time = val1[0];
				var ti = new Image();
				jQuery(ti)
					.load(function () {
						jQuery(this).hide();
						jQuery(id).append(this);
						jQuery.diy_img_loaded(id, time);
					})
					.attr('class', 'swap')
					.attr('src', val2);
				
				//alert(val2); // print each url
			});
		}
	});
});
