skus = [];

// COLOR: Silver/Polarized Grey Gradient
sku = {
  style_name:       'Craft Outdoorsman',
  style_number:     'RB3422Q',
  id:               'sku_776',
  color:            'Silver/Polarized Grey Gradient',
  large_image:      '/usa/images/assets/2607/3e1db755d529579af5155b21ee4b160a.png?from=0x0&resize_to=529x390&size=2400x1400',
  lightbox_image:   '/usa/images/assets/2607/2f75c4bad9553397c4db8c38286519e3.png?from=0x0&resize_to=800&size=2400x1400',
  product_spins:    '', // OPTIMIZE: The asset_path helper adds default params to the image path which the 3d spin swf does not like. We need to prevent these additional params from appearing. 
  color_code:       '003/M8',
  availability:     'Usually Ships in 24-48 hours.',
  upc_id:           '777',
  price:            '$239.00',
  sku_number:       'RB3422Q-03',
  overlay_message:  'New Release',
  is_polarized:     true,
  is_new_release:   true,
  can_sell:         true,
  has_product_spin: false
};

if(!product_spins && sku.has_product_spin) {
	var product_spins = sku.product_spins;
}

skus['sku_776'] = sku;

// COLOR: Gunmetal/Crystal Grey Gradient
sku = {
  style_name:       'Craft Outdoorsman',
  style_number:     'RB3422Q',
  id:               'sku_778',
  color:            'Gunmetal/Crystal Grey Gradient',
  large_image:      '/usa/images/assets/2620/3e1db755d529579af5155b21ee4b160a.png?from=0x0&resize_to=529x390&size=2400x1400',
  lightbox_image:   '/usa/images/assets/2620/2f75c4bad9553397c4db8c38286519e3.png?from=0x0&resize_to=800&size=2400x1400',
  product_spins:    '', // OPTIMIZE: The asset_path helper adds default params to the image path which the 3d spin swf does not like. We need to prevent these additional params from appearing. 
  color_code:       '004/32',
  availability:     'Usually Ships in 24-48 hours.',
  upc_id:           '780',
  price:            '$189.00',
  sku_number:       'RB3422Q-04',
  overlay_message:  'New Release',
  is_polarized:     false,
  is_new_release:   true,
  can_sell:         true,
  has_product_spin: false
};

if(!product_spins && sku.has_product_spin) {
	var product_spins = sku.product_spins;
}

skus['sku_778'] = sku;

// COLOR: Arista /Brown Gradient
sku = {
  style_name:       'Craft Outdoorsman',
  style_number:     'RB3422Q',
  id:               'sku_779',
  color:            'Arista /Brown Gradient',
  large_image:      '/usa/images/assets/2621/3e1db755d529579af5155b21ee4b160a.png?from=0x0&resize_to=529x390&size=2400x1400',
  lightbox_image:   '/usa/images/assets/2621/2f75c4bad9553397c4db8c38286519e3.png?from=0x0&resize_to=800&size=2400x1400',
  product_spins:    '/usa/images/assets/2622/c8885fd01aac198f1672f376ed310a6b.png,/usa/images/assets/2623/c8885fd01aac198f1672f376ed310a6b.png,/usa/images/assets/2624/c8885fd01aac198f1672f376ed310a6b.png,/usa/images/assets/2625/c8885fd01aac198f1672f376ed310a6b.png,/usa/images/assets/2626/c8885fd01aac198f1672f376ed310a6b.png,/usa/images/assets/2627/c8885fd01aac198f1672f376ed310a6b.png,/usa/images/assets/2628/c8885fd01aac198f1672f376ed310a6b.png,/usa/images/assets/2629/c8885fd01aac198f1672f376ed310a6b.png,/usa/images/assets/2630/c8885fd01aac198f1672f376ed310a6b.png,/usa/images/assets/2631/c8885fd01aac198f1672f376ed310a6b.png,/usa/images/assets/2632/c8885fd01aac198f1672f376ed310a6b.png,/usa/images/assets/2633/c8885fd01aac198f1672f376ed310a6b.png', // OPTIMIZE: The asset_path helper adds default params to the image path which the 3d spin swf does not like. We need to prevent these additional params from appearing. 
  color_code:       '001/51',
  availability:     'Usually Ships in 24-48 hours.',
  upc_id:           '781',
  price:            '$189.00',
  sku_number:       'RB3422Q-05',
  overlay_message:  'New Release',
  is_polarized:     false,
  is_new_release:   true,
  can_sell:         true,
  has_product_spin: true
};

if(!product_spins && sku.has_product_spin) {
	var product_spins = sku.product_spins;
}

