$(document).ready(function(){

  $('.best_selling #archives_dd select').change(function(){ $('#archiveForm').submit(); });

  /* ------------------ slider buttons ------------------ */
  $('#latest-reviews .nav-arrows a.prev').click(function(){ slideIt('#latest-reviews', 'prev'); return false; });
  $('#latest-reviews .nav-arrows a.next').click(function(){ slideIt('#latest-reviews', 'next'); return false; });
  $('#latest-releases .nav-arrows a.prev').click(function(){ slideIt('#latest-releases', 'prev'); return false; });
  $('#latest-releases .nav-arrows a.next').click(function(){ slideIt('#latest-releases', 'next'); return false; });
  $('#awfully-good .nav-arrows a.prev').click(function(){ slideIt('#awfully-good', 'prev'); return false; });
  $('#awfully-good .nav-arrows a.next').click(function(){ slideIt('#awfully-good', 'next'); return false; });
  $('#latest-discussion .nav-arrows #disc_down').click(function(){ slideIt('#latest-discussion', 'next'); return false; });
  $('#latest-discussion .nav-arrows #disc_up').click(function(){ slideIt('#latest-discussion', 'prev'); return false; });

});


/* ------------------------------------------------------- */
function slideIt (item, dir) { 
  var spd = 400;
  var movingObject = $(item).find('.slider');
  var totalItems = $(movingObject).find('li').size();
  var visibleItems = 3;

  var step = ($(item).find('.contain').css('width').replace(/px/g, '') * 1);

  // indiv. slider settings
  if (item == '#latest-reviews') { totalItems = 4; visibleItems = 1; }
  else if (item == '#latest-releases') { visibleItems = 1; totalItems = $(item).find('.group').size(); }
  else if (item == '#awfully-good') { visibleItems = 1; totalItems = $(item).find('.group').size() - 1; }
  else if (item == '#latest-discussion') { visibleItems = 1; totalItems = 5; }

  var x = 0;
  if (dir == 'next') { 
    x = ($(movingObject).css('marginLeft').replace(/px/g, '') * 1) - step;
    if (item =='#latest-discussion') { 
      x = ($(movingObject).css('marginTop').replace(/px/g, '') * 1) - step;
    }
    $(item).find('.prev').show();
  }
  else { 
    x = ($(movingObject).css('marginLeft').replace(/px/g, '') * 1) + step;
    if (item =='#latest-discussion') { 
      x = ($(movingObject).css('marginTop').replace(/px/g, '') * 1) + step;
    }
    $(item).find('.next').show();
  }
  

  if (item != '#latest-discussion') { 
    $(movingObject).animate({marginLeft: x}, spd);
  } else { 
    $(movingObject).animate({marginTop: x}, spd);
  }

  if (x == 0) {
    $(item).find('.prev').hide();
  }
  else {
    $(item).find('.prev').show();
  }

  //console.log(x * visibleItems + ' = ' + ((totalItems-visibleItems) * step * -1));

  if (x * visibleItems == ((totalItems-visibleItems) * step * -1)) {
    $(item).find('.next').hide();
  }

}


/* ------------------------------------------------------- */
function MovieHottiesBoobiesArchiveJump() {
  var boobies_monthyear = document.getElementById( 'boobies_monthyear' );
  var monthyear         = boobies_monthyear.value;
  if ( monthyear != "" ) {
    window.location = "http://www.joblo.com/moviehotties/boobies_archive.php?monthyear=" + monthyear;
  }
}

/* ------------------------------------------------------- */
function resetTabs() { 
  $('#tabs .images').attr('src', '/moviehotties/images/new/btn/gal-tab1b.jpg');
  $('#tabs .bio').attr('src', '/moviehotties/images/new/btn/gal-tab2b.jpg');
  $('#tabs .videos').attr('src', '/moviehotties/images/new/btn/gal-tab3b.jpg');
  $('#tabs .downloads').attr('src', '/moviehotties/images/new/btn/gal-tab4b.jpg');
  $('#tabs .headlines').attr('src', '/moviehotties/images/new/btn/gal-tab5b.jpg');
}

/* ------------------------------------------------------- */
function chooseMonth(month) { 
  $('#best-selling .headlines').hide();
  var tmp = '#best-selling table.' + month;
  $(tmp).show();

  $('#best-selling .category a').removeClass('active');
  var tmp = '#best-selling a.' + month;
  $(tmp).addClass('active');
  
}




/* ------------------------------------------------------- */
function MM_jumpMenu(targ,selObj,restore, bookMarkPage, title){ //v3.0
  if (selObj.options[selObj.selectedIndex].value == "bookmark") { bookmark(); }
  else{
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;  
  }
}



function printWindow(url, width) { 
  if (typeof width == 'undefined') { width = 800; }
  window.open(url, 'printWindow', 'status=0,toolbar=0,menubar=1,resizable=1,scrollbars=1,width=' + width);
}

