		currentID = null ;
		currentHasFull = null ;
		portfolioXML = "portfolio.xml" ;
		mtFolder = 'portfolio/main-thumbs/' ; // Main Thumbnails Folder
		fullFolder = 'portfolio/full/' ; // Main Full Size
		panelHeight = 0 ;
		//d = new Date() ;
		d = new Date() ;
		portfolioXML = portfolioXML + '?date=' + d.getTime() ;
		//alert(portfolioXML);
		
		
		jQuery(document).ready(function($) {
			
			portfolioOpen = 0 ;
			fullsizeOpen = 0 ;
			fullsizeHeight = '' ;
			openID = 1 ;
			
			//	--------------------------------------
			//	Button behaviours on thumbs
			//	--------------------------------------
			
			jQuery("#portfolio-thumbs ul li").each(function(a){
				
				jQuery(this).fadeTo('slow', 0.6);
				
				jQuery(this).mouseenter(function(){
					jQuery(this).dequeue() ;
					jQuery(this).fadeTo('slow',1);
				});
				
				jQuery(this).mouseleave(function(){
					jQuery(this).dequeue() ;
					jQuery(this).fadeTo('slow',0.6);
				});
				
				jQuery(this).mousedown(function(){
					
					if(portfolioOpen == 0){
						
						// Opens panel if none open
						
						changeInfo( jQuery(this).attr('id').substr(3,1));
						jQuery("#full-image").fadeOut(0) ;
						jQuery("#thumb-desc").fadeIn(0) ;
						jQuery('#item-desc').fadeOut(0);
						jQuery('#item-image').fadeOut(0);
						jQuery('#portfolio-item').css({height: ''}) ;
						jQuery('#portfolio-item').slideDown(1000,function(){
							
							jQuery('#item-image').css({visibility: 'visible', display: 'none'}).fadeIn(1000, function(){
									jQuery('#item-desc').css({visibility: 'visible', display: 'none'}).fadeIn(1000) ;
							});	
							
							portfolioOpen = 1 ;
												
						}) ;
						
						openID = jQuery(this).attr('id').substr(3,1) ;
						
					} else if (portfolioOpen == 1 && jQuery(this).attr('id').substr(3,1) == openID) {
						
						// Closes panel if clicked on thumb of open one.
											
						jQuery('#portfolio-item').css('height', jQuery('#portfolio-item').height() + 'px') ;
						jQuery('#item-desc').fadeOut(1000, function(){
							jQuery('#item-image').fadeOut(1000, function(){
									
									//jQuery('#portfolio-item').css('min-height','');
									//jQuery('#portfolio-item').css({height: ''}) ;
									jQuery('#portfolio-item').slideUp(1000, function(){
										
										jQuery("#thumb-desc").fadeIn(0)
										jQuery("#full-image").fadeOut(0) ;

										jQuery('#portfolio-item').css('height','');
									}) ;
									
									jQuery('#item-desc').css({visibility: 'hidden', display: 'block'}) ;
									jQuery('#item-image').css({visibility: 'hidden', display: 'block'}) ;
								
								
								
								portfolioOpen = 0 ;
								openID = 0 ;
								
							});
						}); 
					
					} else {
					
						// If already open change to another
						var currentID = jQuery(this).attr('id').substr(3,1) ;
						//getItem(currentID);
						
						jQuery("#full-image").fadeOut(1000,function(){
						
							jQuery('#portfolio-item').css('height', jQuery('#portfolio-item').height() + 'px') ;
							
							jQuery('#item-desc').fadeOut(1000, function(){
								jQuery('#item-image').fadeOut(1000, function(){
									
									jQuery("#thumb-desc").fadeIn(0) ;												
									jQuery('#item-desc').fadeOut(0);
									jQuery('#item-image').fadeOut(0);
									changeInfo(currentID) ;
									jQuery('#portfolio-item').css('min-height','252px')
									jQuery('#portfolio-item').animate({height: jQuery('#item-desc').height() + 'px'}) ;
									jQuery('#item-image').fadeIn(1000, function(){
										jQuery('#item-desc').fadeIn(1000, function(){
										//jQuery('#portfolio-item').css({height: ''}) ;
											
										}) ;
									}) ;
									
								}) ;
							}) ;
						
						}) ;
						
						openID = jQuery(this).attr('id').substr(3,1) ;
						
					}
					
				}) ;
			});
			
			// For thumb
			jQuery("#item-image").mouseenter(function(){
					
				if(currentHasFull == true){
					jQuery("#item-control").dequeue() ;
					//jQuery("#item-control").animate({bottom:'0'},1000);
					jQuery("#item-control").slideDown(1000);
				} else {
					jQuery("#item-image").css('cursor','default');
				}
				
			}) ;
				
				
			jQuery("#item-image").mouseleave(function(){
					
					if(currentHasFull == true){
						
						jQuery("#item-control").dequeue() ;
						//jQuery("#item-control").animate({bottom:'-26px'},1000);
						jQuery("#item-control").slideUp(1000);
					
					} else {
						jQuery("#item-image").css('cursor','pointer');
					}
					
			}) ;
			
			jQuery("#item-image").mousedown(function(){
				
				if(currentHasFull == true){
					
					panelHeight = jQuery('#portfolio-item').height() + 'px' ;
					jQuery('#portfolio-item').animate({height: fullsizeHeight}) ;
					
					jQuery("#thumb-desc").fadeOut(1000, function(){
						jQuery("#full-image").fadeIn(1000) ;
					}) ;
				
				} else {
				
					// If no full image present, do nothing
				
				}
			
			});
			
			// For full image
			
			jQuery('#item-control-full').css('display:none');
			
			jQuery("#full-image").mouseenter(function(){
				jQuery('#item-control-full').slideDown(500);	
			}) ;
			
			jQuery("#full-image").mouseleave(function(){
				jQuery('#item-control-full').slideUp(500);	
			}) ;

			jQuery("#full-image").mousedown(function(){
				
				jQuery("#full-image").fadeOut(1000, function(){
						
						jQuery("#thumb-desc").fadeIn(1000, function(){	
							jQuery('#portfolio-item').animate({height: jQuery('#item-desc').height() + 'px'}) 
						}) ;
					}) ;
			
			}) ;
			
			
		}) ;
		
		
		
		
		
		function drawPortfolio(){
			
			jQuery.ajax({
		
				type: "GET",
				url: portfolioXML,
				dataType: "xml",
				success: function(xml) {
						
						jQuery(xml).find('item').each(function(){
							//jQuery(this).find('id').text() ;
							
							
							
						});

				}
			});
			
		
		} ;
		
		function getItem(id){
		
			jQuery.ajax({
		
				type: "GET",
				url: portfolioXML,
				dataType: "xml",
				success: function(xml) {
						
						jQuery(xml).find('item').each(function(){
							if(jQuery(this).attr('id') == id){
								alert( jQuery(this).find('title').text() ) ;
							}
							
							
						});

				}
			});
			
		
		} ;
		
		function changeInfo(id){
		
			jQuery.ajax({
		
				type: "GET",
				url: portfolioXML,
				dataType: "xml",
				//cache: false,
				//contentType: 'text/xml',
				success: function(xml) {
						
						jQuery(xml).find('item').each(function(){
						
							if(jQuery(this).attr('id') == id){
								//alert( jQuery(this).find('description').html() );
								//currentHasFull
								jQuery('#item-desc h3').text( jQuery(this).find('title').text() ) ;
								jQuery('#item-desc-actual').html(jQuery(this).find('description').text()) ;
								jQuery('#item-image').css('background-image', 'url(' + mtFolder + jQuery(this).find('picture:first thumb').text() + ')' ) ;
								if(jQuery(this).find('picture:first full').text() != ''){
									jQuery('#full-image').css('background-image', 'url(' + fullFolder + jQuery(this).find('picture:first full').text() + ')' ) ;
									jQuery('#full-image').css('height', jQuery(this).find('picture:first full_height').text() ) ;
									currentHasFull = true ;
								} else {
									currentHasFull = false ;
								}
								
								fullsizeHeight = jQuery(this).find('picture:first full_height').text() ;
							}
							
							
						});

				}
			});
			
		} ;
		