
jQuery.noConflict();

/*
 * jQuery Form Example Plugin 1.4.3
 * Populate form inputs with example text that disappears on focus.
 *
 * e.g.
 *  $('input#name').example('Bob Smith');
 *  $('input[@title]').example(function() {
 *    return $(this).attr('title');
 *  });
 *  $('textarea#message').example('Type your message here', {
 *    className: 'example_text'
 *  });
 *
 * Copyright (c) Paul Mucur (http://mucur.name), 2007-2008.
 * Dual-licensed under the BSD (BSD-LICENSE.txt) and GPL (GPL-LICENSE.txt)
 * licenses.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
(function($) {

  $.fn.example = function(text, args) {

    /* Only calculate once whether a callback has been used. */
    var isCallback = $.isFunction(text);

    /* Merge the arguments and given example text into one options object. */
    var options = $.extend({}, args, {example: text});

    return this.each(function() {

      /* Reduce method calls by saving the current jQuery object. */
      var $this = $(this);

      /* Merge the plugin defaults with the given options and, if present,
       * any metadata.
       */
      if ($.metadata) {
        var o = $.extend({}, $.fn.example.defaults, $this.metadata(), options);
      } else {
        var o = $.extend({}, $.fn.example.defaults, options);
      }

      /* The following event handlers only need to be bound once
       * per class name. In order to do this, an array of used
       * class names is stored and checked on each use of the plugin.
       * If the class name is in the array then this whole section
       * is skipped. If not, the events are bound and the class name
       * added to the array.
       *
       * As of 1.3.2, the class names are stored as keys in the
       * array, rather than as elements. This removes the need for
       * $.inArray().
       */
      if (!$.fn.example.boundClassNames[o.className]) {

        /* Because Gecko-based browsers cache form values
         * but ignore all other attributes such as class, all example
         * values must be cleared on page unload to prevent them from
         * being saved.
         */
        $(window).unload(function() {
          $('.' + o.className).val('');
        });

        /* Clear fields that are still examples before any form is submitted
         * otherwise those examples will be sent along as well.
         *
         * Prior to 1.3, this would only be bound to forms that were
         * parents of example fields but this meant that a page with
         * multiple forms would not work correctly.
         */
        $('form').submit(function() {

          /* Clear only the fields inside this particular form. */
          $(this).find('.' + o.className).val('');
        });

        /* Add the class name to the array. */
        $.fn.example.boundClassNames[o.className] = true;
      }

      /* Several browsers will cache form values even if they are cleared
       * on unload, so this will clear any value that matches the example
       * text and hasn't been specified in the value attribute.
       *
       * If a callback is used, it is not possible or safe to predict
       * what the example text is going to be so all non-default values
       * are cleared. This means that caching is effectively disabled for
       * that field.
       *
       * Many thanks to Klaus Hartl for helping resolve this issue.
       */
      if (!$this.attr('defaultValue') && (isCallback || $this.val() == o.example))
        $this.val('');

      /* Initially place the example text in the field if it is empty
       * and doesn't have focus yet.
       */
      if ($this.val() == '' && this != document.activeElement) {
        $this.addClass(o.className);

        /* The text argument can now be a function; if this is the case,
         * call it, passing the current element as `this`.
         */
        $this.val(isCallback ? o.example.call(this) : o.example);
      }

      /* Make the example text disappear when someone focuses.
       *
       * To determine whether the value of the field is an example or not,
       * check for the example class name only; comparing the actual value
       * seems wasteful and can stop people from using example values as real
       * input.
       */
      $this.focus(function() {

        /* jQuery 1.1 has no hasClass(), so is() must be used instead. */
        if ($(this).is('.' + o.className)) {
          $(this).val('');
          $(this).removeClass(o.className);
        }
      });

      /* Detect a change event to the field and remove the example class. */
      $this.change(function() {
        if ($(this).is('.' + o.className)) {
          $(this).removeClass(o.className);
        }
      });

      /* Make the example text reappear if the input is blank on blurring. */
      $this.blur(function() {
        if ($(this).val() == '') {
          $(this).addClass(o.className);

          /* Re-evaluate the callback function every time the user
           * blurs the field without entering anything. While this
           * is not as efficient as caching the value, it allows for
           * more dynamic applications of the plugin.
           */
          $(this).val(isCallback ? o.example.call(this) : o.example);
        }
      });
    });
  };

  /* Users can override the defaults for the plugin like so:
   *
   *   $.fn.example.defaults.className = 'not_example';
   */
  $.fn.example.defaults = {
    className: 'example'
  };

  /* All the class names used are stored as keys in the following array. */
  $.fn.example.boundClassNames = [];

})(jQuery);


