$(document).ready(function(){
	var pathname = window.location.pathname.lastIndexOf("/");
	var filename = window.location.pathname.substr(pathname);
	var changename = filename.replace('.php', '');
	var lastname = changename.replace('/', '');
	if(lastname == 0){
		lastname = 'index';	
		}
	
	$name = 'xml/'+lastname+'GalleryData.xml';
	
	$.ajax({
		
		type: "GET",
		url: $name,
		dataType: "xml",
		
		success: function(xml) {
		
			
			$(xml).find('img').each(function(){
				var pathname = window.location.pathname.lastIndexOf("/");
				var filename = window.location.pathname.substr(pathname);
				var changename = filename.replace('.php', '');
				var lastname = changename.replace('/', '');
				if(lastname == 0){
					lastname = 'index';	
				}
				var img = $(this).text();
				
				var image = $('<img class="galImg" src="img/galleryPics/'+lastname+'/'+img+'" />').appendTo('#mainContainer');
				
			});
		
		
		
			$(xml).find('imgInfo').each(function(){
					
				var id = $(this).attr('id');
				var heading = $(this).find('heading').text();
				var description = $(this).find('description').text();
				var date = $(this).find('date').text();
				$('<h4 class="heading" id="heading'+id+'"></h4>').html(heading).appendTo('.imgData');
				$('<p class="desc" id="desc'+id+'"></p>').html(description).appendTo('.imgData');
				$('<p class="date" id="date'+id+'"></p>').html(date).appendTo('.imgData');
			});	
	
		}
	
	});
	
	
	$('.portfolio #gallery, .recruitment #gallery').hover(function(){
			
			$('#gallery .imgData').animate({
				marginTop: '0px'
			
		}, 'easeOutSine');
	
	}, function(){
		$('#gallery .imgData').animate({
				marginTop: '100px'
			
		});
		
	});
	
	
	$('#panel ul #PB1 a').css({
			backgroundColor: '#F15A2A'
		});	
	
	$('.heading').css({
			display: 'none',
			opacity: '0'
		});
	
	$('#panel ul li a').click(function(){
		$('.heading, .desc, .date').css({
			display: 'none',
			opacity: '0'
		});
	});
	
	
	
	$('#panel ul #PB1 a').click(function(){
		
		$('#mainContainer').animate({
			marginTop: '0px'	  <!--Swap tab image-->  
		});	
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		$('#heading1, #desc1, #date1').css({
			display: 'block'
		});
		$('#heading1, #desc1, #date1').fadeTo(500, 1);
		
	});
		
	$('#panel ul #PB2 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-350px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		
		$('#heading2, #desc2, #date2').css({
			display: 'block'
		});
		$('#heading2, #desc2, #date2').fadeTo(500, 1);
		
	});	
	
	$('#panel ul #PB3 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-700px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		$('#heading3, #desc3, #date3').css({
			display: 'block'
		});
		$('#heading3, #desc3, #date3').fadeTo(500, 1);
		
	});	
	
	$('#panel ul #PB4 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-1050px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		$('#heading4, #desc4, #date4').css({
			display: 'block'
		});
		$('#heading4, #desc4, #date4').fadeTo(500, 1);
		
	});	
	
	$('#panel ul #PB5 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-1400px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		$('#heading5, #desc5, #date5').css({
			display: 'block'
		});
		$('#heading5, #desc5, #date5').fadeTo(500, 1);		
	});	
	
	$('#panel ul #PB6 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-1750px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		$('#heading6, #desc6, #date6').css({
			display: 'block'
		});
		$('#heading6, #desc6, #date6').fadeTo(500, 1);
	});	
	
	$('#panel ul #PB7 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-2100px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		$('#heading7, #desc7, #date7').css({
			display: 'block'
		});
		$('#heading7, #desc7, #date7').fadeTo(500, 1);
	});	
	
	$('#panel ul #PB8 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-2450px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		$('#heading8, #desc8, #date8').css({
			display: 'block'
		});
		$('#heading8, #desc8, #date8').fadeTo(500, 1);
		
	});	
	
	$('#panel ul #PB9 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-2800px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});			
		$('#heading9, #desc9, #date9').css({
			display: 'block'
		});
		$('#heading9, #desc9, #date9').fadeTo(500, 1);
	});
	
	$('#panel ul #PB10 a').click(function(){
		
		$('#mainContainer').animate({
			marginTop: '-3150px'	  <!--Swap tab image-->  
		});	
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		$('#heading10, #desc10, #date10').css({
			display: 'block'
		});
		$('#heading10, #desc10, #date10').fadeTo(500, 1);
		
	});
		
	$('#panel ul #PB11 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-3500px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		
		$('#heading11, #desc11, #date11').css({
			display: 'block'
		});
		$('#heading11, #desc11, #date11').fadeTo(500, 1);
		
	});	
	
	$('#panel ul #PB12 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-3850px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		$('#heading12, #desc12, #date12').css({
			display: 'block'
		});
		$('#heading12, #desc12, #date12').fadeTo(500, 1);
		
	});	
	
	$('#panel ul #PB13 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-4200px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		$('#heading13, #desc13, #date13').css({
			display: 'block'
		});
		$('#heading13, #desc13, #date13').fadeTo(500, 1);
		
	});	
	
	$('#panel ul #PB14 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-4550px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		$('#heading14, #desc14, #date14').css({
			display: 'block'
		});
		$('#heading14, #desc14, #date14').fadeTo(500, 1);		
	});	
	
	$('#panel ul #PB15 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-4900px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		$('#heading15, #desc15, #date15').css({
			display: 'block'
		});
		$('#heading15, #desc15, #date15').fadeTo(500, 1);
	});	
	
	$('#panel ul #PB16 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-5250px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		$('#heading16, #desc16, #date16').css({
			display: 'block'
		});
		$('#heading16, #desc16, #date16').fadeTo(500, 1);
	});	
	
	$('#panel ul #PB17 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-5600px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});
		$('#heading17, #desc17, #date17').css({
			display: 'block'
		});
		$('#heading17, #desc17, #date17').fadeTo(500, 1);
		
	});	
	
	$('#panel ul #PB18 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-5955px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});			
		$('#heading18, #desc18, #date18').css({
			display: 'block'
		});
		$('#heading18, #desc18, #date18').fadeTo(500, 1);
	});
	
	$('#panel ul #PB19 a').click(function(){
		$('#mainContainer').animate({
			marginTop: '-6300px'	  <!--Swap tab image-->  
		});
		$('#panel ul li a').css({
			backgroundColor: '#fff'
		});
		$(this).css({
			backgroundColor: '#F15A2A'
		});			
		$('#heading19, #desc19, #date19').css({
			display: 'block'
		});
		$('#heading19, #desc19, #date19').fadeTo(500, 1);
	});
	
 
});
