/*
	<div id="leftGadget">left</div>
	<div id="imageGadget">image</div>
	<div id="rightGadget">right</div>
*/

var ImageObj = function(newPath, newDesc, newUrl)
{
	this.path = newPath;
	this.desc = newDesc;
	this.url = newUrl;
};

var HtmlObj = function(imageBox, newId)
{
	imageBox.append('<li><a class="imageID" id="anchor' + newId +'" ><img id="img' + newId +'"/></a><a id="descAnchor' + newId +'"><span id="description' + newId +'"></span></a></li>');
	this.anchor = jQuery('#anchor' + newId);
	this.img = jQuery('#img' + newId);
	this.description = jQuery('#description' + newId);
	this.descAnchor = jQuery('#descAnchor' + newId);
};

var ImageGadget = function(newImgArr)
{
	var currentIndex = 0;
	var imagePath = '/img/';
	var imageBox;
	this.keyword = '';
	this.imgCount = 2;
	var htmlArr;
	this.imageArr = newImgArr;
	this.init = function()
	{
		htmlArr = Array(this.imgCount);
		imageBox = jQuery('#image' + this.keyword);
		var newImgs = '';
		for(var i= 0; i< this.imgCount; i++)
		{
			var newId = this.keyword + i;
			htmlArr[i] = new HtmlObj(imageBox, newId)
		}
		this.loadImage(currentIndex);
	}
	this.loadImage = function(imgIndex)
	{
		for(var i = 0; i< htmlArr.length; i++)
		{
			htmlArr[i].img.attr('src', this.getImage(this.getIndex(i)));
			htmlArr[i].anchor.attr('href', this.imageArr[this.getIndex(i)].url);
			htmlArr[i].description.html(this.imageArr[this.getIndex(i)].desc);
			htmlArr[i].descAnchor.attr('href', this.imageArr[this.getIndex(i)].url);
		}
	}
	this.slide = function(newIndex)
	{
		currentIndex = this.getIndex(newIndex);
		this.loadImage(currentIndex);
	}
	this.getIndex = function(imgIndex)
	{
		var returnIndex = currentIndex + imgIndex - 1;
		if (returnIndex < 0)
		{
			return (this.imageArr.length + imgIndex - 1);
		}
		else
		{
			return returnIndex % this.imageArr.length;
		}
	}
	this.getImage = function(imgIndex)
	{
		return imagePath + this.imageArr[imgIndex].path;
	}
};