jQuery(function($) {
$(document).ready(function(){
  $('.language').hover(
    function() {
      $(this).addClass('hover');
      $(this).children('ul').show();
    },
    function() {
      $(this).removeClass('hover');
      $(this).children('ul').hide();
    }
  );
});
});

jQuery(function($) {
$(document).ready(function(){
  $('#menus > li').hover(
    function() {
      $(this).addClass('hover');
      $(this).children('ul').show();
    },
    function() {
      $(this).removeClass('hover');
      $(this).children('ul').hide();
    }
  );
});
});

jQuery(function($) {
$(document).ready(function(){
  $('.product2 .product2_image_thumbnail img').each(function() {
    if($(this).parents('.product2').find('.product2_image img').length) {
      $(this).qtip({
        content: $(this).parents('.product2').find('.product2_image img'),
        style: { 
          width: 320,
          padding:5,
          border: {
            width:0
          },
          tip: false
        },
        position: {
          //adjust: { screen: true },
          corner: {
            target: 'leftTop',
            tooltip: 'rightTop'
          }          
        }
      });
    }
  });
});
});

(function($) {
  $.fn.adGallery2 = function(options) {
    var defaults = {
      animation: 4000,
      slideShowItem:'.csc-textpic-imagerow'      
    };        
    var settings = $.extend(false, defaults, options);
    $(this).each(function() {
      if($(this).children(settings.slideShowItem).length > 1) {
        var gallery = new AdGallery2(this, settings);
      }
    });
   };
    
    function AdGallery2(wrapper, settings) {
      this.init(wrapper, settings);
    };
    AdGallery2.prototype = {
      type:0,
      n:0,
      count:0,
      data:1,
      wrapper: false,
      setting: false,
      countdown_interval: false,
      init: function(wrapper, settings) {
        var context = this;
        context.wrapper = $(wrapper);
        context.settings = settings;
        
        context.wrapper.addClass('clearfix');
        
        context.setupElements();
        context.initNav();
        
        context.count = context.wrapper.find(context.settings.slideShowItem).length;
        context.slideshowContentsArray = context.wrapper.find(context.settings.slideShowItem);
        context.wrapper.find(context.settings.slideShowItem).hide();
        context.wrapper.find(context.settings.slideShowItem).first().show();

        context.countdown_interval = setInterval(
          function() {
            context.showAuto();
          },
          8000
        );
      },
      setupElements: function() {
        var context = this;
        var tmp = '';
        for(var i=1; i<=context.wrapper.find(context.settings.slideShowItem).length; i++) {
          if(typeof(addGalleryType) !== 'undefined' && addGalleryType) {
            tmp += '<a href="javascript:void(0);"></a>';
          } else {
            tmp += '<a href="javascript:void(0);">'+i+'</a>';
          }
        }        
        if(typeof(addGalleryType) !== 'undefined' && addGalleryType) {
          tmp = '<div class="imagenav imagenav2">' + tmp + '</div><a href="javascript:void(0);" class="prev">prev</a><a href="javascript:void(0);" class="next">next</a>';
        } else {
          tmp = '<div class="imagenav">' + tmp + '</div>';
        }
        context.wrapper.append(tmp);
        context.wrapper.find('.imagenav a').first().addClass('active');
      },
      
      initNav: function() {
        var context = this;
        context.wrapper.find('.imagenav a').each(function() {
          $(this).data("index",context.data);
          context.data++;
        });
        context.wrapper.find('.imagenav a').bind('click', function(event,isTrigger) {
          if(!isTrigger) {
            clearInterval(context.countdown_interval);
            context.countdown_interval = setInterval(
              function() {
                context.showAuto();
              },
              8000
            );
          }
          if($(this).hasClass("active")) return;
          context.clearNav();
          $(this).addClass("active");
          
          
          var i = $(this).data("index") - 1;
          context.n = i;
          if (i >= context.count) return;
                
          if(context.slideshowContentsArray[i]) {
            context.clearSlideshowContents();
            $(context.slideshowContentsArray[i]).show();
          } 
        });
        
        context.wrapper.find('a.prev').bind('click', function(event,isTrigger) {
          if(!isTrigger) {
            clearInterval(context.countdown_interval);
            context.countdown_interval = setInterval(
              function() {
                context.showAuto();
              },
              8000
            );
            
            var i = context.n == 0 ? (context.count - 1) : context.n - 1;
            context.n = i;
            context.clearNav();
            context.wrapper.find('.imagenav a').each(function() {
              if(($(this).data("index") - 1) == i) {
                $(this).addClass("active");
              }
            })
            
          }
          if(context.slideshowContentsArray[i]) {
            context.clearSlideshowContents();
            $(context.slideshowContentsArray[i]).show();
          }
        });
        
        context.wrapper.find('a.next').bind('click', function(event,isTrigger) {
          if(!isTrigger) {
            clearInterval(context.countdown_interval);
            context.countdown_interval = setInterval(
              function() {
                context.showAuto();
              },
              8000
            );
            var i = context.n >= (context.count - 1) ? 0 : context.n + 1;
            context.n = i;
            context.clearNav();
            context.wrapper.find('.imagenav a').each(function() {
              if(($(this).data("index") - 1) == i) {
                $(this).addClass("active");
              }
            })
          }
          if(context.slideshowContentsArray[i]) {
            context.clearSlideshowContents();
            $(context.slideshowContentsArray[i]).show();
          }
        });
      },
      clearNav: function() {
        var context = this;
        $(context.wrapper.find('.imagenav a')).each(function(){
          if($(this).hasClass("active")) {
            $(this).removeClass("active");
          } else {
            return true;
          }
        });
      },
      clearSlideshowContents: function() {
        var context = this;
        context.wrapper.find(context.settings.slideShowItem).hide();
      },
      showAuto: function() {
        var context = this;
        context.n = context.n >= (context.count - 1) ? 0 : context.n + 1;
        $(context.wrapper.find('.imagenav a')).eq(context.n).trigger('click',['true']);
      }
      
    };
})(jQuery);


