function thumbtoimg(){
  var u_newhtml = $(this).next('div').html();
  
  $('#productbigdisplay').html(u_newhtml);
  
  return false;
}

/* This is the slideshow function for the front page

   If the page is not the front page the function will terminate because Count_item == 0
   
*/
var count_item = $('body.front').length;
$('li.views-row-first').addClass('fpactive').toggleClass('views-row-first').length; 
var ucj_rotator;
var u_count = 0;

function ucj_pause() {
	clearTimeout(ucj_rotator);
	return;
}

function ucj_restart() {
	ucj_rotator = setTimeout(function() { ucjShow(); }, 4500);
	return;
}

function ucjShow() {
	/* if this is not the front page then return without running this function */
	if (count_item == 0) { return; } 
	/* if this is the first time the function has been called do not change the li with the fpactive class */
	if (u_count) {
  	  frtpg_li = $('li.fpactive');
	  if ( $(frtpg_li).next("li").length ) {
		  $(frtpg_li).toggleClass("fpactive");
		  $(frtpg_li).next().toggleClass("fpactive");
	  }
	  else {
		  $(frtpg_li).toggleClass("fpactive");
		  $(frtpg_li).siblings("li:first").toggleClass("fpactive");
	  }
	}
	u_count = 1;
	ucj_rotator = setTimeout(function() { ucjShow(); }, 5000);
}

$(document).ready(function() {ucjShow(); } );

	$('li.fpactive').mouseenter(ucj_pause);
    $('li.fpactive').mouseleave(ucj_restart);

function frtpgshift(){
  var u_frtpg_a = $(this);
  var u_frtpgli = $(this).parent().parent();
  
  /* the frontpage content rotator should stop when one of the arrows is clicked so that the user may manually rotate through the frontpage content */
  clearTimeout(ucj_rotator);
  
  if ( $(u_frtpgli).hasClass("views-row-first") ) {
    $(u_frtpgli).addClass("fpactive").removeClass("views-row-first");
  }
  
  if ($(u_frtpg_a).hasClass('u_actl')){
    if ( $(u_frtpgli).prev("li").length ){
      $(u_frtpgli).prev().toggleClass('fpactive');
      $(u_frtpgli).toggleClass('fpactive');
    }
    else {
      $(u_frtpgli).siblings("li:last").toggleClass('fpactive');
      $(u_frtpgli).toggleClass('fpactive');
    }
      
    return;
  }
  
  if ($(this).hasClass('u_actr')){
    if ( $(u_frtpgli).next("li").length ){
      $(u_frtpgli).next().toggleClass('fpactive');
      $(u_frtpgli).toggleClass('fpactive');
    }
    else {
      $(u_frtpgli).siblings("li:first").toggleClass('fpactive');
      $(u_frtpgli).toggleClass('fpactive');
    }
      
    return;
  }
}

$('a.swtchimg').click(thumbtoimg);

$('.frtpgtext a').click(frtpgshift);

/* These functions hide the non-active items on the side menu */

$('#block-menu-menu-taxonomy li a.active')
    .addClass('gotclass')
    .parent()
    .addClass('gotclass')
    .not('.expanded')
    .siblings('li.leaf')
    .addClass('gotclass')
    .children('a')
    .addClass('gotclass');

$('#block-menu-menu-taxonomy li a.active')
    .addClass('gotclass')
    .parents('li')
    .addClass('gotclass')
    .children('a')
    .addClass('gotclass');
  
$('#block-menu-menu-taxonomy li.gotclass ul li')
    .addClass('gotclass')
    .children('a')
    .addClass('gotclass');

$('#block-menu-menu-taxonomy li')
    .not('.gotclass')
    .hide();
    
$('#edit-field-newletter-yes')
		.attr('checked',true);

(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

(function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