skus['sku_779'] = sku;

// COLOR: Silver/Crystal Grey Gradient
sku = {
  style_name:       'Craft Outdoorsman',
  style_number:     'RB3422Q',
  id:               'sku_780',
  color:            'Silver/Crystal Grey Gradient',
  large_image:      '/usa/images/assets/2634/3e1db755d529579af5155b21ee4b160a.png?from=0x0&resize_to=529x390&size=2400x1400',
  lightbox_image:   '/usa/images/assets/2634/2f75c4bad9553397c4db8c38286519e3.png?from=0x0&resize_to=800&size=2400x1400',
  product_spins:    '', // OPTIMIZE: The asset_path helper adds default params to the image path which the 3d spin swf does not like. We need to prevent these additional params from appearing. 
  color_code:       '003/32',
  availability:     'Usually Ships in 24-48 hours.',
  upc_id:           '782',
  price:            '$189.00',
  sku_number:       'RB3422Q-06',
  overlay_message:  'New Release',
  is_polarized:     false,
  is_new_release:   true,
  can_sell:         true,
  has_product_spin: false
};

if(!product_spins && sku.has_product_spin) {
	var product_spins = sku.product_spins;
}

skus['sku_780'] = sku;

// COLOR: Arista /Brown Gradient Polarized
sku = {
  style_name:       'Craft Outdoorsman',
  style_number:     'RB3422Q',
  id:               'sku_781',
  color:            'Arista /Brown Gradient Polarized',
  large_image:      '/usa/images/assets/2747/3e1db755d529579af5155b21ee4b160a.png?from=0x0&resize_to=529x390&size=2400x1400',
  lightbox_image:   '/usa/images/assets/2747/2f75c4bad9553397c4db8c38286519e3.png?from=0x0&resize_to=800&size=2400x1400',
  product_spins:    '', // OPTIMIZE: The asset_path helper adds default params to the image path which the 3d spin swf does not like. We need to prevent these additional params from appearing. 
  color_code:       '001/M7',
  availability:     'Usually Ships in 24-48 hours.',
  upc_id:           '778',
  price:            '$239.00',
  sku_number:       'RB3422Q-01',
  overlay_message:  'New Release',
  is_polarized:     true,
  is_new_release:   true,
  can_sell:         true,
  has_product_spin: false
};

if(!product_spins && sku.has_product_spin) {
	var product_spins = sku.product_spins;
}

skus['sku_781'] = sku;

// COLOR: Arista /Green Gradient Mirror Polarized
sku = {
  style_name:       'Craft Outdoorsman',
  style_number:     'RB3422Q',
  id:               'sku_782',
  color:            'Arista /Green Gradient Mirror Polarized',
  large_image:      '/usa/images/assets/2606/3e1db755d529579af5155b21ee4b160a.png?from=0x0&resize_to=529x390&size=2400x1400',
  lightbox_image:   '/usa/images/assets/2606/2f75c4bad9553397c4db8c38286519e3.png?from=0x0&resize_to=800&size=2400x1400',
  product_spins:    '', // OPTIMIZE: The asset_path helper adds default params to the image path which the 3d spin swf does not like. We need to prevent these additional params from appearing. 
  color_code:       '001/M9',
  availability:     'Usually Ships in 24-48 hours.',
  upc_id:           '779',
  price:            '$239.00',
  sku_number:       'RB3422Q-02',
  overlay_message:  'New Release',
  is_polarized:     true,
  is_new_release:   true,
  can_sell:         true,
  has_product_spin: false
};

if(!product_spins && sku.has_product_spin) {
	var product_spins = sku.product_spins;
}

skus['sku_782'] = sku;

function facebox_footer_info()
{
	$(".zoom").click(function() {
	$("#facebox .footer").addClass("zoom").empty().append(
		'<div>' +	'<span class="sku_number">' + selected_sku.style_number + '</span>' + 
			'<span class="style_name">' + selected_sku.style_name + '</span>' +
			'<span><span class="color_code_text">Color Code:</span> ' + selected_sku.color_code + '</span>' + 
		'</div>');
  });
}

function load_flash_movie() 
{	
  // attributes  = {};
  // params      = {wmode:"transparent"};
  // flashvars   = {pName: product_spins, pPath:"", controller:true};
  // swfobject.embedSWF("/usa/flash/360_spins/360_standalone_colorize.swf", "3d_view", "688", "480", "9.0.0","expressInstall.swf", flashvars, params, attributes);
  // return false;
}