jQuery(function($) {
$(document).ready(function(){
  $('.csc-textpic-imagewrap').adGallery2();
});
});

(function($) {
  $.fn.tabGallery = function(options) {
    var defaults = {
    };        
    var settings = $.extend(false, defaults, options);
    $(this).each(function() {
      var gallery = new TabGallery(this, settings);
    });
   };
    
    function TabGallery(wrapper, settings) {
      this.init(wrapper, settings);
    };
    TabGallery.prototype = {
      wrapper: false,
      setting: false,
      init: function(wrapper, settings) {
        var context = this;
        this.wrapper = $(wrapper);
        this.settings = settings;
        this.setupElements();

      },
      setupElements: function() {
        var context = this;
        context.wrapper.children('.productform').hide();
        context.wrapper.prepend('<div class="productdetailtabs_inner"><ul class="tabs_menu"><li class="active"><a class="productdetail" href="javascript:void(0);">MATERIAL</a></li><li><a class="productform_partone" href="javascript:void(0);">DRAWINGS</a></li><li><a  class="productform_parttwo" href="javascript:void(0);">ACCESSORIES</a></li><li><a class="productform_partthree" href="javascript:void(0);">Inquiry</a></li></ul></div>');
        context.wrapper.find('a.productdetail').click(function() {
          if(context.wrapper.find('div.productdetail').is(':visible')) return;
          context.wrapper.children('div.productform').hide();
          context.wrapper.find('div.productdetail').show();
          context.wrapper.find('ul.tabs_menu li').removeClass('active');
          $(this).parent().addClass('active');
        });
        
        context.wrapper.find('a.productform_partone').click(function() {
          if(context.wrapper.find('div.productform').is(':visible') && context.wrapper.find('div.productform_partone').is(':visible')) return;
          context.wrapper.find('div.productdetail, div.productform_partone, div.productform_parttwo, div.productform_partthree').hide();
          context.wrapper.find('div.productform, div.productform_partone').show();
          context.wrapper.find('ul.tabs_menu li').removeClass('active');
          $(this).parent().addClass('active');
        });
        context.wrapper.find('a.productform_parttwo').click(function() {
          if(context.wrapper.find('div.productform').is(':visible') && context.wrapper.find('div.productform_parttwo').is(':visible')) return;
          context.wrapper.find('div.productdetail, div.productform_partone, div.productform_parttwo, div.productform_partthree').hide();
          context.wrapper.find('div.productform, div.productform_parttwo').show();
          context.wrapper.find('ul.tabs_menu li').removeClass('active');
          $(this).parent().addClass('active');
        });
        context.wrapper.find('a.productform_partthree').click(function() {
          if(context.wrapper.find('div.productform').is(':visible') && context.wrapper.find('div.productform_parthree').is(':visible')) return;
          context.wrapper.find('div.productdetail, div.productform_partone, div.productform_parttwo, div.productform_partthree').hide();
          context.wrapper.find('div.productform, div.productform_partthree').show();
          context.wrapper.find('ul.tabs_menu li').removeClass('active');
          $(this).parent().addClass('active');
        });
        
      }
    };
})(jQuery);

