

if (!ChildCareJobs)
{
	var ChildCareJobs = {};
}

ChildCareJobs.FeaturedEmployerSlider = 
{
	rsimagesRSS: [{"id":77,"jobSearchLink":"searchresults.aspx?order=date&keywords=&category=&type=&position=&country=&state=&city=&emp=77&pg=1","imageUrl":"imageNew.aspx?employerId=77&w=215&h=135","alternateText":"Abracadabra Childcare Services\nPO Box 102, Coogee, NSW\nAbracadabra Childcare Services has been providing quality childcare to families across Sydney since 1999. ACS is owned and managed by Felicity Gray. F..."},{"id":1189,"jobSearchLink":"searchresults.aspx?order=date&keywords=&category=&type=&position=&country=&state=&city=&emp=1189&pg=1","imageUrl":"imageNew.aspx?employerId=1189&w=215&h=135","alternateText":"Kindalin Early Childhood Learning Centres\n4 Spurwood Close, Dural, NSW\nKindalin Early Childhood Learning Centres have been providing high quality Children’s Services for over 20 years and can offer:\r\n\r\n\u003cul\u003e\u003cli\u003eJob Securit..."},{"id":765,"jobSearchLink":"searchresults.aspx?order=date&keywords=&category=&type=&position=&country=&state=&city=&emp=765&pg=1","imageUrl":"imageNew.aspx?employerId=765&w=215&h=135","alternateText":"Guardian Childcare Alliance Pty Ltd\nPO Box 379, Spring Hill, QLD\n..."}],

	nIndexImages: 0,
	_currentlyShownImage: null,

	buildimages: function(divContainer, employer) {
		// 2010-mar-29 markg: this uses jquery to build the dom elements, avoiding any XSS attacks by manually building up strings
		var div = $(document.createElement('div'));

		div
			.attr({ id : employer.id })
			.hide()
			.css("margin-left", "2px")
			.append(
				$(document.createElement('a'))
					.attr({ href : employer.jobSearchLink })
					.append(
						$(document.createElement('img'))
							.attr({ border: "0", src: employer.imageUrl, alt: employer.alternateText })
					)
			);

		employer.div = div;

		divContainer.append(div);

		if (this._currentlyShownImage)
		{
			this.slideimages(div);
		}
		else
		{
			div.show();
			
			this._currentlyShownImage = div;
		}
	},

	/// <summary>
	/// 2010-mar-29 markg: takes in a jquery object of the new images to show after the current image has faded
	/// </summary>
	slideimages: function(newImageToShow)
	{
		var slider = this;
		var fimages = this._currentlyShownImage;

		if (fimages)
		{
			fimages.fadeOut(600, function() {
				slider._currentlyShownImage = newImageToShow;

				newImageToShow.show();
			});
		}
	},

	loadimages: function()
	{
		if (this.rsimagesRSS.length > 0) {
			if (this.nIndexImages >= this.rsimagesRSS.length) {
				this.nIndexImages = 0;
			}

			var employer = this.rsimagesRSS[this.nIndexImages];

			var elSlider = employer.div;

			if (elSlider)
			{
				this.slideimages(elSlider);
			}
			else
			{
				this.buildimages($('#featuredEmployersSlider'), employer);
			}

			this.nIndexImages++;
		}
	}
}

$(function() {
	ChildCareJobs.FeaturedEmployerSlider.loadimages();
	window.setInterval(function() {ChildCareJobs.FeaturedEmployerSlider.loadimages();}, 5000);
});