jQuery(window).load(function ()
{
	var img1 = new ImageObj('/home/img/video.jpg', 'ECITB &amp; RAE Project Management Competition Video', 'http://www.ecitb.org.uk/AboutECITB/ECITBRAEProjectManagementCompetitionVideo/');
	var img2 = new ImageObj('/home/img/davidEdwards.png', 'David Edwards - The need for training in the UK', 'http://www.ecitb.org.uk/AboutECITB/DavidEdwardsVideo/');
	
	var imageVideos = new ImageGadget([img2, img1]);
	imageVideos.keyword = 'Video';
	imageVideos.imgCount = 1;
	imageVideos.init();
	jQuery('#leftVideo').click(function()
	{
		imageVideos.slide(2);
	});
	jQuery('#rightVideo').click(function()
	{
		imageVideos.slide(0);
	});

	var img1 = new ImageObj('/home/SkillCharter/GMB_Logo.jpg', 'GMB', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img2 = new ImageObj('/home/SkillCharter/Pyeroy_Logo.jpg', 'Pyeroy', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img3 = new ImageObj('/home/SkillCharter/alphaPlus_logo.jpg', 'Aplha Plus', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img4 = new ImageObj('/home/SkillCharter/3sun_logo.jpg', '3Sun', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img5 = new ImageObj('/home/SkillCharter/akerSolutions_logo.jpg', 'Aker Solutions', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img6 = new ImageObj('/home/SkillCharter/alstom_logo.jpg', 'Alstom', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img7 = new ImageObj('/home/SkillCharter/amec_logo.jpg', 'Amec', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img8 = new ImageObj('/home/SkillCharter/applus_logo.jpg', 'Applus', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img9 = new ImageObj('/home/SkillCharter/bp_logo.jpg', 'BP', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img10 = new ImageObj('/home/SkillCharter/cape_logo.jpg', 'Cape', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img11 = new ImageObj('/home/SkillCharter/cds_logo.jpg', 'CDS', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img12 = new ImageObj('/home/SkillCharter/cees_logo.jpg', 'CEES', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img13 = new ImageObj('/home/SkillCharter/cordel_logo.jpg', 'Cordel', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img14 = new ImageObj('/home/SkillCharter/doosan_logo.jpg', 'Doosan', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img15 = new ImageObj('/home/SkillCharter/ecia_logo.jpg', 'ECIA', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img16 = new ImageObj('/home/SkillCharter/enterprise_logo.jpg', 'Enterprise', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img17 = new ImageObj('/home/SkillCharter/foster_logo.jpg', 'Foster', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img18 = new ImageObj('/home/SkillCharter/granite_logo.jpg', 'Granite', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img19 = new ImageObj('/home/SkillCharter/haycock_logo.jpg', 'Haycock', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img20 = new ImageObj('/home/SkillCharter/ineos_logo.jpg', 'INEOS', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img21 = new ImageObj('/home/SkillCharter/interface_logo.jpg', 'Interface', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img22 = new ImageObj('/home/SkillCharter/interserve_logo.jpg', 'Interserve', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img23 = new ImageObj('/home/SkillCharter/jacobs_logo.jpg', 'Jacobs', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img24 = new ImageObj('/home/SkillCharter/jenkins_logo.jpg', 'Jenkins', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img25 = new ImageObj('/home/SkillCharter/jib_logo.jpg', 'JIB', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img26 = new ImageObj('/home/SkillCharter/jibscottish_logo.jpg', 'JIB Scottish', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img27 = new ImageObj('/home/SkillCharter/lakers_logo.jpg', 'Lakers', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img28 = new ImageObj('/home/SkillCharter/mb_logo.jpg', 'MB', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img29 = new ImageObj('/home/SkillCharter/mpe_logo.jpg', 'MPE', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img30 = new ImageObj('/home/SkillCharter/njc_logo.jpg', 'NJC', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img31 = new ImageObj('/home/SkillCharter/pjd_logo.jpg', 'PJD', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img32 = new ImageObj('/home/SkillCharter/promanex_logo.jpg', 'Promanex', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img33 = new ImageObj('/home/SkillCharter/psn_logo.jpg', 'PSN', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img34 = new ImageObj('/home/SkillCharter/quartzelec_logo.jpg', 'Quartzelec', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img35 = new ImageObj('/home/SkillCharter/scottish_logo.jpg', 'Scottish Power', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img36 = new ImageObj('/home/SkillCharter/shaw_logo.jpg', 'Shaw Group', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img37 = new ImageObj('/home/SkillCharter/southern_logo.jpg', 'Southern Electric', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img38 = new ImageObj('/home/SkillCharter/stats_logo.jpg', 'Stats', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img39 = new ImageObj('/home/SkillCharter/t3uk_logo.jpg', 'T3UK', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img40 = new ImageObj('/home/SkillCharter/tica_logo.jpg', 'TICA', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img41 = new ImageObj('/home/SkillCharter/unite_logo.jpg', 'Unite', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img42 = new ImageObj('/home/SkillCharter/westwell_logo.jpg', 'Westwell', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img43 = new ImageObj('/home/SkillCharter/wg_logo.jpg', 'WG', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');
	var img44 = new ImageObj('/home/SkillCharter/wright_logo.jpg', 'Wright', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');

	
	var imageSkills= new ImageGadget([img1, img2, img3, img4, img5, img6, img7, img8, img9, img10, img11, img12, img13, img14, img15, img16, img17, img18
	, img19, img20, img21, img22, img23, img24, img25, img26, img27, img28, img29, img30, img31, img32, img33, img34, img35, img36, img37, img38, img39
	, img40, img41, img42, img43, img44]);
	imageSkills.keyword = 'Skills';
	imageSkills.imgCount = 2;
	imageSkills.init();
	jQuery('#leftSkills').click(function()
	{
		imageSkills.slide(2);
	});
	jQuery('#rightSkills').click(function()
	{
		imageSkills.slide(0);
	});

	
	var img1 = new ImageObj('/home/Publications/product_services.jpg', 'ECITB Product &amp; Services', 'http://www.ecitb.org.uk/documents/levyAndScope/ProgrammeListing2010_JUNE.pdf');
	//var img2 = new ImageObj('/home/img/annual_reports.jpg', 'Annual Report &amp; Accounts', 'http://www.ecitb.org.uk/documents/levyAndScope/ECITB_ANNUAL_REPORT_&_ACCOUNTS_2009_Parliament.pdf');
	var img3 = new ImageObj('/home/Publications/training_guide.jpg', 'Guide to Training Programmes', 'http://www.ecitb.org.uk/AboutECITB/SkillsTrainingCharter/');	
	var img4 = new ImageObj('/home/Publications/2009CustomerSurveyResultsReport.jpg', '2009 Customer Survey Results', 'http://www.ecitb.org.uk/documents/corporate/2009CustomerSurveyResultsReport.pdf');
	var img5 = new ImageObj('/home/Publications/2009SkillsActionPlan.jpg', '2009 Skills Action Plan', 'http://www.ecitb.org.uk/documents/corporate/2008Results_2009SkillsActionPlan.pdf');
	var img6 = new ImageObj('/home/Publications/bridgesAndPathwaysNewsletter.jpg', 'ECITB Bridges &amp; Pathways Newsletter', 'http://www.ecitb.org.uk/documents/regions/Newsletter_pathways.pdf');
	var img8 = new ImageObj('/home/Publications/energyLeaflet.jpg', 'East of England Skills for Energy', 'http://www.ecitb.org.uk/documents/awardsQualifications/ResearchDevelopment/Energy_Leaflet.pdf');
	var img9 = new ImageObj('/home/Publications/energySkills.jpg', 'ECITB Energy Skills', 'http://www.ecitb.org.uk/documents/corporate/EWP_Skills_Reporting_Final_Oct_20_08.pdf');
	var img10 = new ImageObj('/home/Publications/industryReport08.jpg', 'ECITB Industry Report 08', 'http://www.ecitb.org.uk/documents/corporate/2008_ECITB_Industry_Report.pdf');
	var img14 = new ImageObj('/home/Publications/MobilityAndSkills.jpg', 'ECITB Mobility &amp; Skills', 'http://www.ecitb.org.uk/documents/awardsQualifications/ResearchDevelopment/Mobility_and_Skills_Key_Findings.pdf');
	var img15 = new ImageObj('/home/Publications/productivityInEngineering.jpg', 'ECITB Productivity In Engineering', 'http://www.ecitb.org.uk/documents/awardsQualifications/ResearchDevelopment/Producivity_in_Engineering_Exec_Summary.pdf');
	var img16 = new ImageObj('/home/Publications/sectorWorkforce.jpg', 'Sector Work force', 'http://www.ecitb.org.uk/documents/awardsQualifications/ResearchDevelopment/Sector_Workforce_Development_Plan.pdf');
	var img17 = new ImageObj('/home/Publications/SkillsDemandAndSupply.jpg', 'ECITB Skills Demand &amp; Supply', 'http://www.ecitb.org.uk/documents/corporate/Skills_Demand_Supply_and_Gaps_Executive_Summary.pdf');
	var img18 = new ImageObj('/home/Publications/skillsPledge.jpg', 'ECITB Skills Pledge', 'http://www.ecitb.org.uk/documents/programmes/sectorCompact/employer/skillspledge_foremployers.pdf');
	var img19 = new ImageObj('/home/Publications/skillsProfileOfTheECITB.jpg', 'ECITB Skills Profile Of The ECITB', 'http://www.ecitb.org.uk/documents/awardsQualifications/ResearchDevelopment/Skills_Profiled.pdf');
	var img20 = new ImageObj('/home/Publications/statutory_manpower_payroll_return.jpg', 'ECITB Statutory Manpower Payroll Return', 'http://www.ecitb.org.uk/documents/corporate/StatutoryManpowerAndPayrollReturnGuidanceNotes.pdf');
	var img21 = new ImageObj('/home/Publications/WorkforceSkillsAndTrainingIssues.jpg', 'ECITB Work force Skills &amp; Training Issues', 'http://www.ecitb.org.uk/documents/corporate/2007_Contracting_Community_Joint_Report.pdf');
	
	var imagePublications= new ImageGadget([img1, img3, img4, img5, img6, img8, img9, img10, img14, img15, img16, img17, img18, img19, img20, img21]);
	imagePublications.keyword = 'Publications';
	imagePublications.imgCount = 2;
	imagePublications.init();
	jQuery('#leftPublications').click(function()
	{
		imagePublications.slide(2);
	});
	jQuery('#rightPublications').click(function()
	{
		imagePublications.slide(0);
	});
});