var photoGallery = {
	hideelements:function(n){
		for(i=1; i<=n; i++) {
			$('#bigImage'+i).css({'display':'none'})
		}
	},
	removeclass:function(n) {
		for(i=0; i<n; i++) {
			$('.thumb').eq(i).removeClass('active')
		}
	},
	addclass:function(e){
		e.addClass('active')
	},
	animation:function(e){
		e.fadeIn('slow')
	},
	changetitle:function(title){
		$('#bigImageTitle').text(title)
	},
	
	initialize:function(){ // initialize function starts
		thumbs=$('.thumb').length;
		current=$('.thumb.active').children('a').attr('rel');
		current=parseInt(current.substr(8,1))
		
		$('.thumb').click(function(a){
			photoGallery.removeclass(thumbs)
			photoGallery.hideelements(thumbs)
			photoGallery.addclass($(this))
			photoGallery.animation($('#'+$(this).children('a').attr('rel')))
			photoGallery.changetitle($(this).children('a').attr('title'))
			current=$('.thumb.active').children('a').attr('rel');
			current=parseInt(current.substr(8,1))
		})
		
		
		$('#nextArrow').click(function(){
			if(current>=thumbs) {
				current=0;
			}
			current++;
			photoGallery.removeclass(thumbs)
			photoGallery.addclass($('.thumb').eq(current-1))
			photoGallery.hideelements(thumbs)
			photoGallery.animation($('#bigImage'+(current)))
			photoGallery.changetitle($('.thumb').eq(current-1).children('a').attr('title'))
		})
		
		$('#previousArrow').click(function(){
			current--;
			if(current<1){
				current=thumbs	
			}
			
			photoGallery.removeclass(thumbs)
			photoGallery.addclass($('.thumb').eq(current-1))
			photoGallery.hideelements(thumbs)
			photoGallery.animation($('#bigImage'+(current)))
			photoGallery.changetitle($('.thumb').eq(current-1).children('a').attr('title'))
		})
	} // initialize function ends
}
