jQuery(document).ready(function() {
	// categories
	jQuery('#mycategories .currentParent').css('display', 'block');
	
	//load attribute options values for product info
  if (jQuery('#attrib-1').length > 0) {
	  jQuery('#attrib-1').hide();
	  jQuery('#attrib-1 option').each(function(i){
		  var addClass = '';
		  if(jQuery(this).is(':selected'))	addClass = 'currentSelectBox ';
		  jQuery('.selectBoxUL').append('<li data-id="' + jQuery(this).val() + '" class="' + addClass + 'selectBox back">' + jQuery(this).text() + '</li>');
	  });
	  jQuery('.selectBoxUL li.selectBox').click(function(){
		  jQuery('.selectBoxUL li.selectBox').removeClass('currentSelectBox');
		  jQuery(this).addClass('currentSelectBox');
		  jQuery('#attrib-1').val(jQuery(this).data('id'));
	  });
  } else if (jQuery('#attrib-12').length > 0) {
    jQuery('#attrib-12').hide();
    jQuery('#attrib-12 option').each(function(i){
      var addClass = '';
      if(jQuery(this).is(':selected'))  addClass = 'currentSelectBox ';
      jQuery('.selectBoxUL').append('<li data-id="' + jQuery(this).val() + '" class="' + addClass + 'selectBox back">' + jQuery(this).text() + '</li>');
    });
    jQuery('.selectBoxUL li.selectBox').click(function(){
      jQuery('.selectBoxUL li.selectBox').removeClass('currentSelectBox');
      jQuery(this).addClass('currentSelectBox');
      jQuery('#attrib-12').val(jQuery(this).data('id'));
    });
  } else if (jQuery('#productAttributes input[type="radio"]').length > 0) {
    jQuery('#productAttributes input[type="radio"]').parent('div').hide();
    jQuery('#productAttributes input[type="radio"]').each(function(i){
      var addClass = '';
      if(jQuery(this).is(':checked'))  addClass = 'currentSelectBox ';
      jQuery('.selectBoxUL').append('<li data-id="' + jQuery(this).val() + '" class="' + addClass + 'selectBox back">' + jQuery(this).next('label').text() + '</li>');
    });
    jQuery('.selectBoxUL li.selectBox').click(function(){
      jQuery('.selectBoxUL li.selectBox').removeClass('currentSelectBox');
      jQuery(this).addClass('currentSelectBox');
      jQuery('#productAttributes input[type="radio"]').val(jQuery(this).data('id'));
    });
  }
	
	
  jQuery('.zoomIcon').live('click', function() {
    jQuery('#productMainImage a.highslide').click();
  });
  
  var mainImageFull = jQuery('#productMainImage a.highslide').attr('href');
  var mainImageThumb = jQuery('#productMainImage a.highslide img:first').attr('src');
  jQuery('.additionalImages .highslide').hover(
	function() {
		var additionalImage = jQuery(this).attr('href');
		jQuery('#productMainImage a.highslide img:first').attr('src', additionalImage);
	},
	function() {
		jQuery('#productMainImage a.highslide img:first').attr('src', mainImageThumb);
		//jQuery('.zoomWrapperImage img').attr('src', mainImageFull);
	}
  ); 
});
