var index = 0;
var arrow_x = 0;

$(function(){
	
	var pages = 0;
	$(".content_page").each(function(){
		pages++;				 
	});
	//alert((1000*pages)+"px" + $(".content_page_wrapper").css("width"));
	$(".content_page_wrapper").css("width", (1000*pages)+"px");
	
	//$(".content_page_wrapper").width((1000*pages)+"px");
	
	$(".content_main").css("height", $(".content_page:eq(0)").css('height'));
	
	$(".subnav_link").click(function(event){
		//event.preventDefault();
			
		var $th = $(this).parent();
    	index_new = $th.parent().children().index($th);
			//alert($(".content_page:eq(" + index_new + ")").css('height'));

		arrow_x = $(this).attr("arrow_x");
		if(index != index_new){
			index = index_new;
			//$(".content_page_wrapper").animate({left:(-1000*index)+'px'}, function(){$(".content_main").animate({height:$(".content_page:eq(" + index + ")").css('height')})});
			
			$(".content_page_wrapper").animate({left:(-1000*index)+'px'}, function(){$(".content_main").animate({height:$(".content_page:eq(" + index + ")").height()});});
			
			
			
			$(".subnav_indicator").animate({left:arrow_x+'px'});
			
		}
	
	});
	
	
	var myFile = document.location.toString();
	if (myFile.match('#')) { // the URL contains an anchor
		// click the navigation item corresponding to the anchor
		var myAnchor = '#' + myFile.split('#')[1];
		myAnchor = myAnchor.replace("#","");
		if(myAnchor != ''){
			subnav_to(myAnchor);
		}
	} else {
	}
	
});

function subnav_to(id){
	index = id;
	arrow_x = $(".subnav_link:eq(" + index + ")").attr("arrow_x");
	$(".content_page_wrapper").animate({left:(-1000*index)+'px'}, function(){$(".content_main").animate({height:$(".content_page:eq(" + index + ")").height()});});
	$(".subnav_indicator").animate({left:arrow_x+'px'});
}

function inputFocus(){
	//nothing
}


Cufon.replace('h1');
Cufon.replace('.column_subhead');
Cufon.replace('.nav ul li a');
