jQuery.noConflict();
jQuery.fn.Jexists = function(){return jQuery(this).length>0;}

var bigSlideSpan = 340;
var smallSlideSpan = 375;
var currentBig = 535;
var currentSmall = 0;
var currentBike = 5;
var numberOfBikes = 5;
var currentBikeNames = new Array('funk','nevis-lady','nevis-man','pico','disko');


function closeVideo(){jQuery('.header-back').animateNav();}

function resetProductTabs(){
	jQuery('.product-tab-index li').removeClass('checked').removeClass('checked-selected');
		jQuery('.product-tab-index li').each(function(){
			var filled = true;
			jQuery('.' + jQuery(this).find('a').attr('id') + ' select').each(function(){
				if(jQuery(this).val() == 'Choose an Option...' || jQuery(this).val() == '')
					filled = false;
			});
			if(filled){
				if(jQuery(this).hasClass('selected'))
					jQuery(this).addClass('checked-selected');
				else
					jQuery(this).addClass('checked');
			}
		});
}
function getPos(direction, slidespan, type){
	if(type == 'big'){
		if(direction){
			currentBig = (parseInt(currentBig) - slidespan);
			newPos = '(' + currentBig + 'px -20px)';
		}else{
			currentBig = (parseInt(currentBig) + slidespan);
			newPos = '(' + currentBig + 'px -20px)';
		}
	}else{
		if(direction){
			currentSmall = (parseInt(currentSmall) - slidespan);
			newPos = '(' + currentSmall + 'px 0px)';
		}else{
			currentSmall = (parseInt(currentSmall) + slidespan);
			newPos = '(' + currentSmall + 'px 0px)';
		}
	}
	return newPos;
}  

function FusedPreloadOptionLabels(attributeId){
	jQuery("#"+attributeId).val(jQuery("#"+attributeId + " option:nth-child(2)").val());
}

function ReloadSizes(attributeId){
	if(jQuery(attributeId).Jexists()){
		var optionCount = 0;
		var FusedAttributeOptions = new Array;
		var FusedAttributeOptionSelected = new Array;
		var FusedAttributeOptionIDs = new Array;
		
		if(!jQuery(attributeId+' option:selected').val().length>0){
		//	jQuery(attributeId).val(jQuery(attributeId + " option:nth-child(2)").val());
		}
		jQuery(attributeId).children('option').each(function(i, FusedOption){
			if(jQuery(FusedOption).val().length>0){
			FusedAttributeOptionIDs[optionCount] = jQuery(FusedOption).val();
    		FusedAttributeOptions[optionCount] = jQuery(FusedOption).text();
    		FusedAttributeOptionSelected[optionCount] = jQuery(FusedOption).is(':selected');
    		optionCount++;
    		}
		});	
		jQuery(attributeId + '-bikes').html('');
		if(FusedAttributeOptions.length>0){
			for (i=0;i<FusedAttributeOptionIDs.length ;i++) { 
					var appendClass = FusedAttributeOptionSelected[i] ? ' class="selected" ' : '';
				jQuery(attributeId + '-bikes').append('<li'+appendClass+'><a id="option-'+ FusedAttributeOptionIDs[i]+'" class="attribute528" title="'+FusedAttributeOptions[i]+'" href="#"><span class="text">'+FusedAttributeOptions[i].split(': ')[1]+'</span></a></li>');
			}
		}
	}
	
	jQuery('.size-picker li a').click(function(){
		jQuery('.size-picker li').removeClass('selected');
		jQuery(this).parent('li').addClass('selected');
		var optionID = jQuery(this).attr('id').split('-');
		jQuery("#"+jQuery(this).attr('class')).val(optionID[1]);
		//alert("#"+jQuery(this).attr('class'));
		spConfig.configureElement($(jQuery(this).attr('class')));
		resetProductTabs();
		return false;
	});
}

