 $(document).ready(function() {
							
    // initialize scrollable 
    var product_scroller = $("div.scrollable").scrollable({
      api: true
    }); 
 
    $("#product_scroll_previous").click(function() { 
      product_scroller.move(-3);
   });

    $("#product_scroll_next").click(function() { 
      product_scroller.move(3);
   });
	

 });

    $(function() {
        $('a.light_image').lightBox();
    });

    $(function() {
        $('a.light_image2').lightBox();
    });


  function set_main_image(image_file, popup_file) {
	  $("#main_products_image").attr("src" , image_file);
	  $("#main_image_link").attr("href" , popup_file);
  }
  
function announce_slide_in () {
    $("#ajax_announce").animate({ 
        bottom: "20"
      }, 1500 );

}

function announce_slide_out () {
    $("#ajax_announce").animate({ 
        bottom: "-140"
      }, 1500 );

}

function show_announce(product_name, price_string) {
   $("#ajax_announce_items").html('1 x ' + product_name + ' - ' + price_string);
   announce_slide_in();
}

function URLDecode(psEncodeString)
{
  // Create a regular expression to search all +s in the string
  var lsRegExp = /\+/g;
  // Return the decoded string
  return unescape(String(psEncodeString).replace(lsRegExp, " "));
}

function add_cart(products_id, product_url) {
	//If we are on the product info page, get all the inputs (e.g. attributes selected, etc) to send
	var prod_inf_form_string = $("#cart_qty_form").serialize();
	var ajoiner = '?';
 	if (ajax_process_url.indexOf('?') != -1) ajoiner = '&';
  $.get(ajax_process_url + ajoiner + 'action=ajax_add_cart&products_id=' + products_id + '&' + prod_inf_form_string, '', 
    function (responseText, textStatus, XMLHttpRequest) {
      //The following can be used to show the response from the Ajax request (useful for debugging
     //alert(responseText.cart_count);


     if(responseText.redirect_to_product == 'true') {
       window.location = product_url;
     } else {
       $("#ajax_announce_items").html(URLDecode(responseText.product_added_to_cart));
       announce_slide_in();
	   $("#shop_cart_box").html(URLDecode(responseText.cart_box_contents));
	   $("#cart_item_count").html(responseText.cart_count);
     }

	  
    }
   , "json")
  
}

  function update_shipping (shipping_code) {
	$("#checkout_order_totals_container").html('');

	var ajoiner = '?';
 	if (ajax_process_url.indexOf('?') != -1) ajoiner = '&';

  $.get(ajax_process_url + ajoiner + 'action=update_shipping_cost&shipping=' + shipping_code, '', 
    function (responseText, textStatus, XMLHttpRequest) {
      //The following can be used to show the response from the Ajax request (useful for debugging
    // alert(responseText);
	$("#checkout_order_totals_container").html(responseText);


	  
    }
    )

  }