/***
 * Application specific functions
 */

// responds to a select change on store finder
function gotoStore() {
  if ($F('franchisee_id') != '') { location.href = $F('franchisee_id') + '/categories'; } 
  return;
}

// rotates images on home page
function rotateImages(images) {
  i = 0;
  imgs = images.evalJSON(); 
  new PeriodicalExecuter(
    function(pe) {
      img1 = 'img-' + i;
      if (i == imgs.length - 1) {
        img2 = 'img-0';
        i = 0;
      } else {
        img2 = 'img-' + (i + 1);
        i++;
      }
      $(img1).fade();
      $(img2).appear();
    },
    3
  );
  return;
}

// copies shipping information to billing information on checkout
function copyShipping() {
  $('cart_bill_first_name').value = $F('cart_ship_first_name');
  $('cart_bill_last_name').value  = $F('cart_ship_last_name');
  $('cart_bill_address').value    = $F('cart_ship_address');
  $('cart_bill_address2').value   = $F('cart_ship_address2');
  $('cart_bill_city').value       = $F('cart_ship_city');
  $('cart_bill_state_id').value   = $F('cart_ship_state_id');
  $('cart_bill_zip').value        = $F('cart_ship_zip');
  return;
}

function toggleNav(id) {

	var divs = document.getElementsByTagName("div");
  document.getElementById(id).blur();

	for (i = 0; i < divs.length; i++) {
		if (divs[i].id.indexOf("left-sub-") != -1 && divs[i].style.display != "none") {
			Effect.toggle(divs[i].id,'blind');
			
		}

	}
  Effect.toggle(id,'blind');
	return false;

}