function FusedReloadOptionLabels(attributeId){
	if(jQuery(attributeId).Jexists()){
		var optionCount = 0;
		var FusedAttributeOptions = new Array;
		var FusedAttributeOptionIDs = new Array;
		jQuery(attributeId).children('option').each(function(i, FusedOption){
			if(jQuery(FusedOption).val().length>0){
			FusedAttributeOptionIDs[optionCount] = jQuery(FusedOption).val();
    		FusedAttributeOptions[optionCount] = jQuery(FusedOption).text();
    		optionCount++;
    		}
		});	
		if(FusedAttributeOptions.length>0){
			for (i=0;i<FusedAttributeOptionIDs.length ;i++) { 
					jQuery(attributeId + '-bikes #option-'+ FusedAttributeOptionIDs[i]).attr('title', FusedAttributeOptions[i]);
			};
		}
		Shadowbox.setup(); 
		setupPumaBikes();
	}
	ReloadSizes('#attribute528');
	

}
function showLoadBut(){jQuery('#sb-nav-close').removeClass('hide');}
function setupPumaBikes() {
    Shadowbox.setup('.product-pico a.assembly-video', {
        height:     554,
        width:      985,
        initialHeight: 0,
   			initialWidth: 0,
   			animate: true,
			onOpen: moveCloseLink,
   			onFinish: showLoadBut,
   			flashVars:  {
            clip_id:    "1893986",
            autoplay:   "1"
        }
    });
}

jQuery.fn.embedVideo = function() {
  return this.each(function(){
    var playerId = jQuery(this).attr('id');
	
    if (!playerId) {
      throw new Error('Must be called on an element which has an id');
    }
    jQuery(this).append('<span id="'+playerId+'-inner-flv"></span>');

	//jQuery(this).append('<video width="986" height="386" autoplay="true" preload="none" id="'+playerId+'-inner"><source src="/media/puma_movie.mp4" type="video/mp4"><source src="/media/puma_movie.ogv" type="video/ogg"><object id="'+playerId+'-inner-flv"></object></video>');
    var params = {
      allowscriptaccess: 'always',
      allowfullscreen: 'false',
      bgcolor: '000000'
    };

    var flashvars = {
      clip_id: jQuery(this).attr('id').split('-')[1], /* id is 'video-XXX' */
      server: 'www.puma-bikes.com',
      show_title : 0,
      show_byline : 0,
      show_portrait : 0,
      color : '000000',
      fullscreen : 1,
      autoplay : 1,
      js_api : 1,
      //js_onLoad : 'vimeoOnLoad',
      js_swf_id : playerId
    };
    
    var v = jQuery(".fp-video #"+playerId+"-inner"); // Are we dealing with a browser that supports <video>? 
    if ( !v.play ) { // If no, use Flash.
    	
      var params = {
        allowfullscreen: "true",
        allowscriptaccess: "always"
      };
      var flashvars = {
        file: "puma_movie.flv",
        image: "snapshot.jpg"
      };
	  
    swfobject.embedSWF('/media/movie.swf', playerId+'-inner-flv', jQuery(this).width(), jQuery(this).height(), "9.0.0", null, flashvars, params);
    }
  });
};

function vimeoOnLoad(playerId) {
  jQuery('#'+playerId).get(0).api_addEventListener('onFinish', 'vimeoOnFinish');
}

function vimeoOnFinish(playerId) {
  jQuery('#'+playerId).get(0).api_seekTo(0);
}

jQuery.fn.animateNav = function() {
  return this.each(function(){
  		var onlyfirst = true;
		var selectedFPOption =  jQuery(this).attr('class');
		if(jQuery('.quick-access').hasClass('minify')){
			jQuery('.header-back').fadeOut('fast', function(){
				if(!jQuery('.fp-video').is(':hidden')){
					var videoID = jQuery('.fp-video').attr('id');
					var parent = jQuery('.fp-video').parent();
					jQuery('.fp-video').fadeOut('fast').remove();
					parent.append('<div class="fp-video" id="'+videoID+'"><span class="hidden">&nbsp;</span></div>');
				}
				if(!jQuery('.frontpage-top-content').is(':hidden')){
					jQuery('.showonload').fadeOut('fast', function(){
						jQuery('.frontpage-top-content').slideUp('slow');
					});
				}
				jQuery('.quick-access').animate({"width": "0px"}, 300, function(){
					jQuery(this).removeClass('quick-push').animate({"width": "809px"}, 600, function(){
						jQuery('.nav, #header-cart, .mini-login, .redefining').fadeIn('fast');
					}).removeClass('minify');
				});
			});
		}else{
			jQuery('.nav, #header-cart,.mini-login, .block-login, .redefining').fadeOut('fast', function(){
				if(onlyfirst){ 
				 	onlyfirst = false;
					jQuery('.quick-access').animate({"width": "0px"}, 600, function(){
						jQuery(this).addClass('quick-push').animate({"width": "90px"}, 300, function(){
							jQuery('.header-back').fadeIn('fast',function(){
								if(selectedFPOption == 'fp-watch-video'){
									jQuery('.fp-video').embedVideo();
									jQuery('.fp-video').show();
								}
								if(selectedFPOption == 'fp-the-content'){
									jQuery('.frontpage-top-content').slideDown('slow', function(){
											jQuery('.showonload').fadeIn('fast');
									});
								}
						
							});
						}).addClass('minify');
					});
				}
			});
		}
	});
};

