// List of Tabs
var Tabs = {
		'Latest'	: 'clients/00Latest.php',
		'YSL' : 'clients/ysl.php',
		'Oscar De La Renta' : 'clients/oscarDeLaRenta.php',
		'Est&eacute;e Lauder'	: 'clients/esteeLauder.php',
		'Janet Waddell Hair Products'	: 'clients/janetWaddell.php',
		'Eautrois' : 'clients/eautrois.php',
		'Hollywood Trading Company' : 'clients/hollywoodTradingCo.php',
		'Express' : 'clients/express.php',
		'Natural Beauty Basic' : 'clients/naturalBeautyBasic.php',
		'Puma' : 'clients/puma.php',
		'Dockers Outerwear' : 'clients/dockersOuterwear.php',
		'Levi&rsquo;s Outerwear <i> Levis </i>' : 'clients/levisOuterwear.php',
		'Epoca'	: 'clients/epoca.php',
		'Ebel'	: 'clients/ebel.php',
		'Harry Winston' : 'clients/harryWinston.php',
		'Hilfiger Fragrance' : 'clients/hilfiger.php',
		'Matrix L&rsquo; Oreal' : 'clients/matrixLOreal.php',
		'Smacky Glam' : 'clients/smackyGlam.php',
		'Sergio Rossi'	: 'clients/sergioRossi.php'
};

$(document).ready(function(){
	/* This code is executed after the DOM has been completely loaded */
	
	/* Looping through the Tabs object: */
	var z=0;
	$.each(Tabs,function(i,j){
		/* Sequentially creating the tabs and assigning a color from the array: */
		var tmp = $('<li><a href="#" class="tab '+i+'">'+i+'</a></li>');
		
		/* Setting the page data for each hyperlink: */
		tmp.find('a').data('page',j);
		
		/* Adding the tab to the UL container: */
		$('ul.tabContainer').append(tmp);
	})
		
	$('.tabContainer li a').click(function(){
		$('.tabContainer li a').removeClass('active');
		$(this).addClass('active');
	});
	$('.Latest').parent().addClass('hide');

	
	/* Caching the tabs into a variable for better performance: */
	var the_tabs = $('.tab');
	
	the_tabs.click(function(e){
		/* "this" points to the clicked tab hyperlink: */
		var element = $(this);

		/* Checking whether the AJAX fetched page has been cached: */
		if(!element.data('cache'))
		{	
			$.get(element.data('page'),function(msg){
				$('#contentHolder').html(msg);
				
				/* After page was received, add it to the cache for the current hyperlink: */
				element.data('cache',msg);
			});
		}
		else $('#contentHolder').html(element.data('cache'));
		
		e.preventDefault();
	});
	
	/* Emulating a click on the first tab so that the content area is not empty: */
	the_tabs.eq(0).click();
});