jQuery(function($) {
$(document).ready(function(){
$('.productdetailtabs').tabGallery();
});
});

jQuery(function($) {
$(document).ready(function(){
  $('.productform_image img').each(function() {
    if($(this).next('img').length) {
      $(this).qtip({
        content: $(this).next('img'),
        style: { 
          width: 320,
          padding:5,
          border: {
            width:0
          },
          tip: false
        },
        position: {
          adjust: { screen: true },
          corner: {
            target: 'leftTop',
            tooltip: 'rightTop'
          }          
        }
      });
    }
  });
});
});

jQuery(function($) {
$(document).ready(function(){
  $('.productform_cc input[type="radio"]').change(
    function() {
      if($(this).hasClass('change') && $(this).is(':checked')) {
        $('.productform_request').show();
      } else {
        $('.productform_request').hide();
      }
    }
  )
});
});

jQuery(function($) {
$(document).ready(function(){
  $('.productform input.more').parents('td').each(function() {
    $(this).find('input[type="radio"]').change(
      function() {
        if($(this).hasClass('more') && $(this).is(':checked')) {
          $(this).nextAll('input[type="text"]').show();
        } else {
          $(this).parents('td').find('input.more').nextAll('input[type="text"]').hide();
        }
      }
    )
  });
});
});

jQuery(function($) {
$(document).ready(function(){
  $('.productform a.next').click(function() {
    if($(this).parents('.productform_partone').length) {
      $('a.productform_parttwo').trigger('click');
    } else if($(this).parents('.productform_parttwo').length) {
      $('a.productform_partthree').trigger('click');
    }
  });
  $('.productform a.back').click(function() {
    if($(this).parents('.productform_partthree').length) {
      $('a.productform_parttwo').trigger('click');
    } else if($(this).parents('.productform_parttwo').length) {
      $('a.productform_partone').trigger('click');
    }
  });
});
});

