$(document).ready(function() {
	//document.write("<?php echo 'hello'; ?>");
	var startHash = window.location.hash;
	startHash = startHash.replace("#","");
	if(!startHash){
		startHash = "home";
	}
	var screenWidth = $('body').width();
	var slides = ["home","facility", "plans", "location", "concept", "faq", "media", "contact"];
	var currIndex = 0;
	for(i=0;i<slides.length;i++){
		if(startHash == slides[i]){
			currIndex = i;
		}
	}

	$('.next').each(function(){
		$(this).css("right",(screenWidth-980)/2-60+"px");
		$(this).hide();
	});
	$('.prev').each(function(){
		$(this).css("left",(screenWidth-980)/2-60+"px");
		$(this).hide();
	});
	$('.slide').each(function(){
		$(this).css("width",screenWidth+"px");
	})
	
	$('#table-content').css("width",$('.slide').size()*screenWidth+"px");
	if(currIndex+1<slides.length){
		$('#next-'+startHash).show();
	}
	if(currIndex-1>=0){
		$('#prev-'+startHash).show();
	}
	if(currIndex==0){
		$("#logo").addClass('home');
	} else {
		$("#logo").removeClass('home');
	}
	
	$('.work-piece').each(function(i){
		if((i+1)%4 == 0 && i!=0){
			$(this).addClass('row-end');	
		}
	});
	
	$(window).resize(function () {
		screenWidth = $('body').width();
		$('#table-content').css("width",$('.slide').size()*screenWidth+"px");
		$('.next').each(function(){
			$(this).css("right",(screenWidth-980)/2+"px");
		});
		$('.prev').each(function(){
			$(this).css("left",(screenWidth-980)/2+"px");
		});
		$('.slide').each(function(){
			$(this).css("width",screenWidth+"px");
		})
		$('#logo').css("right",(screenWidth-980)/2+20+"px");
		window.location.hash=slides[currIndex];
		$('html').scrollTop(0);
	});
	$.localScroll.defaults.axis = 'x';
	$.localScroll.hash({
		target: '#content', // Could be a selector or a jQuery object too.
		queue:true,
		duration:0,
		onBefore:function(object,element,target){
			$('html').scrollTop(0);
		}
	});

	$.localScroll({
		target:'#content',
		duration:1000,
		hash:true,
		onBefore:function(object,element,target){
			for(i=0;i<slides.length;i++){
				if(slides[i]==$(element).attr("id")){
					currIndex = i;
					pageTracker._trackPageview('/slides/'+slides[i]);
				}
			}
			if(currIndex==0){
				$("#logo").addClass('home');
			} else {
				$("#logo").removeClass('home');
			}
			$('.next').each(function(i){
				if(i!=currIndex){
					$(this).hide();
				} else {
					if(i+1<slides.length){
						$(this).show();
					}
				}
			});
			
			$('.prev').each(function(i){
				if(i!=currIndex){
					$(this).hide();
				} else {
					if(i-1>=0){
						$(this).show();
					}
				}
			});
		}
	});

	
	
	
	

	
	
	


});




