function sampler_init() {
	var xpos = 0;									// starting position, should usually be 0
	var deltax = 232;								// width of headline item (282px + 18px right margin)
	var maxWidth = (numSamplerItems - 1) * deltax;	// set width of "strip"
	var speed = 250;								// transition speed, in milliseconds
	selectedSamplerItem = 1;
	
	// click functions
	jQuery("#sampler_box_next_button").click(function(){
		if (xpos > -maxWidth) {
			selectedSamplerItem++;
			xpos -= deltax;
			jQuery("#sampler_box_strip").animate({left: xpos},speed);
			toggleSamplerNavButtons();
		}
	});
	jQuery("#sampler_box_prev_button").click(function(){
		if (xpos < 0) {
			selectedSamplerItem--;
			xpos += deltax;
			jQuery("#sampler_box_strip").animate({left: xpos},speed);
			toggleSamplerNavButtons();
		}
	});
	
	jQuery("#sampler_box_prev_button").hover(function(){
		if (xpos < 0) {
			jQuery(this).addClass("sampler_box_prev_button_hover");
		}
	}, function() {
		jQuery(this).removeClass("sampler_box_prev_button_hover");
	});
	jQuery("#sampler_box_next_button").hover(function(){
		if (xpos > -maxWidth) {
			jQuery(this).addClass("sampler_box_next_button_hover");
		}
	}, function() {
		jQuery(this).removeClass("sampler_box_next_button_hover");
	});
	
}

function toggleSamplerNavButtons() {
	if (selectedSamplerItem == 1 && selectedSamplerItem < numSamplerItems) {
		jQuery("#sampler_box_prev_button").removeClass().addClass("sampler_box_prev_button_off");
		jQuery("#sampler_box_next_button").removeClass().addClass("sampler_box_next_button_on");
	} else if (selectedSamplerItem > 1 && selectedSamplerItem < numSamplerItems) {
		jQuery("#sampler_box_next_button").removeClass().addClass("sampler_box_next_button_on");
		jQuery("#sampler_box_prev_button").removeClass().addClass("sampler_box_prev_button_on");
	} else if (selectedSamplerItem == numSamplerItems) {
		jQuery("#sampler_box_next_button").removeClass().addClass("sampler_box_next_button_off");
		jQuery("#sampler_box_prev_button").removeClass().addClass("sampler_box_prev_button_on");
	}
}

// add to list of functions which run on window load
womAdd('sampler_init()');

// ensure that jQuery doesn't conflict with other libraries
// but still uses short names for objects
jQuery.noConflict();
