// commas in prices in the appropriate places - the function
	$.fn.digits = function(){ 
	return this.each(function(){ 
		$(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") ); 
	})
	}
// commas in numbers in .price and .priceint classes
$(document).ready(function (){
		$(".priceint").digits(); $(".price").digits();

//Fancybox
	$("a.highslide").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'opacity'		: true,
		'overlayOpacity'	: 0.6,
		'overlayColor'		: '#000000',
		'hideOnOverlayClick'	: true,
		'hideOnContentClick'	: true,
		'autoScale'		: true,
		'autoDimensions'	: true,
		'speedIn'		: 600, 
		'speedOut'		: 200, 
		'overlayShow'		: true,
		'showNavArrows'		: false
	});

//Associated Images caption
	$switches = $('#assoc-class > li');
	$slides = $('#slides > div');
	$switches.each(function(idx) {
            $(this).data('slide', $slides.eq(idx));
        }).hover(
        function() {
            $switches.removeClass('active');
            $slides.removeClass('active');             
            $(this).addClass('active');  
            $(this).data('slide').addClass('active');
        });
	
//Product Images Caption Switcher thing
	$switcher = $('#prodthumbslist > li');
	$bucket = $('#slider > div');
	$switcher.each(function(idx) {
            $(this).data('prodthumbscaptio', $bucket.eq(idx));
        }).hover(
        function() {
            $switcher.removeClass('activethumb');
            $bucket.removeClass('activethumb');             
            $(this).addClass('activethumb');  
            $(this).data('prodthumbscaptio').addClass('activethumb');
        });

//Latest slider - front page
			var slider = $('#latestslider').bxSlider({
				controls: false,
				displaySlideQty: 2,
				mode: 'vertical',
				infiniteLoop: false
			});
			
			$('#top_btn').click(function() {
				slider.goToPreviousSlide();
				return false;
			});
			
			$('#btm_btn').click(function() {
				slider.goToNextSlide();
				return false;
			});

}); /*End jQuery*/

// Begin regular javascript

//Checkout page shipping info = billing info checkbox

function shipsame(form){

if(form.sameasbilling.checked){

     form.shipping_first_name.value = form.first_name.value;
     form.shipping_last_name.value = form.last_name.value;
     form.shipping_address.value = form.address.value;
     form.shipping_address2.value = form.address2.value;
     form.shipping_city.value = form.city.value;
     form.shipping_zip.value = form.zip.value;
     form.shipping_company.value = form.company.value;
     form.shipping_phone.value = form.phone.value;
     
     if(form.state.type == "select-one"){
          var bStateIdx = form.state.selectedIndex;
          form.shipping_state.options[bStateIdx].selected = true;
     }
     else{
          form.shipping_state.value = form.state.value;
     }
     
     if(form.country_code.type == "select-one"){
          var bCountryIdx = form.country_code.selectedIndex;
          form.shipping_country_code.options[bCountryIdx].selected = true;
     }
     else{
          form.shipping_country_code.value = form.country_code.value;
     }
}
else{
     form.shipping_first_name.value = "";
     form.shipping_last_name.value = "";
     form.shipping_address.value = "";
     form.shipping_address2.value = "";
     form.shipping_company.value = "";
     form.shipping_phone.value = "";
     
     if(form.shipping_state.type == "select-one"){
          form.shipping_state.options[0].selected = true;
     }
     else{
          form.shipping_state.value = "";
     }

     if(form.shipping_country_code.type == "select-one"){
          form.shipping_country_code.options[0].selected = true;
     }
     else{
          form.shipping_country_code.value = "";
     }
     form.shipping_city.value = "";
     form.shipping_zip.value = "";
}
}