jQuery(function($) {
  $(document).ready(function(){
    $('#col1 .showhidecontent').hide();
    $('#col1 h3.showhideheader').last().addClass('lastshowhideheader');
    $('#col1 h3.showhideheader').live('click', function() {
      $(this).toggleClass('selected');
      $(this).parent('.csc-default').toggleClass('showhide_select');      
      if($(this).parents('#col1').length) {
        $('#col1 h3.showhideheader').removeClass('selected');
        $('#col1 h3.showhideheader').parent('.csc-default').removeClass('showhide_select');
        $('#col1 .showhidecontent').hide('normal');
        if($(this).next('.showhidecontent').is(':hidden')) {
          $(this).addClass('selected');
          $(this).parent('.csc-default').addClass('showhide_select');
          $(this).next('.showhidecontent').show('normal');
        } else {          
          $(this).next('.showhidecontent').hide('normal');
          $(this).removeClass('selected');
          $(this).parent('.csc-default').removeClass('showhide_select');
        }
        return;
      }
    });
    $('#col1 h3.showhideheader').live({
      mouseover: function() {
        $(this).addClass('hover');
      },      
      mouseout: function() {
        $(this).removeClass('hover');
      }    
    });
  });
});

jQuery(function($) {
  $(document).ready(function(){
    $('#col2 .showhidecontent').hide();
    $('#col2 h3.showhideheader').last().addClass('lastshowhideheader');
    $('#col2 h3.showhideheader').live('click', function() {
      $(this).toggleClass('selected');
      $(this).parent('.csc-default').toggleClass('showhide_select');      
      if($(this).next('.showhidecontent').is(':hidden')) {
        $(this).addClass('selected');
        $(this).parent('.csc-default').addClass('showhide_select');
        $(this).next('.showhidecontent').show('normal');
      } else {          
        $(this).next('.showhidecontent').hide('normal');
        $(this).removeClass('selected');
        $(this).parent('.csc-default').removeClass('showhide_select');
      }
      //$(this).next('.showhidecontent').toggle('normal');
    });
    $('#col2 h3.showhideheader').live({
      mouseover: function() {
        $(this).addClass('hover');
      },      
      mouseout: function() {
        $(this).removeClass('hover');
      }    
    });
    //$('.ui-tabs-panel h3.showhideheader').first().trigger('click');
  });
});

jQuery(function($) {
$(document).ready(function(){
  $(function(){
        var $this = $('.news-latest-container');
        var scrollTimer;
        $this.hover(function(){
              clearInterval(scrollTimer);
         },function(){
           scrollTimer = setInterval(function(){
                         scrollNews( $this );
                    }, 2000 );
        }).trigger("mouseout");
});
function scrollNews(obj){
 var $self = obj;
 //$self.find('.news-latest-item:first').appendTo($self);
 var lineHeight = $self.find('.news-latest-item:first').height(); //»ñÈ¡ÐÐ¸ß 
 $self.find('.news-latest-item:first').animate({ 'margin-top' : -lineHeight +'px' },800 , function(){
         $self.find('.news-latest-item:first').css({ 'margin-top' : '0px' }).appendTo($self)});
}
})
})

jQuery(function($) {
$(document).ready(function(){
  $('table.feature_table tr.feature_tr1 td').each(function() {
    var className = $.trim($(this).attr('class').replace('aligncenter',''));
    var ele = $(this).parents('table').next('#feature_content').find('.'+className);  
    if(ele.length) {
      $(this).qtip({
        content: ele.html(),
        style: {
          background:'#1C2F70',
          width: 320,          
          padding:15,
          border: {
            width:0,
            radius:5,
            color:'#1C2F70'
          },
          tip: false
        },
        position: {
          adjust: { screen: true },
          corner: {
            target: 'topMiddle',
            tooltip: 'bottomMiddle'
          }          
        }
      });
    }
  });
});
});