function moveCloseLink()
{
    cb=document.getElementById( 'sb-nav-close' );
    tb=document.getElementById( 'sb-title' );

    if( tb )
        tb.appendChild(cb);
    jQuery('#sb-nav-close').addClass('hide');
} 
Shadowbox.init({
			onFinish: showLoadBut,
			onOpen: moveCloseLink,
			overlayOpacity: 0.5,
   			showOverlay: true,
   			initialHeight: 0,
   			initialWidth: 0,
   			enableKeys: false,
   			animate: true,
   			   			modal: true
		}, setupPumaBikes);


jQuery(document).ready(function(){
	FusedReloadOptionLabels('#attribute531');
	/* PRODUCT */
	var hasTab2 = jQuery('.product-tab-2').Jexists();
	var hasTab3 = jQuery('.product-tab-3').Jexists();
	var hasTab4 = jQuery('.product-tab-4').Jexists();

		jQuery('.product-link-bar a').click(function(){
		jQuery('.product-tab').hide();
		jQuery('.'+this.id).show();		return false;
	});
	
	/* Spring Fling 
	jQuery('.products-grid .item').append('<a href="/" class="spring-badge" title="Qualify for Spring Fling 50% off"><span class="hide">Qualifies for Spring Fling 50% Off</span></a>');
	
	jQuery('.products-grid:last').append('<li class="item last din-grotesk grotesk-item "><br/><br/><p>SPRING HAS SPRUNG!<br/>SO PICK YOUR BIKE AND RIDE-A-PUMA<br/>INTO THE SUNNY DAYS AHEAD.</p></li>');


	jQuery('.onestepcheckout-coupons').append('<br/><br/><a href="mailto:info@puma-bikes.com?subject=SPRING FLING COUPON CODE REQUEST&body=Oops! I picked my bike but need a coupon code to get 50%25 off.  Please send it to the email address below. I understand that it will be sent to me within the next hour.  Thanks!%0d%0dEmail address:%0dName:%0dCountry:" class="din-grotesk coupon-checkout-link" style="">Need a coupon code? Click here</a>');	 
*/
	
	jQuery('.color-picker li a').click(function(){
		jQuery('.color-picker li').removeClass('selected');
		jQuery(this).parent('li').addClass('selected');
		var optionID = jQuery(this).attr('id').split('-');
		jQuery("#"+jQuery(this).attr('class')).val(optionID[1]);
		//alert("#"+jQuery(this).attr('class'));
		ReloadSizes('#attribute528');
		spConfig.configureElement($(jQuery(this).attr('class')));
		resetProductTabs();
		return false;
	});
	
	jQuery('.product-tab-action').click(function(){
		jQuery('.product-tab-action').parent('li').removeClass('selected');
		jQuery(this).parent('li').addClass('selected');
		jQuery('.product-tab-4, .product-tab-3, .product-tab-2, .product-tab-1').hide();
		if(hasTab2 && this.id == 'product-tab-3' && (!jQuery('#attribute528 option:selected').length || jQuery('#attribute528').val() == '')  ){
			jQuery('.product-tab-2').show();
			jQuery('.product-tab-action').parent('li').removeClass('selected');
			jQuery('#product-tab-2').parent('li').addClass('selected');
			if(!jQuery('#attribute528').hasClass('validation-failed'))
				jQuery('#attribute528').addClass('validation-failed');
			jQuery('#attribute528').parent().children('div').remove();
			jQuery('#attribute528').parent().append('<div style="" id="advice-required-entry-attribute528" class="validation-advice">This is a required field.</div>');
		} else {
			jQuery('#attribute528').removeClass('validation-failed');
			jQuery('#attribute528').parent().children('div').remove();
			jQuery('.' + this.id).show();
		}
		resetProductTabs();
		
		return false;
	});
	if(hasTab2){
		jQuery('#product-tab-2').css('display', 'block');
	}
	if(hasTab3){
		jQuery('#product-tab-3').css('display', 'block');
	}
	if(hasTab4){
		jQuery('#product-tab-4').css('display', 'block');
	}
	
	jQuery('.meet-links li a, .product-nav-bar li a').mouseover(function() {
	    jQuery(this).parent("li").addClass("selected");
  	}).mouseout(function(){
	    jQuery(this).parent("li").removeClass("selected");
  	});
  	
  	
  	jQuery('#header-cart').click(function() {
  		if (!jQuery('#header-cart .singleline').Jexists()){
  			if(jQuery('#cart-content').is(":hidden")) {
  				if(!jQuery('.block-login').is(":hidden")) {
  					jQuery('.block-login').slideUp('fast', function(){jQuery('#cart-content').slideDown("fast");});
	  			} else {
	  				jQuery('#cart-content').slideDown("fast");
	  			}
    		} else {
      			jQuery('#cart-content').slideUp('fast');
    		}
    	}
	});
  	jQuery('.product-nav-bar li a').click(function(){
  		jQuery('.product-nav-bar li').removeClass("current");
  		jQuery(this).parent("li").addClass("current");
  	});

	jQuery('.dnote').mouseover(function() {
	    jQuery(this).addClass("selected");
  	}).mouseout(function(){
	    jQuery(this).removeClass("selected");
  	});

	jQuery('.dnote').each(function() {
	   
	   jQuery(this).qtip({
			
		   content: jQuery(this).find('span').html(),
		   position: {
                  corner: { target: 'topRight', tooltip: 'bottomLeft' }
           },
			style: { 
		      width: 250,
		      padding: 10,
   		      background: '#ffffff',
		      color: 'black',
		      textAlign: 'left',
		      border: {
		         width: 2,
		         radius: 5,
		         color: '#000'
		      },
		   tip: 'bottomLeft'
		   }
		});
	});
	
	/* 3 WAYS TO BUY */
	function resetWays(id){
		jQuery('.'+id+' .inner-content').fadeOut('slow', function(){
			jQuery('.ways-tab-1').animate({right: 0+"px", width: 838+"px"}, { queue:false, duration:150 });
			jQuery('.ways-tab-2').animate({right: 0+"px", width: 594+"px"}, { queue:false, duration:150});
			jQuery('.ways-tab-3').animate({right: 0+"px", width: 340+"px"}, { queue:false, duration:150, complete: function(){
				jQuery('.'+id+' .content').fadeIn('slow');		
				jQuery('.ways-button').removeClass('selected');
			} });
		});
				
	}
	var current_way = '';
	jQuery('.ways-button').click(function(){
		
		if(jQuery(this).hasClass('selected')){
			resetWays(jQuery(this).attr('id'));
		}else{
			if(jQuery('.ways-button').hasClass('selected')){
				jQuery('.ways-button').removeClass('selected');//resetWays();
			}
			if(jQuery(this).attr('id') == 'ways-tab-1'){
				if(current_way.length > 0){
					jQuery(current_way+' .inner-content').fadeOut('slow', function(){
						jQuery('.ways-tab-1 .content').fadeOut('slow', function(){
							jQuery('.ways-tab-2').animate({right: 210+"px", width: 628+"px"}, { queue:false, duration:150 });
							jQuery('.ways-tab-2').animate({right: 0+"px", width: 230+"px"}, { queue:false, duration:150 });
							jQuery('.ways-tab-3').animate({right: 0+"px", width: 170+"px"}, { queue:false, duration:150 , complete: function(){
								if(current_way !== '.ways-tab-1')
									jQuery(current_way+' .content').fadeIn('slow');
								jQuery('.ways-tab-1 .inner-content').fadeIn('slow');		
								jQuery('#ways-tab-1').addClass('selected');
								current_way = '.ways-tab-1';	
					} });

				});
						
					});

				} else{
					jQuery('.ways-tab-1 .content').fadeOut('slow', function(){
						jQuery('.ways-tab-2').animate({right: 210+"px", width: 628+"px"}, { queue:false, duration:150 });
						jQuery('.ways-tab-2').animate({right: 0+"px", width: 230+"px"}, { queue:false, duration:150 });
						jQuery('.ways-tab-3').animate({right: 0+"px", width: 170+"px"}, { queue:false, duration:150 , complete: function(){
							jQuery('.ways-tab-1 .inner-content').fadeIn('slow');		
							jQuery('#ways-tab-1').addClass('selected');
							current_way = '.ways-tab-1';	
						} });

					});
				}
			}
			if(jQuery(this).attr('id') == 'ways-tab-2'){
				if(current_way.length > 0){
					jQuery(current_way+' .inner-content').fadeOut('slow', function(){

				jQuery('.ways-tab-2 .content').fadeOut('slow', function(){
					jQuery('.ways-tab-1').animate({right: 210+"px", width: 628+"px"}, { queue:false, duration:150, easing:'swing'});
					jQuery('.ways-tab-2').animate({width: 780+"px"}, { queue:false, duration:150, easing:'swing'});
					jQuery('.ways-tab-3').animate({right: 0+"px", width: 170+"px"}, { queue:false, duration:150, easing:'swing' , complete: function(){
						if(current_way !== '.ways-tab-2')
							jQuery(current_way+' .content').fadeIn('slow');
						jQuery('.ways-tab-2 .inner-content').fadeIn('slow');	
						jQuery('#ways-tab-2').addClass('selected');
						current_way = '.ways-tab-2';	
					} });

				});
						
					});

				} else{
				jQuery('.ways-tab-2 .content').fadeOut('slow', function(){
					jQuery('.ways-tab-1').animate({right: 210+"px", width: 628+"px"}, { queue:false, duration:150, easing:'swing'});
					jQuery('.ways-tab-2').animate({width: 780+"px"}, { queue:false, duration:150, easing:'swing'});
					jQuery('.ways-tab-3').animate({right: 0+"px", width: 170+"px"}, { queue:false, duration:150, easing:'swing' , complete: function(){
						jQuery('.ways-tab-2 .inner-content').fadeIn('slow');	
						jQuery('#ways-tab-2').addClass('selected');
						current_way = '.ways-tab-2';	
					} });

					});
				}
			}
			
			if(jQuery(this).attr('id') == 'ways-tab-3'){
			
			if(current_way.length > 0){
					jQuery(current_way+' .inner-content').fadeOut('slow', function(){

			
				jQuery('.ways-tab-3 .content').fadeOut('slow', function(){
					jQuery('.ways-tab-1').animate({right: 210+"px", width: 628+"px"}, { queue:false, duration:150 });
					jQuery('.ways-tab-2').animate({width: 780+"px"}, { queue:false, duration:150});
					jQuery('.ways-tab-3').animate({right: 0+"px", width: 715+"px"}, { queue:false, duration:150  , complete: function(){
						if(current_way !== '.ways-tab-3	')
							jQuery(current_way+' .content').fadeIn('slow');
						jQuery('.ways-tab-3 .inner-content').fadeIn('slow');		
						jQuery('#ways-tab-3').addClass('selected');
						current_way = '.ways-tab-3';	
					} });

				});
						
					});

				} else{
				
				jQuery('.ways-tab-3 .content').fadeOut('slow', function(){
					jQuery('.ways-tab-1').animate({right: 210+"px", width: 628+"px"}, { queue:false, duration:150 });
					jQuery('.ways-tab-2').animate({width: 780+"px"}, { queue:false, duration:150});
					jQuery('.ways-tab-3').animate({right: 0+"px", width: 715+"px"}, { queue:false, duration:150  , complete: function(){
						jQuery('.ways-tab-3 .inner-content').fadeIn('slow');		
						jQuery('#ways-tab-3').addClass('selected');
						current_way = '.ways-tab-3';
					} });

					});
				}
			}
		}
	});
	
	/* NAVIGATION ACTIONS */
	
	jQuery('.fp-watch-video, .header-back, .fp-the-content').click(function(){
		jQuery(this).animateNav();
		return false;
	});
	
	/* THIS WAS IPAD SWIPE FUNCTION
	// On document ready hide all images first
    jQuery("#imageShowcase img").hide();
    jQuery("#productImgDefault").show();

    jQuery("#colorSelector").change(function() {
        // Hide all images on slect element change action
        jQuery("#imageShowcase img").hide();

        // Get the value of selected option
        var optionValue = jQuery(this).attr('value');
        // Just a test to see if you're getting option value
        // alert(optionValue);

        // Get the content (aka inner HTML) of selected option
        var optionValueText = jQuery.trim(jQuery('#colorSelector :selected').text());

        // Just a test to see if you're getting right selected option inner text
        // alert(optionValueText);
        alert('Selected option has value: ' + optionValue + ' and inner text: ' + optionValueText);


        // Show the image based on selected value
        // Whatch out, case sensitive...
        jQuery("#productImg" + optionValueText).show();
    });

	
	
	/* BIKESLECTOR */	
	jQuery('.bike-link-'+currentBike).fadeIn('fast');
	jQuery('.bike-selector').css({backgroundPosition: '535px -20px'});
	jQuery('.product-box-inner').css({backgroundPosition: '0px 0px'});

	jQuery('.bike-selector .nextPage').click(function(){
		if(!jQuery('.bikesplash').is(':hidden')){

		jQuery(".confandbuy").animate({width:'toggle', duration: 'slow'}, function(){
			jQuery('.bikesplash').fadeOut('slow', function() {
				jQuery('.bike-link-'+currentBike).fadeOut('fast', function() {
					currentBike = currentBike == 1 ? numberOfBikes : currentBike - 1;
					jQuery('.bike-selector').animate({backgroundPosition: getPos(false, bigSlideSpan, 'big')},500);
					jQuery('.product-box-inner').animate({backgroundPosition: getPos(false, smallSlideSpan,  'small')},700, function() {
						jQuery('.bike-link-'+currentBike).fadeIn('fast');
						jQuery('.meet-links li').removeClass('current');
						jQuery('.meet-'+currentBikeNames[currentBike-1]).addClass('current');
					});
				});
			});
		});
		} else {
				jQuery('.bike-link-'+currentBike).fadeOut('fast', function() {
					currentBike = currentBike == 1 ? numberOfBikes : currentBike - 1;
					jQuery('.bike-selector').animate({	backgroundPosition: getPos(false, bigSlideSpan, 'big')},500);
					jQuery('.product-box-inner').animate({backgroundPosition: getPos(false, smallSlideSpan,  'small')},700, function() {
						jQuery('.bike-link-'+currentBike).fadeIn('fast');
						jQuery('.meet-links li').removeClass('current');
						jQuery('.meet-'+currentBikeNames[currentBike-1]).addClass('current');
					});
				});
		}
		return false;
	});
	jQuery('.bike-selector .prevPage').click(function(){
		if(!jQuery('.bikesplash').is(':hidden')){
		jQuery(".confandbuy").animate({width:'toggle', duration: 'slow'}, function(){
			jQuery('.bikesplash').fadeOut('slow', function() {
				jQuery('.bike-link-'+currentBike).fadeOut('fast', function() {
					currentBike = currentBike == numberOfBikes ? 1 : currentBike + 1;
					jQuery('.bike-selector').animate({backgroundPosition: getPos(true, bigSlideSpan, 'big')},500);
					jQuery('.product-box-inner').animate({backgroundPosition: getPos(true, smallSlideSpan,  'small')},1000, function() {
						jQuery('.bike-link-'+currentBike).fadeIn('fast');
						jQuery('.meet-links li').removeClass('current');
						jQuery('.meet-'+currentBikeNames[currentBike-1]).addClass('current');
					});
				});
			});
		});
		}else{
				jQuery('.bike-link-'+currentBike).fadeOut('fast', function() {
					currentBike = currentBike == numberOfBikes ? 1 : currentBike + 1;
					jQuery('.bike-selector').animate({backgroundPosition: getPos(true, bigSlideSpan, 'big')},500);
					jQuery('.product-box-inner').animate({backgroundPosition: getPos(true, smallSlideSpan,  'small')},1000, function() {
						jQuery('.bike-link-'+currentBike).fadeIn('fast');
						jQuery('.meet-links li').removeClass('current');
						jQuery('.meet-'+currentBikeNames[currentBike-1]).addClass('current');
					});
				});
		}
		return false;
	});
	
	jQuery('.bike-link,  .bike-selector-wrapper .meet-links a').click(function(){
		var currentBikeName = jQuery(this).attr('href').split('#');
		jQuery('.meet-links li').removeClass('current');
		jQuery('.meet-'+currentBikeName[1]).addClass('current');
		jQuery('.bikesplash').fadeOut('slow', function(){
		jQuery('.bikesplash').remove();
		jQuery('.bike-selector').append('<div class="bikesplash"><div class="bikesplash-inner"><a class="confandbuy" href="/bikes/'+currentBikeName[1]+'.html/" title="Configure and buy this bike"><span class="hide">Configure and buy this bike</span></a></div></div>');
		jQuery('.bikesplash').addClass(currentBikeName[1]+'-real');
		jQuery('.bikesplash').fadeIn('slow', function(){
			jQuery(".confandbuy").animate({width:'toggle'}, {duration: 'slow'});
		});
		});
	});
	
	jQuery('.more-info-size').click(function(){showBikeSize();});
	
	/* IPHONE // IPAD FEATUES
	jQuery('.bike-selector').swipe({
	     swipeLeft: function() { jQuery('.bike-link-'+currentBike).fadeOut('fast', function() {
				currentBike = currentBike == numberOfBikes ? 1 : currentBike + 1;
				jQuery('.bike-selector').animate({backgroundPosition: getPos(true, bigSlideSpan, 'big')},500);
				jQuery('.product-box-inner').animate({backgroundPosition: getPos(true, smallSlideSpan,  'small')},1000, function() {
					jQuery('.bike-link-'+currentBike).fadeIn('fast');
				});
			});},
	     swipeRight: function() { jQuery('.bike-link-'+currentBike).fadeOut('fast', function() {
				currentBike = currentBike == 1 ? numberOfBikes : currentBike - 1;
				jQuery('.bike-selector').animate({backgroundPosition: getPos(false, bigSlideSpan, 'big')},500);
				jQuery('.product-box-inner').animate({backgroundPosition: getPos(false, smallSlideSpan,  'small')},1000, function() {
					jQuery('.bike-link-'+currentBike).fadeIn('fast');
				});
			}); },
	});
	*/
	//showLoading(true, 'Adding to shopping bag...');
	
});
/*
window.onload = function() {
if(jQuery('.catalog-product-view').hasClass('not-allowed')){

    // open a welcome message as soon as the window loads
    Shadowbox.open({
        content:    '/out-of-bounds',//'<div id="welcome-msg">Welcome to my website!</div>',
        player:     "iframe",
        title:      "Welcome",
        height:     300,
        width:      700
    });
	}
};
*/


	/* KEEP ME UPDATED */