function select_sku(sku_id)
{
  selected_sku = skus[sku_id];
  $(".product_color_code .value").html(selected_sku.color_code);
  $(".product_sku .value").html(selected_sku.sku_number);
  $(".product_status .value").html(selected_sku.availability);
  $(".price .value").html(selected_sku.price);
  $("select#product_colors").val(sku_id);
  $("input#upc_number").attr("value", selected_sku.upc_id);
  $("#product_detail_image #primary_image").attr("src", selected_sku.large_image);
  $("#product_detail_image #product_controls .product_control.zoom").attr("href", selected_sku.lightbox_image);
  $("#product_related_items a.selected").removeClass("selected");
  $("#thumb_" + selected_sku.id + " a").addClass("selected");
  if(product_spins) {
    $("#3d_view_button").show();
  } else {
    $("#3d_view_button").hide(); 
  }
  if(!selected_sku.can_sell) {
    $("input.submit").attr("disabled", true);
    $("input.submit").addClass("disabled");
    $("input.submit_b").attr("disabled", true);
    $("input.submit_b").attr('src', '/usa/images/css/ui/product_detail/addtocart_b_disabled.png?1283367658');
  } else {
    $("input.submit").removeAttr("disabled");
    $("input.submit").removeClass("disabled");
    $("input.submit_b").removeAttr("disabled");
    $("input.submit_b").attr('src', '/usa/images/css/ui/product_detail/addtocart_b.png?1283367658');
  }

  $("#product_detail_image .status").html(sku.overlay_message);
  
  if(selected_sku.is_polarized) {
    $("#product_detail_image  .hilight").removeClass("hide");
  } else {
    $("#product_detail_image .hilight").addClass("hide");
  }
	facebox_footer_info();
}

function inject3d() {
	$("#facebox .popup .footer").empty().append('<div id="3d_view_wrap"><div id="3d_view"><h1>Whoops!</h1><p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p></div></div>').css({'margin' : '10px auto', 'width' : '688px'});
}

function showFormLayout(gwoLayout) {
	if(gwoLayout == "a" || gwoLayout == "b") {
		if(gwoLayout == "a") {
			$('div.form_layout_orig').remove();
			$('div.form_layout_b').remove();
		}	else if(gwoLayout == "b") {
			$('div.form_layout_orig').remove();
			$('div.form_layout_a').remove();
		}
		// NEW CHIKEZIE LAYOUTS
		$('body').addClass('split split_' + gwoLayout);
		$(document).ready(function() { $('form.jqtransform').jqTransform(); });		
	} else {
		$('div.form_layout_a').remove();
		$('div.form_layout_b').remove();
		// O.G. LAYOUT
		$('body').addClass('split_orig');
	}
}

$(document).ready(function() {
	
  var selected_sku = skus['sku_782'];
  select_sku(selected_sku.id);
  
  $("a.three-d").click(function() {    
		inject3d();
		var flashvars  = { pName: product_spins, pPath:"", controller: true, controllerColor:"0xd70000" };
		var params     = { movie: "/usa/flash/360_spins/360_standalone_colorize.swf"};
		var attributes = {};
		swfobject.embedSWF("/usa/flash/360_spins/360_standalone.swf", "3d_view", "688", "480", "9.0.0","expressInstall.swf", flashvars, params, attributes);
		return false;		
  });
  
  

  $("select#product_colors").change(function() {
    index    = $(this).find("option").index($(this).find("option:selected"));
		indexlast  = index -3;
    scroller = $("#product_scroller").scrollable().seekTo(indexlast);
    select_sku($(this).val());
  });
  
  $('.color .jqTransformSelectWrapper ul li a').livequery('click', function(event) {
		var jqIndex = parseFloat($(this).attr('index')) + 1; // -1 for zero based
  	var selectVal = $('#product_colors option:nth-child(' + jqIndex + ')').attr('value');
  	var selectText = $('#product_colors option:nth-child(' + jqIndex + ')').html();
  	//console.log(jqIndex + " | " + selectVal + " | " + selectText); 
    select_sku(selectVal);
  })
  
  $("ul.product_listing a").click(function() {
    // IF NORMAL DROP DOWN:
    select_sku($(this).attr("rel"));
    
    // IF JQ DROP DOWN:
	  var clickIndex = $("ul.product_listing li").index($(this).parent('li'));
  	$('.color .jqTransformSelectWrapper ul li:nth-child(' + (parseFloat(clickIndex) + 1) + ')').children('a').trigger('click');
  	
  	// EITHER WAY
    return false;
  });
  

  
  
  $(".facebox").facebox();

  
  $("#product_scroller").scrollable({
    size: 5
  });
  
  $("form.ajax").submitWithAjax();
 	
 	
 	
});