function setSelectedUnits() {
  jQuery(function($) {
    var mpSelectedUnits = '';
    var tempSelectedUnit = '';
    $('input[class="product_selected"]:checked').each(function() {
      if(parseInt($(this).parents('.product_item').find('input.product_number').val())) {
        tempSelectedUnit = $(this).parents('.product_item').find('input.product_number').val()+
        ','+$(this).parents('.product_item').find('.product_name').text()+
        ','+$(this).parents('.product_item').find('.product_blueprint img').attr('src')+';';
        mpSelectedUnits += tempSelectedUnit;
      }
    });
    $('#mp_selected_units').val(mpSelectedUnits.substring(0,mpSelectedUnits.length-1));
  })
}

function setConfig() {
  jQuery(function($) {
    //$('#mp_uconfig').val($('#select_type').val());
    $('input[name="mp_uconfig"]').val($('#select_type').val());
  })
}

function setOtherBluePrint() {
  jQuery(function($) {
    if($.query.get('blueprintname')) {
      $('input[name="mp_otherblueprint"]').val($.query.get('blueprintname'));
    }
  })
}

jQuery(function($) {
  $(document).ready(function(){
    if($('#selected_units').length) {
      var mpSelectedUnits = $('#mp_selected_units').val();
      if(mpSelectedUnits) {
        var mpSelectedUnitsArray = mpSelectedUnits.split(';');
        var productNumber=0;
        var productName='';
        var productArray;
        var writeSelectedUnits = $('<ul></ul>');
        for(var i=0; i<mpSelectedUnitsArray.length; i++) {
          productArray = mpSelectedUnitsArray[i].split(',');
          productNumber = parseInt(productArray[0]);
          productName = productArray[1];
          writeSelectedUnits.append('<li><span class="product_number">'+productNumber+'</span><span class="join">x</span>'+productName+'</li>');
        }
        $('#selected_units').append(writeSelectedUnits);
      }
    }
    var blueprintName = $.query.get('blueprintname') ? $.query.get('blueprintname') : $('input[name="mp_otherblueprint"]').val();
    if(blueprintName) {
      if($('#selected_units ul').length) {
        $('#selected_units ul').append('<li><span class="product_number">1</span><span class="join">x</span>'+blueprintName+'</li>');
      } else {
        $('#selected_units').append('<ul><li><span class="product_number">1</span><span class="join">x</span>'+blueprintName+'</li></ul>');
      }
    }
    
  })
})
jQuery(function($) {
  $(document).ready(function(){
    if($('#selected_units_preview').length) {
      var mpSelectedUnits = $('#mp_selected_units').val();
      if(mpSelectedUnits) {
        var mpSelectedUnitsArray = mpSelectedUnits.split(';');
        var productNumber=0;
        var productName='';
        var productImageSrc='';
        var productArray;
        var writeSelectedUnits = $('<ul class="clearfix"></ul>');
        for(var i=0; i<mpSelectedUnitsArray.length; i++) {
          productArray = mpSelectedUnitsArray[i].split(',');
          productNumber = parseInt(productArray[0]);
          productName = productArray[1];
          productImageSrc = productArray[2];
          if((i+1)%3) {
            writeSelectedUnits.append('<li><span class="product_name">'+productName+'</span><span class="product_image"><img alt="'+productName+'" src="'+productImageSrc+'" /></span><span class="product_number_wrap"><span class="unit">Units</span><span class="product_number">'+productNumber+'</span></span></li>');
          } else {
            writeSelectedUnits.append('<li class="last"><span class="product_name">'+productName+'</span><span class="product_image"><img alt="'+productName+'" src="'+productImageSrc+'" /></span><span class="product_number_wrap"><span class="unit">Units</span><span class="product_number">'+productNumber+'</span></span></li>');
          }
        }
        $('#selected_units_preview').append(writeSelectedUnits);
      }
      var blueprintName = $.query.get('blueprintname') ? $.query.get('blueprintname') : $('input[name="mp_otherblueprint"]').val();
      if(blueprintName) {
        $('#selected_units_preview').append('<p>'+blueprintName+'<br /><span class="product_number_wrap"><span class="unit">Units</span><span class="product_number">1</span></span></p>');
      }
    }
  })
})

