function upholstery_customizer_hook___pre_object_instantiation__global(options){}
function upholstery_customizer_hook___pre_DOM_inspection__global(){}
function upholstery_customizer_hook___pre_bootstrap_loader__global(){}
function upholstery_customizer_hook___post_bootstrap_loader__global(){}

function upholstery_customizer_hook___pre_DOM_inspection__item(caller) {
	var is_item_list = (
		(typeof window.is_custom_upholstery_landing_page === 'function') &&
		(!window.is_custom_upholstery_landing_page())
	);

	// ========================================================================
	// move DOM position of <form id="formXXX"> tag
	var block_form = $('#' + caller.sku).closest('tr').find('form:first');
	var block_cell = $('#' + caller.sku).closest('td');

//	if (block_form.siblings('#' + caller.sku).length === 1) {
//	if (!$.contains($('#' + caller.sku).get(0), block_form.get(0))) {
	if (
		(!$.contains($('#' + caller.sku).get(0), block_form.get(0))) &&
		(!$.contains(block_form.get(0), $('#' + caller.sku).get(0)))
	){
		block_cell.find('script').each(function(){
			var js = $(this).html();
			if (js.match(/handlingCost/i) != null)		{$(this).remove();}
			if (js.match(/document\.write/i) != null)	{$(this).remove();}
		});
		block_form.detach();
		block_cell.children().appendTo(block_form);
		block_cell.empty();
		block_form.appendTo(block_cell);

		caller.form_id = block_form.attr('id');
	}

	// ========================================================================
	// move DOM position of "Quantity" form field element
	var row_src_data	= $('#' + caller.sku + ' td.descript div.addtoCartQuantity:not(:hidden)');
	var table_dst		= row_src_data.closest('table').find('table:first').find('tr:first').parent();
	var table_dst_data;

	if (table_dst.length === 1){
		table_dst_data	= $('<tr id="quantity_fields_row"><td class="smalltextnolink"><a>Quantity:</a></td><td>&nbsp;&nbsp;</td><td id="quantity_fields"></td></tr>');
		row_src_data.find(":input").appendTo($('#quantity_fields',table_dst_data));
		row_src_data.closest('tr').remove();
		table_dst_data.appendTo(table_dst);
	}

	// ========================================================================
	// dependencies: colorbox/jquery.colorbox-min.js, colorbox/document_ready.js
	// ========================================================================
	// alter the type of popup (if needed)
/* will re-enable when colorbox is used on live site */
/*
	var css_right, css_wrong;
	if (caller.options.show_flash) {
		css_right	= caller.options.anchor_css_class.flash;
		css_wrong	= caller.options.anchor_css_class.image;
	}
	else {
		css_right	= caller.options.anchor_css_class.image;
		css_wrong	= caller.options.anchor_css_class.flash;
	}
	var parent_container_selector	= '#' + caller.form_id + ' #' + caller.sku;
	var wrong_popups				= $(parent_container_selector + ' .' + css_wrong);
	if (wrong_popups.length > 0) {
		wrong_popups.each(function(){
			$(this).removeClass(css_wrong).addClass(css_right);
		});
		initialize_all_popup_elements( $(parent_container_selector) );
	}
*/

	// ========================================================================
	// apply custom filters
	var hidden_form_fields = get_hidden_form_fields(caller);
	if (hidden_form_fields != null) {
		caller.hidden_form_fields = hidden_form_fields;
	}
	var form_field_value_filters = get_form_field_value_filters(caller);
	if (form_field_value_filters != null) {
		caller.form_field_value_filters = form_field_value_filters;
	}
	var default_values = get_default_values(caller);
	if (default_values != null) {
		$.each(default_values, function(key, value){
			caller.default_values[key] = value;
		});
	}

	// ========================================================================
	// insert alt-image thumbnails which open a popup that contains a gallery
	// function is declared in: "alt_image_sets.js"
	if (
		(! is_item_list) &&
		(typeof alt_image_sets__load_thumbnails === 'function')
	){
		alt_image_sets__load_thumbnails( caller.sku );
	}
}

function upholstery_customizer_hook___post_DOM_inspection__item(caller) {}
function upholstery_customizer_hook___pre_JSON_downloads__item(caller) {}
function upholstery_customizer_hook___post_JSON_downloads__item(caller) {}
function upholstery_customizer_hook___pre_bootstrap_loader__item(caller) {}
function upholstery_customizer_hook___post_bootstrap_loader__item(caller) {}

function get_form_field_value_filters(caller) {
	var result = null;
	return result;
}

function get_hidden_form_fields(caller) {
	var result = null;
	return result;
}

function get_default_values(caller) {
	var result = null;
	return result;
}

// IE-specific: per-item, post-bootstrap
if (jQuery.browser.msie){
	jQuery(document).bind('custom_upholstery_bootstrap_complete', function(event, tool_instance){

		// called after initialize_fabrics()
		// form field dropdowns that were dynamically modified need to be "touched" so their css width & height is recalculated.
		var fix_dropdowns = function(){
			var select_tag;

			select_tag = $('#' + tool_instance.form_id + ' [name="' + tool_instance.form_fields[tool_instance.form_field_aliases.main_fabric] + '"]');
			select_tag.hide().show();

			if (tool_instance.has_piping) {
				select_tag = $('#' + tool_instance.form_id + ' [name="' + tool_instance.form_fields[tool_instance.form_field_aliases.piping_fabric] + '"]');
				select_tag.hide().show();
			}
		};

		fix_dropdowns();
	});
}