function keepmesubmit(){

	jQuery('.keepmesubmit').click();
	return false;
}

function keepmevalidation(){
	var keepName = jQuery('.keep-me-updated #name');
	var keepEmail = jQuery('.keep-me-updated #mjujij-mjujij');
	
	if(keepEmail.hasClass('validation-failed') && keepName.hasClass('validation-failed') ){
		jQuery('.keepme-validation-message').html('Oops!  We need a bit more information: <br/>Please enter your name and email address before clicking "enter".').removeClass('hide');
	}
	
	if(!keepEmail.hasClass('validation-failed') && keepName.hasClass('validation-failed') ){
		jQuery('.keepme-validation-message').html('Oops!  We need a bit more information: <br/>Please enter your name before clicking "enter".').removeClass('hide');
	}
	
	if(keepEmail.hasClass('validation-failed') && !keepName.hasClass('validation-failed') && keepEmail.val() == ''){
		jQuery('.keepme-validation-message').html('Oops!  We need a bit more information: <br/>Please enter your email address before clicking "enter".').removeClass('hide');
	}
	
	if(keepEmail.hasClass('validation-failed') && !keepName.hasClass('validation-failed') && keepEmail.val() != ''){
		jQuery('.keepme-validation-message').html('Oops!  Seems there is a problem with the email address you entered. <br/>Please retype it and click "enter" again').removeClass('hide');
	}
	
	Cufon.replace('.din-grotesk', { fontFamily: 'DIN-grotesk' });
}

	