jQuery(function($) {
      $(document).ready(function(){
//start
$('input.product_selected').each(function() {
  var relElement = $('<li></li>');
  $(this).data('relEle', relElement);
  relElement.data('relEle', $(this));
  $(this).parents('.product_item').find('input.product_number').data('relEle', relElement);
});
$('input.product_selected, input.other_selected').live('click', function() {
  if($(this).attr('checked')) {
    $(this).parents('.product_header, .other_header').addClass('selected');
      var productNumber = parseInt($(this).parents('.product_item').find('input.product_number').val());
      if(productNumber) {
        var relElement = $(this).data('relEle');
        $(this).parents('.product_item').find('input.product_number').data('relEle', relElement);
        
      
        var productName = $(this).parents('.product_item').find('input.product_name').val();
        var newElement = $(this).data('relEle').html('<span class="product_number">' + productNumber + '</span><span class="join">x</span>' + productName + '<a href="javascript:void(0);" class="delete"></a>');
        newElement.find('a.delete').data('relEle', $(this));
        if($('.selected_box ul').length) {          
          $('.selected_box ul').append(newElement);
        } else {
          $('.selected_box').append($('<ul></ul>').append(newElement));
        }
      }
  } else {
    $(this).parents('.product_header, .other_header').removeClass('selected');
    $(this).data('relEle').remove();
    if(!$('.selected_box ul li').length) {
      $('.selected_box ul').remove();
    }
  }
});
$('input.product_selected, input.other_selected').each(function() {
  if($(this).attr('checked')) {
      $(this).parents('.product_header, .other_header').addClass('selected');
      var productNumber = parseInt($(this).parents('.product_item').find('input.product_number').val());
      if(productNumber) {
        var relElement = $(this).data('relEle');
        $(this).parents('.product_item').find('input.product_number').data('relEle', relElement);
        
      
        var productName = $(this).parents('.product_item').find('input.product_name').val();
        var newElement = $(this).data('relEle').html('<span class="product_number">' + productNumber + '</span><span class="join">x</span>' + productName + '<a href="javascript:void(0);" class="delete"></a>');
        newElement.find('a.delete').data('relEle', $(this));
        if($('.selected_box ul').length) {          
          $('.selected_box ul').append(newElement);
        } else {
          $('.selected_box').append($('<ul></ul>').append(newElement));
        }
      }
  }
});

var blueprintName = $('input[name="mp_otherblueprint"]').val();
if(blueprintName) {
  if($('.selected_box ul').length) {          
    $('.selected_box ul').append('<li><span class="product_number">1</span><span class="join">x</span>' + blueprintName + '<a href="javascript:void(0);" class="otherdelete delete"></a></li>');
  } else {
    $('.selected_box').append($('<ul></ul>').append('<li><span class="product_number">1</span><span class="join">x</span>' + blueprintName + '<a href="javascript:void(0);" class="otherdelete delete"></a></ul>'));
  }
}

$('input.product_number').live('blur', function() {
  if(!$(this).parents('.product_item').find('input.product_selected').attr('checked')) return;
  if(parseInt($(this).val())) {
    //$(this).data('relEle').remove();
    var productNumber = parseInt($(this).val());
    /*var productName = $(this).parents('.product_item').find('input.product_name').val();
    var newElement = $(this).data('relEle').html('<span class="product_number">' + productNumber + '</span><span class="join">x</span>' + productName + '<a href="javascript:void(0);" class="delete"></a>');
    newElement.find('a.delete').data('relEle', $(this).parents('.product_item').find('input.product_selected, input.other_selected'));
    if($('.selected_box ul').length) {          
      $('.selected_box ul').append(newElement);
    } else {
      $('.selected_box').append($('<ul></ul>').append(newElement));
    }*/
    $(this).data('relEle').children('span.product_number').text(productNumber);
  } else {
    $(this).parents('.product_item').find('input.product_selected').attr('checked', false);
    $(this).parents('.product_item').find('.product_header, .other_header').removeClass('selected');
    $(this).data('relEle').remove();
    if(!$('.selected_box ul li').length) {
      $('.selected_box ul').remove();
    }
  }
});
$('.selected_box a.delete').live('click', function() {
  if($(this).data('relEle')) {
    $(this).data('relEle').attr('checked',false);
    $(this).data('relEle').parents('.product_header, .other_header').removeClass('selected');
  }
  $(this).parents('li').remove();
  if($(this).hasClass('otherdelete')) {
    $('input[name="mp_otherblueprint"]').val('');
  }
})

//end
})
    })

