$(document).ready(function(){
	$("li." + page_handle + "-item").addClass("active");
 	var $list = $('ul.gbp-menu');
	var $viewport = $('div.gbp-menu');
	var item_length = 138;
	var item_count = $("li.gbp-list-item").length ;
	$list.width(item_count * item_length);
	//var $list_pos = -1024;
	var start_list_pos = -((item_count / 3) * item_length);
	//var list_pos = start_list_pos;
	
	if (page_handle == "" || (page_handle == "get-a-quote")) {
	 var current_list_pos = -966;
	//alert(page_handle);	
	} else {
		var position = $("li#" + page_handle + "-item").position();
		var current_list_pos =  -(position.left + 1) ;
		if ($.browser.msie || $.browser.safari) {current_list_pos = current_list_pos + 1}
		}
	//alert(current_item_pos);
	var list_pos = current_list_pos;
//	alert(list_pos);
	$list.css("left", current_list_pos);
	
 	$(".gbp-menu.back.btn").click(function(){
 		var new_pos = list_pos + item_length;
		list_pos = new_pos;
		//$list.stop().animate({'left':new_pos}, {duration:1000,easing:'easeOutExpo'});
			if (list_pos == -(966) || list_pos == -(0) ) {
				list_pos = start_list_pos;
				//alert('at start of center list');
				$('ul.gbp-menu').css("left","-1104px");
				$list.stop().animate({'left':list_pos}, {duration:1000,easing:'easeOutExpo'});
				
			} else {
				$list.stop().animate({'left':new_pos}, {duration:1000,easing:'easeOutExpo'});
			}
 	});

		$(".gbp-menu.forward.btn").click(function(){
			
	 		var new_pos = list_pos - item_length;
			list_pos = new_pos;
				//if (list_pos == -1518 || list_pos == -2208 ) {
				// if (list_pos == -1518) {
				// 	list_pos = -(552);
					if (list_pos <= -1518 ) {
						list_pos = list_pos - start_list_pos;
					//alert('at end of center list');
					$('ul.gbp-menu').css("left","-414px");
					$list.stop().animate({'left':list_pos}, {duration:1000,easing:'easeOutExpo'});
				} else {
					$list.stop().animate({'left':new_pos}, {duration:1000,easing:'easeOutExpo'});
				}
	 	});
	
		$(".gbp-menu.btn").hover(
					//alert('hovering');
					function () {
						$(this).css("cursor", "pointer");
						$(this).css("background-color", "#81a151");
					},
					function () {
						$(this).css("background-color", "#263412");
					}
			);
					
 });