$(document).ready(function(){
			var
			$switchPrice,
			$switchInfo,
			$prev,
			$next,
			$bikes = $('#bikes'),
			$slides = $bikes.find('.bike'),
			width = $slides.eq(0).outerWidth(true),
			total = $slides.length * width,
			$slideLinks = $slides.find('.photo'),
			//left = Math.floor($slides.length/2) * width,
			left = 0,
			speed = 800,
			$clone = $bikes
				.clone()
				.find('.overlay')
				.remove()
				.end()
				.attr('id','clone')
				.appendTo('#bikes')
			$desc = $clone.find('.desc');
			$price = $clone.find('.price');
			$wraps = $('.wrap'),
			$tabs = $('#tabs li');
			
			$('a.tabLink').click(function(e){
				e.preventDefault();
				$tabs.removeClass('current');
				$(this).parent().addClass('current');
			});
			
			$wraps.css({marginLeft:-left});
			
			$('body').css({paddingTop : Math.max(document.documentElement.clientHeight - $('#content').height(), 0) / 2 + $(window).scrollTop()});
			
			function animate(){
				$wraps.stop().animate({marginLeft:-left},speed);				
			}
			
			$slideLinks.click(function(e){
				var index = $slideLinks.index(this);
				e.preventDefault();
				left = width * index;
				animate();
			});
			
			$clone.find('.bike').click(false);
			
			$switchInfo = $('<a href="#" id="switchInfo" class="on">INFO</a>').click(function(){
				$(this).addClass('on').css({cursor:'auto'});
				$switchPrice.removeClass('on').css({cursor:'pointer'});
				$price.fadeOut(function() { 
					$desc.fadeIn();
				});
				
			}),
			
			$switchPrice = $('<span href="#" id="switchPrice">PRICES</span>').click(function(){
				$(this).addClass('on').css({cursor:'auto'});
				$switchInfo.removeClass('on').css({cursor:'pointer'});
				$desc.fadeOut(function() { 
					$price.fadeIn();
				});
				
			}),
			
			$next = $('<a href="#" id="next"/>').click(function(e){
				e.preventDefault();
				
				left += width;
				if(left > total - width){
					left = total - width;
				}
				animate();
			});
			
			$prev = $('<a href="#" id="prev"/>').click(function(e){
				e.preventDefault();
				
				left -= width;
				if(left <= 0){
					left = 0;
				}
				animate();
			});
			
			$clone.append($switchPrice, $switchInfo, $prev, $next);
			
			 //Contact Form
			$('a.contact_link').colorbox({href:"/contactform.php", initialWidth:635, initialHeight:340, width:635, height:340, transition:"fade", opacity:0.7, speed:0});
		
			$("input[name='submit']").live("mouseover", function(){
					if($.browser.msie){
						$(this).css({"background-position":"left bottom"});
					} else {
						$(this).stop().fadeTo(300, 0);
					}
				}).live("mouseout", function(){
					if($.browser.msie){
						$(this).css({"background-position":"left top"});
					} else {
						$(this).stop().fadeTo(300, 1);
					}
				}).live('click', function() {
					$('#contact_form').fadeTo("fast", 0, function () {
					 $(this).hide();
					 postit();
				});
				return false;
			});
		
			function postit(){
					$.post('/contactform.php', {'update':'update', 'name': $("input[name='name']").val(), 'email' : $("input[name='email']").val(), 'tel' : $("input[name='tel']").val(), 'message' : $("textarea[name='message']").val(), 'submit' : 'submit'}, 
					function(data){
						$('#contact_form').html(data);
						$('#contact_form').show().fadeTo("fast",1);
					}, "html");
			}


		});
