/* Heroes */
function sramk_flash_product_hero() {
   var B = {
      name : $("#flash-hero span.flashId").text()
   };
   var C = {
      allowfullscreen : "true", 
      bgcolor : "#ffffff", 
      quality : "best", 
      wmode : "transparent"
   };
   var A = {};
   
   if($("div#flash-hero").length > 0 && userHasFlashVersion) {
      swfobject.embedSWF("/_ui/sramk08/swf/products/productFamily/hero.swf", "flash-hero", "960", "372", flashVersion, expressInstall, B, C, A)
   }
   else {
      if(typeof sramk_motor_family != "undefined") {
         $("div#flash-hero").append('<img src="/_ui/sramk08/img/noflash/hero/' + sramk_motor_family + '.jpg"/>')
      }
      else {
         $("div#flash-hero").append(noFlashAlternateContent)
      }
   }
}
   
/* Landing Page */
function sramk_flash_product_landing() {
   var B = {};
   var C = {
      allowfullscreen : "true", 
      bgcolor : "#ffffff", 
      quality : "best", 
      wmode : "transparent"
   };
   var A = {};
   if(userHasFlashVersion) {
      $("#content div.content-container").remove();
      swfobject.embedSWF("/_ui/sramk08/swf/products/browser/product_browser.swf", "flash-products", "952", "350", flashVersion, expressInstall, B, C, A)
   }
}
   
/* Accessories Sidebar */
var productAccessoriesScroller = {
   displayNum : 3, numItems : 0, currentPg : 0, __construct : function() {
      productAccessoriesScroller.numItems = $("#sidebar .accessories .box").length;
      $("#sidebar .view-all a.last").html(Math.ceil(productAccessoriesScroller.numItems / productAccessoriesScroller.displayNum));
      $("#sidebar .view-all a.right-arrow").click(this.next);
      $("#sidebar .view-all a.left-arrow").click(this.prev);
      $("#sidebar .view-all a.all").click(this.showAll);
      $("#sidebar .view-all a.last").click(function() {
         var A = $(this).html() * 1; productAccessoriesScroller.currentPg = A - 1; productAccessoriesScroller.next(); return false}
      );
      this.next()}
   , next : function() {
      var A, B;
      productAccessoriesScroller.currentPg++;
      if((productAccessoriesScroller.currentPg * productAccessoriesScroller.displayNum) < (productAccessoriesScroller.numItems + productAccessoriesScroller.displayNum)) {
         A = (productAccessoriesScroller.currentPg * productAccessoriesScroller.displayNum);
         B = A - productAccessoriesScroller.displayNum - 1;
         $("#sidebar .accessories .box").removeClass("active");
         $("#sidebar .accessories .box:lt(" + A + "):gt(" + B + ")").addClass("active")}
      else {
         productAccessoriesScroller.currentPg--}
      productAccessoriesScroller.cleanupNav();
      return false}
   , prev : function() {
      var A, B;
      productAccessoriesScroller.currentPg--;
      if(productAccessoriesScroller.currentPg >= 1) {
         A = (productAccessoriesScroller.currentPg * productAccessoriesScroller.displayNum);
         B = A - productAccessoriesScroller.displayNum - 1;
         $("#sidebar .accessories .box").removeClass("active");
         $("#sidebar .accessories .box:lt(" + A + "):gt(" + B + ")").addClass("active")}
      else {
         productAccessoriesScroller.currentPg = 1}
      productAccessoriesScroller.cleanupNav();
      return false}
   , showAll : function() {
      $("#sidebar .accessories .box").addClass("active");
      return false}
   , cleanupNav : function() {
      var A = productAccessoriesScroller.numItems - 1;
      if($("#sidebar .accessories .box:eq(0)").hasClass("active")) {
         $("#sidebar .view-all a.left-arrow").removeClass("active").addClass("disabled")}
      else {
         $("#sidebar .view-all a.left-arrow").removeClass("disabled").addClass("active")}
      if($("#sidebar .accessories .box:eq(" + A + ")").hasClass("active")) {
         $("#sidebar .view-all a.right-arrow").removeClass("active").addClass("disabled")}
      else {
         $("#sidebar .view-all a.right-arrow").addClass("active").removeClass("disabled")}
      $("#sidebar .view-all a.current").html(productAccessoriesScroller.currentPg)}
};
   
$(document).ready(function() {
   /* Landing */
   if($("#flash-products").length > 0) {
      sramk_flash_product_landing()
   }
   
   /* Hero */
   if($("#flash-hero").length > 0 && $("#flash-hero div.key").length == 0) {
      sramk_flash_product_hero()
   }
   
   /* Accessories Sidebar */
   productAccessoriesScroller.__construct();
   if($("#column ul.questions").length > 0) {
      $("#column ul.questions li a.question").click(function() {
         var A = $(this).parents("li");
         $("#column ul.questions > li").not(A).removeClass("active");
         if($(A).is(".active")) {
            $(A).removeClass("active")
         }
         else {
            $(A).addClass("active")
         }
         return false;
      });
   }
}); 