jQuery(function($) {
  $(document).ready(function() {
    //Assign default value to form field #1
    $('input.product_number').example(0);
  });
})

jQuery(function($) {
  $(document).ready(function() {
    var relArray = new Array();
    relArray['Basic'] = '#basiccontent';
    relArray['Standard'] = '#standardcontent';
    relArray['Senior'] = '#seniorcontent';
    //$(relArray.join()).hide();
    $('#select_type').change(function () {
      //$(relArray.join()).hide();
      $('#basiccontent, #standardcontent, #seniorcontent').hide();
      $(relArray[$(this).val()]).show();
      //$('#mp_config').val($(this).val());
    });
    
    $('#select_type').trigger('change');
  });
})


jQuery(function($) {
  $(document).ready(function() {
    var relArray = new Array();
    relArray['Basic'] = '.basic_preview';
    relArray['Standard'] = '.standard_preview';
    relArray['Senior'] = '.senior_preview';
    //$(relArray.join()).hide();
    $('.basic_preview, .standard_preview, .senior_preview').hide();
    $(relArray[$('#mp_uconfig').val()]).show();
  });
})

jQuery(function($) {
$(document).ready(function() {
    $('input.product_number').keydown(function(event) {
        // Allow only backspace and delete
        if ( event.keyCode == 46 || event.keyCode == 8 ) {
            // let it happen, don't do anything
        }
        else {
            // Ensure that it is a number and stop the keypress
            if (event.keyCode < 48 || event.keyCode > 57 ) {
                event.preventDefault(); 
            }   
        }
    });
});
})

jQuery(function($) {
$(document).ready(function() {
  $('#basiccontent select, #standardcontent select, #seniorcontent select').change(function () {
    var selectName = $(this).attr('name');
    var selectIdx = $(this)[0].selectedIndex;
    var href = '#'+selectName+'_'+selectIdx;
    $(this).next('a.viewinfo').attr('href',href);
  });
  $("a.viewinfo").prettyPhoto({animation_speed:'fast',slideshow:10000, hideflash: true, social_tools:'',default_width:640,default_height:500});
});
})

jQuery(function($) {
$(document).ready(function() {
  function mycarousel_initCallback(carousel) {
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
  }
  if($('.jcarousel-skin-tango').length) {
      $('.jcarousel-skin-tango').jcarousel({
          scroll:1,
          initCallback: mycarousel_initCallback
      });
    $('a.mycarousel_title').click(function() {
      $(this).parents('li').find('a.lightbox').trigger('click');
    });
  }
});
})

jQuery(function($) {
$(document).ready(function() {
  $('.ui-tabs-panel').addClass('ui-tabs-hide');
  $('ul.rgtabs-menu li').not($('ul.rgtabs-menu li.inquiry')).find('a').click(function() {
    var panelID = $(this).attr('href');
    $(this).parents('.tx-rgtabs-pi1').find('.ui-tabs-panel').addClass('ui-tabs-hide');
    var relPanel = $(panelID).removeClass('ui-tabs-hide');
    //showhide
    if(!relPanel.hasClass('ui-tabs-hide')) {
      if(!relPanel.find('h3.showhideheader').first().hasClass('selected')) {
        relPanel.find('h3.showhideheader').first().trigger('click');
      }
    }
    
    $(this).parents('ul.rgtabs-menu').children().removeClass('ui-tabs-selected');
    $(this).parent('li').addClass('ui-tabs-selected');
    return false;
  });
  $('ul.rgtabs-menu').children('li').first().find('a').trigger('click');
});
})


