var hideProgress;
var main_url = 'http://www.vanagoncurtains.com/';

var current_step = 1; // 1=begin, 2=fabric, 3=tieback, 4=fringe, 5=hardware, 6=review/checkout
var max_step = 1; // 1=begin, 2=fabric, 3=tieback, 4=fringe, 5=hardware, 6=review/checkout
var last_step = 'begin'; // begin, fabric, tieback, fringe, hardware, review, checkout
var modify_field = ''; // begin, fabric, tieback, fringe, hardware, review, checkout
var continue_goto = 1;
var how_many_items = 0;
var how_many_items_fabric = 0;
var how_many_items_fabric_added = 0;
var how_many_items_tieback = 0;
var how_many_items_tieback_added = 0;
var how_many_items_fringe = 0;
var how_many_items_fringe_added = 0;
var how_many_items_hardware = 0;
var how_many_items_hardware_added = 0;

var selected_van_model = '';
var selected_van_year = '';

var selected_fabric = '';
var selected_fabric_option = '';
var previous_show_fabric = '';
var previous_fabric_option = '';
var selected_fabric_count = '';
var selected_fabric_type = '';
var selected_fabric_option_count = '';
var selected_fabric_option_type = '';
var selected_special_fabric = '';
var selected_special_fabric_count = '';

var selected_tieback = '';
var selected_tieback_option = '';
var selected_tieback_type = '';
var previous_show_tieback = '';
var previous_tieback_option = '';
var selected_tieback_count = '';
var selected_tieback_option_count = '';
var selected_special_tieback = '';
var selected_special_tieback_count = '';

var selected_fringe = '';
var selected_fringe_option = '';
var selected_fringe_count = '';
var selected_fringe_option_count = '';
var selected_fringe_option_type = '';
var selected_special_fringe = '';
var selected_special_fringe_count = '';

var selected_hardware = '';
var selected_hardware_option = '';
var selected_hardware_option_amount = '';
var selected_hardware_count = '';
var selected_hardware_option_count = '';
var selected_special_hardware = '';
var selected_special_hardware_count = '';

var removed_selection = '';
var logged_in = 0;
var register_customer = 0;
var reload_step = '';
var specials_count = '';
var current_special_page = 1;
var add_specials = 0;

var billing_shipping_check = 0;
var old_shipping_first_name = '';
var old_shipping_last_name = '';
var old_shipping_address = '';
var old_shipping_city = '';
var old_shipping_state = '';
var old_shipping_zip = '';

var show_forgot_password = 0;
var show_register_customer = 0;
var skip_steps = 0;

var multiple_fabric = 0;
var multiple_tieback = 0;
var multiple_fringe = 0;
var multiple_hardware = 0;

var current_selected_fabric = '';
var current_selected_fabric_count = '';
var current_selected_fabric_type = '';
var current_selected_fabric_option = '';
var current_selected_fabric_option_count = '';
var full_selected_fabric = '';
var full_selected_fabric_count = '';
var full_selected_fabric_type = '';
var full_selected_fabric_option = '';
var full_selected_fabric_option_count = '';
var full_selected_fabric_option_type = '';

var current_selected_tieback = '';
var current_selected_tieback_count = '';
var current_selected_tieback_type = '';
var current_selected_tieback_option = '';
var current_selected_tieback_option_count = '';
var full_selected_tieback = '';
var full_selected_tieback_count = '';
var full_selected_tieback_type = '';
var full_selected_tieback_option = '';
var full_selected_tieback_option_count = '';
var full_selected_tieback_option_type = '';

var current_selected_fringe = '';
var current_selected_fringe_count = '';
var current_selected_fringe_option = '';
var current_selected_fringe_option_count = '';
var current_selected_fringe_option_type = '';
var full_selected_fringe = '';
var full_selected_fringe_count = '';
var full_selected_fringe_option = '';
var full_selected_fringe_option_count = '';
var full_selected_fringe_option_type = '';

var current_selected_hardware = '';
var current_selected_hardware_count = '';
var current_selected_hardware_option = '';
var current_selected_hardware_option_count = '';
var current_selected_hardware_option_type = '';
var current_selected_hardware_option_amount = '';
var full_selected_hardware = '';
var full_selected_hardware_count = '';
var full_selected_hardware_option = '';
var full_selected_hardware_option_count = '';
var full_selected_hardware_option_type = '';
var full_selected_hardware_option_amount = '';

function hideProgressBox()
{
	Element.hide('progress_box');
}

function strstr(haystack, needle, bool)
{
	var pos = 0;

	haystack += '';
	pos = haystack.indexOf(needle);
	if ( pos == -1 )
	{
		return false;
	}
	else
	{
		if ( bool )
		{
			return haystack.substr(0, pos);
		}
		else
		{
			return haystack.slice(pos);
		}
	}
}

function nextStepFabric(type)
{
	clearTimeout(hideProgress); // clear any existing timeouts

	//grab submitted information
	var van_model = document.getElementById('van_model').value;
	if ( van_model != '' )
	{
		var van_year = document.getElementById('van_year_' + van_model.replace(' ', '_')).value;
	}
	else
	{
		var van_year = '';
	}

	/* set text to a loading box */
	$('progress_text').innerHTML = 'Loading...';
	Element.show('progress_box');

	//if ( van_year != '' && van_model != '' )
	//{
	selected_van_model = van_model;
	selected_van_year = van_year;

	/* add the ajax request to the end of defined url variable */
	var url = 'shop_ajax.php?step=begin' + ( $('step_fabric').innerHTML != '' ? '&type=save' : '' );

	/* make the ajax request for the information */
	new Ajax.Request(url, {
		method: 'post',
		parameters: 'van_year=' + van_year + '&van_model=' + van_model + '&how_many_items=' + how_many_items,
		onSuccess: function(xhrResponse) {
			if ( type != 'save' )
			{
				if ( $('step_fabric').innerHTML == '' )
				{
					$('step_fabric').innerHTML = xhrResponse.responseText;
				}

				document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
				document.getElementById('step_2_img').src = 'images/steps2_02.jpg';

				Element.show('start_over');
				Element.show('step_fabric');
				Element.hide('step_' + last_step);
				Element.hide('progress_box');
				current_step = 2;
				max_step = ( max_step < 2 ? 2 : max_step );
				last_step = 'fabric';
				parent.location.hash = 'step=fabric';
				modify_field = '';
			}
			else
			{
				Element.hide('progress_box');
			}
		},
		onFailure: function(xhrResponse) {
			$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
		}
	});
	/*}
	else
	{
	if ( van_model == '' )
	{
	$('progress_text').innerHTML = 'Model required.';
	hideProgress = setTimeout(hideProgressBox, 24000);
	}
	else if ( van_year == '' )
	{
	$('progress_text').innerHTML = 'Year required.';
	hideProgress = setTimeout(hideProgressBox, 24000);
	}
	}*/
}

function changeYear()
{
	modify_field = 'begin';
}

function changeModel()
{
	modify_field = 'begin';
}

function selectFabric(fabric_id, fabric_type)
{
	var which_type = '';
	var which_one = 0;
	var which_one2 = 0;

	if ( current_selected_fabric == '' )
	{
		how_many_items_fabric++;
		which_type = 'add';
		which_one = fabric_id;

		current_selected_fabric = document.getElementById('fabric_' + fabric_id + '_id').value;
		current_selected_fabric_count = fabric_id;
		current_selected_fabric_type = fabric_type;
	}
	else
	{
		if ( current_selected_fabric_count == fabric_id )
		{
			which_type = 'remove';
			which_one = fabric_id;

			current_selected_fabric = '';
			current_selected_fabric_count = '';
			current_selected_fabric_type = '';
		}
		else if ( current_selected_fabric_type == fabric_type )
		{
			which_type = 'remove';
			which_one = current_selected_fabric_count;
			which_one2 = fabric_id;

			current_selected_fabric = document.getElementById('fabric_' + fabric_id + '_id').value;
			current_selected_fabric_count = fabric_id;
			current_selected_fabric_type = fabric_type;
		}
		else
		{
			which_type = 'remove';
			which_one = current_selected_fabric_count;
			which_one2 = fabric_id;

			current_selected_fabric = document.getElementById('fabric_' + fabric_id + '_id').value;
			current_selected_fabric_count = fabric_id;
			current_selected_fabric_type = fabric_type;
		}
	}

	document.getElementById('fabric_' + which_one).style.borderColor = ( which_type == 'remove' ? '#FFFFFF' : '#b36328' );

	if ( which_one2 > 0 )
	{
		document.getElementById('fabric_' + which_one2).style.borderColor = '#b36328';
	}

	modify_field = 'fabric';
}

function showFabrics(type)
{
	if ( current_selected_fabric != '' )
	{
		how_many_items_fabric--;
		multipleItem('fabric', 'next_type');
	}

	previous_show_fabric = ( previous_show_fabric == '' ? 'better' : previous_show_fabric );

	if ( previous_show_fabric != type )
	{
		//Element.hide(previous_show_fabric + '_fabrics');
		//Element.show(type + '_fabrics');
		Element.hide('display_prices_' + previous_show_fabric);
		Element.show('display_prices_' + type);
		Effect.SlideUp(previous_show_fabric + '_fabrics', { duration: 0.25 });
		Effect.SlideDown(type + '_fabrics', { duration: 0.25 });
		document.getElementById(previous_show_fabric + '_fabric_arrow').src = 'images/boxarrow.jpg';
		document.getElementById(type + '_fabric_arrow').src = 'images/boxarrow-up.jpg';
		previous_show_fabric = type;
	}
}

function gotoBegin()
{
	if ( modify_field != '' )
	{
		if ( modify_field == 'begin' )
		{
			var check_selection = ( selected_van_model == '' ? '' : '1' ) + ( selected_van_year == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepFabric('save', '', '');
		}
		else if ( modify_field == 'fabric' )
		{
			var check_selection = ( selected_fabric == '' ? '' : '1' ) + ( selected_fabric_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepTieback('save', '', '');
		}
		else if ( modify_field == 'tieback' )
		{
			continue_goto = 1;
			nextStepFringe('save', '', '');
		}
		else if ( modify_field == 'fringe' )
		{
			var check_selection = ( selected_fringe == '' ? '' : '1' ) + ( selected_fringe_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepHardware('save', '', '');
		}
		else if ( modify_field == 'hardware' )
		{
			var check_selection = ( selected_hardware == '' ? '' : '1' ) + ( selected_hardware_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepReview('save', '', '');
		}
		modify_field = '';
	}

	if ( continue_goto == 1 && ((last_step != 'begin' || show_forgot_password == 1) || register_customer == 1) )
	{
		if ( last_step == 'checkout' )
		{
			Element.hide('checkout_step');
			last_step = 'review';
		}

		if ( show_forgot_password == 1 )
		{
			Effect.SlideDown('step_begin', { duration: 1.0 });
		}
		else
		{
			Element.show('step_begin');
		}

		if ( register_customer == 1 )
		{
			Element.hide('register_customer');
			register_customer = 0;
			clearRegisterCustomer();
		}
		else
		{
			if ( show_forgot_password == 1 )
			{
				Effect.SlideUp('forgot_password', { duration: 1.0 });
				show_forgot_password = 0;
			}
			else
			{
				Element.hide('step_' + last_step);
			}

			if ( $('step_specials').innerHTML != '' )
			{
				Element.hide('step_specials');
				$('step_specials').innerHTML = '';
			}
		}

		document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
		document.getElementById('step_1_img').src = 'images/steps2_01.jpg';
		last_step = 'begin';
		current_step = 1;
		parent.location.hash = 'step=begin';
	}
	else if ( add_specials == 1 )
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = 'Loading...';
		Element.show('progress_box');

		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=add_specials';

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'special_fabric=' + selected_special_fabric + '&special_tieback=' + selected_special_tieback + '&special_fringe=' + selected_special_fringe + '&special_hardware=' + selected_special_hardware + '&how_many_items=' + how_many_items,
			onSuccess: function(xhrResponse) {
				Element.hide('step_specials');
				Element.show('shopping');
				Element.show('progress_bar');
				Element.show('step_begin');
				Element.hide('progress_box');

				document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
				document.getElementById('step_1_img').src = 'images/steps2_01.jpg';
				last_step = 'begin';
				current_step = 1;
				parent.location.hash = 'step=begin';

				add_specials = 0;
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
}

function selectFabricOption(fabric_option_id)
{
	var which_type = '';
	var which_one = 0;
	var which_one2 = 0;

	if ( current_selected_fabric_option == '' )
	{
		which_type = 'add';
		which_one = fabric_option_id;

		current_selected_fabric_option = document.getElementById('fabrics_option_' + fabric_option_id + '_id').value;
		current_selected_fabric_option_count = fabric_option_id;
	}
	else
	{
		if ( current_selected_fabric_option_count == fabric_option_id )
		{
			which_type = 'remove';
			which_one = fabric_option_id;

			current_selected_fabric_option = '';
			current_selected_fabric_option_count = '';
		}
		else
		{
			which_type = 'remove';
			which_one = current_selected_fabric_option_count;
			which_one2 = fabric_option_id;

			current_selected_fabric_option = document.getElementById('fabrics_option_' + fabric_option_id + '_id').value;
			current_selected_fabric_option_count = fabric_option_id;
		}
	}

	document.getElementById('fabrics_option_' + which_one).style.backgroundColor = ( which_type == 'remove' ? '#E2E2E2' : '#ed712d' );
	document.getElementById('fabrics_option_' + which_one).style.color = ( which_type == 'remove' ? '#b36328' : '#FFFFFF' );
	document.getElementById('fabrics_option_' + which_one + '_price').style.backgroundColor = ( which_type == 'remove' ? '#E2E2E2' : '#ed712d' );
	document.getElementById('fabrics_option_' + which_one + '_price').style.color = ( which_type == 'remove' ? '#b36328' : '#FFFFFF' );

	if ( which_one2 > 0 )
	{
		document.getElementById('fabrics_option_' + which_one2).style.backgroundColor = '#ed712d';
		document.getElementById('fabrics_option_' + which_one2).style.color = '#FFFFFF';
		document.getElementById('fabrics_option_' + which_one2 + '_price').style.backgroundColor = '#ed712d';
		document.getElementById('fabrics_option_' + which_one2 + '_price').style.color = '#FFFFFF';
	}

	modify_field = 'fabric';
}

function nextStepTieback(type, add_to_cart, next_review)
{
	clearTimeout(hideProgress); // clear any existing timeouts

	/* set text to a loading box */
	$('progress_text').innerHTML = 'Loading...';
	Element.show('progress_box');

	selected_fabric = current_selected_fabric;
	selected_fabric_option = current_selected_fabric_option;

	var passed = 1;
	var check_fabric = selected_fabric;
	var check_fabric_option = selected_fabric_option;

	if ( check_fabric == '' && check_fabric_option == '' )
	{
		passed = 1;
	}
	else
	{
		if ( check_fabric != '' )
		{
			if ( !check_fabric || check_fabric == undefined )
			{
				passed = 2; // no fabric
			}
			else if ( !check_fabric_option || check_fabric_option == undefined )
			{
				passed = 3; // no fabric option
			}
		}
		else
		{
			passed = 2; // no fabric
		}
	}

	if ( passed == 1 )
	{
		if ( removed_selection == '' && add_to_cart != '' )
		{
			full_selected_fabric = ( full_selected_fabric == '' ? '' : full_selected_fabric + ',' ) + selected_fabric;
			full_selected_fabric_count = ( full_selected_fabric_count == '' ? '' : full_selected_fabric_count + ',' ) + selected_fabric_count;
			full_selected_fabric_type = ( full_selected_fabric_type == '' ? '' : full_selected_fabric_type + ',' ) + selected_fabric_type;

			full_selected_fabric_option = ( full_selected_fabric_option == '' ? '' : full_selected_fabric_option + ',' ) + selected_fabric_option;
			full_selected_fabric_option_count = ( full_selected_fabric_option_count == '' ? '' : full_selected_fabric_option_count + ',' ) + selected_fabric_option_count;
			full_selected_fabric_option_type = ( full_selected_fabric_option_type == '' ? '' : full_selected_fabric_option_type + ',' ) + selected_fabric_option_type;
		}

		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=' + ( removed_selection != '' ? 'review&remove=fabric' : 'fabric' ) + ( removed_selection == '' && $('step_tieback').innerHTML != '' ? '&type=save' : '' );

		if ( add_to_cart != '' && selected_fabric_option != '' )
		{
			how_many_items++;
		}
		
		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'fabric=' + full_selected_fabric + '&fabric_option=' + full_selected_fabric_option + '&special_fabric=' + selected_special_fabric + '&how_many_items=' + how_many_items,
			onSuccess: function(xhrResponse) {
				if ( removed_selection == '' )
				{
					if ( add_to_cart != '' && selected_fabric_option != '' )
					{
						how_many_items_fabric_added++;
						$('progress_text').innerHTML = how_many_items_fabric + ' item' + ( how_many_items_fabric == 1 ? '' : 's' ) + ' added to cart';
						hideProgress = setTimeout(hideProgressBox, 24000);

						if ( document.getElementById('how_many_items_fabric') )
						{
							$('how_many_items_fabric').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
						}
						if ( document.getElementById('how_many_items_tieback') )
						{
							$('how_many_items_tieback').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
						}
						if ( document.getElementById('how_many_items_fringe') )
						{
							$('how_many_items_fringe').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
						}
						if ( document.getElementById('how_many_items_hardware') )
						{
							$('how_many_items_hardware').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
						}
						if ( document.getElementById('how_many_items_special') )
						{
							$('how_many_items_special').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
						}

						if ( next_review == '' )
						{
							showMultipleItem('fabric');
						}
					}

					if ( add_to_cart == '' || next_review == 'tieback' || selected_fabric_option == '' )
					{
						if ( selected_fabric_option != '' )
						{
							multipleItem('fabric', 'tieback');
						}

						if ( $('step_tieback').innerHTML == '' )
						{
							$('step_tieback').innerHTML = xhrResponse.responseText;
						}

						if ( type != 'save' )
						{
							Element.show('step_tieback');
							if ( skip_steps == 1 )
							{
								Element.hide('step_' + last_step);
								skip_steps = 0;
								document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
							}
							else
							{
								document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
								Element.hide('step_' + last_step);
							}
							Element.hide('progress_box');
							current_step = 3;
							max_step = ( max_step < 3 ? 3 : max_step );
							last_step = 'tieback';
							parent.location.hash = 'step=tieback';
							modify_field = '';

							document.getElementById('step_3_img').src = 'images/steps2_03.jpg';
						}
						else
						{
							document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
							Element.hide('progress_box');
						}

						if ( how_many_items_fabric > 0 )
						{
							$('progress_text').innerHTML = how_many_items_fabric + ' item' + ( how_many_items_fabric == 1 ? '' : 's' ) + ' added to cart';
							Element.show('progress_box');
							hideProgress = setTimeout(hideProgressBox, 24000);
						}
					}
				}
				else
				{
					$('step_review').innerHTML = xhrResponse.responseText;
					Element.hide('progress_box');
					Element.hide('step_fabric');
					Element.show('step_review');
					current_step = 6;
					last_step = 'review';
					parent.location.hash = 'step=review';
					removed_selection = '';

					document.getElementById('step_2_img').src = 'images/steps_02.jpg';
					document.getElementById('step_6_img').src = 'images/steps2_06.jpg';
				}
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
	else
	{
		if ( passed == 2 )
		{
			$('progress_text').innerHTML = 'Fabric required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( passed == 3 )
		{
			$('progress_text').innerHTML = 'Pricing option required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
	}
}

function showMultipleItem(type)
{
	grayOut(true);
	$('multiple_message').innerHTML = '<table width="573" height="200" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="5"><img src="popup/option_01.jpg" width="573" height="121" alt=""></td></tr><tr><td><img src="popup/option_02.jpg" width="55" height="51" alt=""></td><td><img src="popup/option_03.jpg" onclick="multipleItem(\'' + type + '\', \'\');" style="cursor: pointer;" width="81" height="51" alt=""></td><td><img src="popup/option_04.jpg" onclick="closeMultipleItem(\'' + type + '\', \'next\');" style="cursor: pointer;" width="206" height="51" alt=""></td><td><img onclick="closeMultipleItem(\'' + type + '\', \'checkout\');" style="cursor: pointer;" src="popup/option_05.jpg" width="182" height="51" alt=""></td><td><img src="popup/option_06.jpg" width="49" height="51" alt=""></td></tr><tr><td colspan="5"><img src="popup/option_07.jpg" width="573" height="28" alt=""></td></tr></table>';
	Element.show('multiple_message');
}

function closeMultipleItem(type, go_where)
{
	grayOut(false);
	Element.hide('multiple_message');
	modify_field = type;
	if ( go_where == 'next' )
	{
		if ( type == 'fabric' )
		{
			nextStepTieback('new', '', '');
		}
		else if ( type == 'tieback' )
		{
			nextStepFringe('new', '', '');
		}
		else if ( type == 'fringe' )
		{
			nextStepHardware('new', '', '');
		}
		else if ( type == 'hardware' )
		{
			nextStepReview('new', '', '');
		}
	}
	else
	{
		multipleItem(type, 'next');
		nextStepReview('new', '', '');
	}
}

function multipleItem(type, next_step)
{
	if ( next_step == '' )
	{
		grayOut(false);
		Element.hide('multiple_message');
	}

	if ( type == 'fabric' )
	{
		multiple_fabric = 1;

		document.getElementById(type + '_' + current_selected_fabric_count).style.borderColor = '#FFFFFF';

		if ( next_step != 'next_type' )
		{
			document.getElementById(type + 's_option_' + current_selected_fabric_option_count).style.backgroundColor = '#E2E2E2';
			document.getElementById(type + 's_option_' + current_selected_fabric_option_count).style.color = '#b36328';
			document.getElementById(type + 's_option_' + current_selected_fabric_option_count + '_price').style.backgroundColor = '#E2E2E2';
			document.getElementById(type + 's_option_' + current_selected_fabric_option_count + '_price').style.color = '#b36328';
		}

		current_selected_fabric = '';
		current_selected_fabric_count = '';
		current_selected_fabric_type = '';
		current_selected_fabric_option = '';
		current_selected_fabric_option_count = '';
		current_selected_fabric_option_type = '';
	}
	else if ( type == 'tieback' )
	{
		multiple_tieback = 1;

		document.getElementById(current_selected_tieback_type + '_' + type + '_' + current_selected_tieback_count).style.borderColor = '#FFFFFF';

		current_selected_tieback = '';
		current_selected_tieback_count = '';
		current_selected_tieback_type = '';
	}
	else if ( type == 'fringe' )
	{
		multiple_fringe = 1;

		document.getElementById(type + '_' + current_selected_fringe_count).style.borderColor = '#FFFFFF';

		if ( next_step != 'next_type' )
		{
			document.getElementById(type + 's_option_' + current_selected_fringe_option_count).style.backgroundColor = '#E2E2E2';
			document.getElementById(type + 's_option_' + current_selected_fringe_option_count).style.color = '#b36328';
			document.getElementById(type + 's_option_' + current_selected_fringe_option_count + '_price').style.backgroundColor = '#E2E2E2';
			document.getElementById(type + 's_option_' + current_selected_fringe_option_count + '_price').style.color = '#b36328';
		}

		current_selected_fringe = '';
		current_selected_fringe_count = '';
		current_selected_fringe_option = '';
		current_selected_fringe_option_count = '';
		current_selected_fringe_option_type = '';
	}
	else if ( type == 'hardware' )
	{
		multiple_hardware = 1;

		document.getElementById(type + '_' + current_selected_hardware_count).style.borderColor = '#FFFFFF';

		if ( next_step != 'next_type' )
		{
			document.getElementById(type + 's_option_' + current_selected_hardware_option_count).style.backgroundColor = '#E2E2E2';
			document.getElementById(type + 's_option_' + current_selected_hardware_option_count).style.color = '#b36328';
			document.getElementById(type + 's_option_' + current_selected_hardware_option_count + '_price').style.backgroundColor = '#E2E2E2';
			document.getElementById(type + 's_option_' + current_selected_hardware_option_count + '_price').style.color = '#b36328';
		}

		current_selected_hardware = '';
		current_selected_hardware_count = '';
		current_selected_hardware_option = '';
		current_selected_hardware_option_count = '';
		current_selected_hardware_option_type = '';
		current_selected_hardware_option_amount = '';
	}
}

function gotoFabric(add_items)
{
	if ( modify_field != '' )
	{
		if ( modify_field == 'begin' )
		{
			var check_selection = ( selected_van_model == '' ? '' : '1' ) + ( selected_van_year == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepFabric('save', '', '');
		}
		else if ( modify_field == 'fabric' )
		{
			var check_selection = ( selected_fabric == '' ? '' : '1' ) + ( selected_fabric_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepTieback('save', '', '');
		}
		else if ( modify_field == 'tieback' )
		{
			continue_goto = 1;
			nextStepFringe('save', '', '');
		}
		else if ( modify_field == 'fringe' )
		{
			var check_selection = ( selected_fringe == '' ? '' : '1' ) + ( selected_fringe_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepHardware('save', '', '');
		}
		else if ( modify_field == 'hardware' )
		{
			var check_selection = ( selected_hardware == '' ? '' : '1' ) + ( selected_hardware_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepReview('save', '', '');
		}
		modify_field = '';
	}

	if ( continue_goto == 1 && ((last_step != 'fabric' || show_forgot_password == 1) || register_customer == 1) && $('step_fabric').innerHTML != '' )
	{
		if ( last_step == 'checkout' )
		{
			Element.hide('checkout_step');
			last_step = 'review';
		}
		if ( max_step >= 2 )
		{
			if ( $('step_fabric').innerHTML != '' )
			{
				if ( show_forgot_password == 1 )
				{
					Effect.SlideDown('step_fabric', { duration: 1.0 });
				}
				else
				{
					Element.show('step_fabric');
				}

				if ( register_customer == 1 )
				{
					Element.hide('register_customer');
					register_customer = 0;
					clearRegisterCustomer();
				}
				else
				{
					if ( show_forgot_password == 1 )
					{
						Effect.SlideUp('forgot_password', { duration: 1.0 });
						show_forgot_password = 0;
					}
					else
					{
						Element.hide('step_' + last_step);
					}

					if ( $('step_specials').innerHTML != '' )
					{
						Element.hide('step_specials');
						$('step_specials').innerHTML = '';
					}
				}

				document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
				document.getElementById('step_2_img').src = 'images/steps2_02.jpg';
				last_step = 'fabric';
				current_step = 2;
				parent.location.hash = 'step=fabric';
			}
		}
	}
	else if ( add_specials == 1 )
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = 'Loading...';
		Element.show('progress_box');

		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=add_specials';

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'special_fabric=' + selected_special_fabric + '&special_tieback=' + selected_special_tieback + '&special_fringe=' + selected_special_fringe + '&special_hardware=' + selected_special_hardware + '&how_many_items=' + how_many_items,
			onSuccess: function(xhrResponse) {
				Element.hide('step_specials');
				Element.show('shopping');
				Element.show('progress_bar');
				Element.show('step_fabric');
				Element.hide('progress_box');

				document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
				document.getElementById('step_2_img').src = 'images/steps2_02.jpg';
				last_step = 'fabric';
				current_step = 2;
				parent.location.hash = 'step=fabric';

				add_specials = 0;
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
	else if ( $('step_fabric').innerHTML == '' )
	{
		skip_steps = 1;
		nextStepFabric('new', '', 'fabric');
		Element.show('start_over');
	}
}

function gotoTieback(add_items)
{
	if ( modify_field != '' )
	{
		if ( modify_field == 'begin' )
		{
			var check_selection = ( selected_van_model == '' ? '' : '1' ) + ( selected_van_year == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepFabric('save', '', '');
		}
		else if ( modify_field == 'fabric' )
		{
			var check_selection = ( selected_fabric == '' ? '' : '1' ) + ( selected_fabric_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepTieback('save', '', '');
		}
		else if ( modify_field == 'tieback' )
		{
			continue_goto = 1;
			nextStepFringe('save', '', '');
		}
		else if ( modify_field == 'fringe' )
		{
			var check_selection = ( selected_fringe == '' ? '' : '1' ) + ( selected_fringe_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepHardware('save', '', '');
		}
		else if ( modify_field == 'hardware' )
		{
			var check_selection = ( selected_hardware == '' ? '' : '1' ) + ( selected_hardware_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepReview('save', '', '');
		}
		modify_field = '';
	}

	if ( continue_goto == 1 && ((last_step != 'tieback' || show_forgot_password == 1) || register_customer == 1) && $('step_tieback').innerHTML != '' )
	{
		if ( last_step == 'checkout' )
		{
			Element.hide('checkout_step');
			last_step = 'review';
		}
		if ( max_step >= 3 )
		{
			if ( $('step_tieback').innerHTML != '' )
			{
				if ( show_forgot_password == 1 )
				{
					Effect.SlideDown('step_tieback', { duration: 1.0 });
				}
				else
				{
					Element.show('step_tieback');
				}

				if ( register_customer == 1 )
				{
					Element.hide('register_customer');
					register_customer = 0;
					clearRegisterCustomer();
				}
				else
				{
					if ( show_forgot_password == 1 )
					{
						Effect.SlideUp('forgot_password', { duration: 1.0 });
						show_forgot_password = 0;
					}
					else
					{
						Element.hide('step_' + last_step);
					}

					if ( $('step_specials').innerHTML != '' )
					{
						Element.hide('step_specials');
						$('step_specials').innerHTML = '';
					}
				}

				document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
				document.getElementById('step_3_img').src = 'images/steps2_03.jpg';
				last_step = 'tieback';
				current_step = 3;
				parent.location.hash = 'step=tieback';
			}
		}
	}
	else if ( add_specials == 1 )
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = 'Loading...';
		Element.show('progress_box');

		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=add_specials';

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'special_fabric=' + selected_special_fabric + '&special_tieback=' + selected_special_tieback + '&special_fringe=' + selected_special_fringe + '&special_hardware=' + selected_special_hardware + '&how_many_items=' + how_many_items,
			onSuccess: function(xhrResponse) {
				Element.hide('step_specials');
				Element.show('shopping');
				Element.show('progress_bar');
				Element.show('step_tieback');
				Element.hide('progress_box');

				document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
				document.getElementById('step_3_img').src = 'images/steps2_03.jpg';
				last_step = 'tieback';
				current_step = 3;
				parent.location.hash = 'step=tieback';

				add_specials = 0;
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
	else if ( $('step_tieback').innerHTML == '' )
	{
		skip_steps = 1;
		nextStepTieback('new', '', 'tieback');
		Element.show('start_over');
	}
}

function selectTieback(tieback_type, tieback_id)
{
	var which_type = '';
	var which_one = 0;
	var which_one2 = 0;

	if ( current_selected_tieback == '' )
	{
		how_many_items_tieback++;
		which_type = 'add';
		which_one = tieback_id;

		current_selected_tieback = document.getElementById(tieback_type + '_tieback_' + tieback_id + '_id').value;
		current_selected_tieback_count = tieback_id;
		current_selected_tieback_type = tieback_type;
	}
	else
	{
		if ( current_selected_tieback_count == tieback_id )
		{
			which_type = 'remove';
			which_one = tieback_id;

			current_selected_tieback = '';
			current_selected_tieback_count = '';
			current_selected_tieback_type = '';
		}
		else if ( current_selected_tieback_type == tieback_type )
		{
			which_type = 'remove';
			which_one = current_selected_tieback_count;
			which_one2 = tieback_id;

			current_selected_tieback = document.getElementById(tieback_type + '_tieback_' + tieback_id + '_id').value;
			current_selected_tieback_count = tieback_id;
			current_selected_tieback_type = tieback_type;
		}
		else
		{
			which_type = 'remove';
			which_one = current_selected_tieback_count;
			which_one2 = tieback_id;

			current_selected_tieback = document.getElementById(tieback_type + '_tieback_' + tieback_id + '_id').value;
			current_selected_tieback_count = tieback_id;
			current_selected_tieback_type = tieback_type;
		}
	}

	document.getElementById(tieback_type + '_tieback_' + which_one).style.borderColor = ( which_type == 'remove' ? '#FFFFFF' : '#b36328' );

	if ( which_one2 > 0 )
	{
		document.getElementById(tieback_type + '_tieback_' + which_one2).style.borderColor = '#b36328';
	}

	modify_field = 'tieback';
}

function showTiebacks(type)
{
	if ( current_selected_tieback != '' )
	{
		how_many_items_tieback--;
		multipleItem('tieback', 'next_type');
	}

	previous_show_tieback = ( previous_show_tieback == '' ? 'A' : previous_show_tieback );

	if ( previous_show_tieback != type )
	{
		Effect.SlideUp(previous_show_tieback + '_tiebacks', { duration: 0.25 });
		Effect.SlideDown(type + '_tiebacks', { duration: 0.25 });
		//Element.hide(previous_show_tieback + '_tiebacks');
		//Element.show(type + '_tiebacks');
		document.getElementById(previous_show_tieback + '_tieback_arrow').src = 'images/boxarrow.jpg';
		document.getElementById(type + '_tieback_arrow').src = 'images/boxarrow-up.jpg';
		previous_show_tieback = type;
	}
}

/*function selectTiebackOption(option_id)
{
var i = 1;
while ( document.getElementById('tiebacks_option_' + i) )
{
document.getElementById('tiebacks_option_' + i).style.backgroundColor = '#E2E2E2';
document.getElementById('tiebacks_option_' + i).style.color = '#b36328';
document.getElementById('tiebacks_option_' + i + '_type').style.backgroundColor = '#E2E2E2';
document.getElementById('tiebacks_option_' + i + '_type').style.color = '#b36328';
i++;
}

if ( option_id != selected_tieback_option_count )
{
document.getElementById('tiebacks_option_' + option_id).style.backgroundColor = '#ed712d';
document.getElementById('tiebacks_option_' + option_id).style.color = '#FFFFFF';
document.getElementById('tiebacks_option_' + option_id + '_type').style.backgroundColor = '#ed712d';
document.getElementById('tiebacks_option_' + option_id + '_type').style.color = '#FFFFFF';

selected_tieback_option = document.getElementById('tiebacks_option_' + option_id + '_id').value;
selected_tieback_option_count = option_id;
}
else
{
selected_tieback_option = '';
selected_tieback_option_count = '';
}

modify_field = 'tieback';
}*/

function nextStepFringe(type, add_to_cart, next_review)
{
	clearTimeout(hideProgress); // clear any existing timeouts

	/* set text to a loading box */
	$('progress_text').innerHTML = 'Loading...';
	Element.show('progress_box');

	selected_tieback = current_selected_tieback;
	selected_tieback_option = current_selected_tieback_option;

	//if ( selected_tieback != '' && selected_tieback_option != '' )
	//{
	/* add the ajax request to the end of defined url variable */
	var url = 'shop_ajax.php?step=' + ( removed_selection != '' ? 'review&remove=tieback' : 'fringe' ) + ( removed_selection == '' && $('step_fringe').innerHTML != '' ? '&type=save' : '' );

	if ( removed_selection == '' && add_to_cart != '' )
	{
		full_selected_tieback = ( full_selected_tieback == '' ? '' : full_selected_tieback + ',' ) + selected_tieback;
		full_selected_tieback_count = ( full_selected_tieback_count == '' ? '' : full_selected_tieback_count + ',' ) + selected_tieback_count;
		full_selected_tieback_type = ( full_selected_tieback_type == '' ? '' : full_selected_tieback_type + ',' ) + selected_tieback_type;
	}

	if ( add_to_cart != '' && selected_tieback != '' )
	{
		how_many_items++;
	}
	
	/* make the ajax request for the information */
	new Ajax.Request(url, {
		method: 'post',
		parameters: 'tieback=' + full_selected_tieback + '&tieback_option=' + selected_tieback_option + '&special_tieback=' + selected_special_tieback + '&how_many_items=' + how_many_items,
		onSuccess: function(xhrResponse) {
			if ( removed_selection == '' )
			{
				if ( add_to_cart != '' && selected_tieback != '' )
				{
					how_many_items_tieback_added++;
					$('progress_text').innerHTML = how_many_items_tieback + ' item' + ( how_many_items_tieback == 1 ? '' : 's' ) + ' added to cart';
					hideProgress = setTimeout(hideProgressBox, 24000);

					if ( document.getElementById('how_many_items_fabric') )
					{
						$('how_many_items_fabric').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
					}
					if ( document.getElementById('how_many_items_tieback') )
					{
						$('how_many_items_tieback').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
					}
					if ( document.getElementById('how_many_items_fringe') )
					{
						$('how_many_items_fringe').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
					}
					if ( document.getElementById('how_many_items_hardware') )
					{
						$('how_many_items_hardware').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
					}
					if ( document.getElementById('how_many_items_special') )
					{
						$('how_many_items_special').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
					}

					if ( next_review == '' )
					{
						showMultipleItem('tieback');
					}
				}
				if ( add_to_cart == '' || next_review == 'tieback' || selected_tieback == '' )
				{
					if ( selected_tieback != '' )
					{
						multipleItem('tieback', 'tieback');
					}

					if ( $('step_fringe').innerHTML == '' )
					{
						$('step_fringe').innerHTML = xhrResponse.responseText;
					}

					if ( type != 'save' )
					{
						Element.show('step_fringe');
						if ( skip_steps == 1 )
						{
							Element.hide('step_' + last_step);
							skip_steps = 0;
							document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
						}
						else
						{
							Element.hide('step_' + last_step);
							document.getElementById('step_3_img').src = 'images/steps_03.jpg';
						}
						Element.hide('progress_box');
						current_step = 4;
						max_step = ( max_step < 4 ? 4 : max_step );
						last_step = 'fringe';
						parent.location.hash = 'step=fringe';
						modify_field = '';

						document.getElementById('step_4_img').src = 'images/steps2_04.jpg';
					}
					else
					{
						Element.hide('progress_box');
					}

					if ( how_many_items_tieback > 0 )
					{
						$('progress_text').innerHTML = how_many_items_tieback + ' item' + ( how_many_items_tieback == 1 ? '' : 's' ) + ' added to cart';
						Element.show('progress_box');
						hideProgress = setTimeout(hideProgressBox, 24000);
					}
					continue_goto = 1;
				}
			}
			else
			{
				$('step_review').innerHTML = xhrResponse.responseText;
				Element.hide('progress_box');
				Element.hide('step_tieback');
				Element.show('step_review');
				current_step = 6;
				last_step = 'review';
				parent.location.hash = 'step=review';
				removed_selection = '';

				document.getElementById('step_3_img').src = 'images/steps_03.jpg';
				document.getElementById('step_6_img').src = 'images/steps2_06.jpg';
			}
		},
		onFailure: function(xhrResponse) {
			$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
		}
	});
}

function gotoFringe()
{
	if ( modify_field != '' )
	{
		if ( modify_field == 'begin' )
		{
			var check_selection = ( selected_van_model == '' ? '' : '1' ) + ( selected_van_year == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepFabric('save', '', '');
		}
		else if ( modify_field == 'fabric' )
		{
			var check_selection = ( selected_fabric == '' ? '' : '1' ) + ( selected_fabric_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepTieback('save', '', '');
		}
		else if ( modify_field == 'tieback' )
		{
			continue_goto = 1;
			nextStepFringe('save', '', '');
		}
		else if ( modify_field == 'fringe' )
		{
			var check_selection = ( selected_fringe == '' ? '' : '1' ) + ( selected_fringe_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepHardware('save', '', '');
		}
		else if ( modify_field == 'hardware' )
		{
			var check_selection = ( selected_hardware == '' ? '' : '1' ) + ( selected_hardware_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepReview('save', '', '');
		}
		modify_field = '';
	}

	if ( continue_goto == 1 && ((last_step != 'fringe' || show_forgot_password == 1) || register_customer == 1) && $('step_fringe').innerHTML != '' )
	{
		if ( last_step == 'checkout' )
		{
			Element.hide('checkout_step');
			last_step = 'review';
		}
		if ( max_step >= 4 )
		{
			if ( $('step_fringe').innerHTML != '' )
			{
				if ( show_forgot_password == 1 )
				{
					Effect.SlideDown('step_fringe', { duration: 1.0 });
				}
				else
				{
					Element.show('step_fringe');
				}

				if ( register_customer == 1 )
				{
					Element.hide('register_customer');
					register_customer = 0;
					clearRegisterCustomer();
				}
				else
				{
					if ( show_forgot_password == 1 )
					{
						Effect.SlideUp('forgot_password', { duration: 1.0 });
						show_forgot_password = 0;
					}
					else
					{
						Element.hide('step_' + last_step);
					}

					if ( $('step_specials').innerHTML != '' )
					{
						Element.hide('step_specials');
						$('step_specials').innerHTML = '';
					}
				}

				document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
				document.getElementById('step_4_img').src = 'images/steps2_04.jpg';
				last_step = 'fringe';
				current_step = 4;
				parent.location.hash = 'step=fringe';
			}
		}
	}
	else if ( add_specials == 1 )
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = 'Loading...';
		Element.show('progress_box');
		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=add_specials';

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'special_fabric=' + selected_special_fabric + '&special_tieback=' + selected_special_tieback + '&special_fringe=' + selected_special_fringe + '&special_hardware=' + selected_special_hardware + '&how_many_items=' + how_many_items,
			onSuccess: function(xhrResponse) {
				Element.hide('step_specials');
				Element.show('shopping');
				Element.show('progress_bar');
				Element.show('step_fringe');
				Element.hide('progress_box');

				document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
				document.getElementById('step_4_img').src = 'images/steps2_04.jpg';
				last_step = 'fringe';
				current_step = 4;
				parent.location.hash = 'step=fringe';

				add_specials = 0;
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
	else if ( $('step_fringe').innerHTML == '' )
	{
		skip_steps = 1;
		nextStepFringe('new', '', 'fringe');
		Element.show('start_over');
	}
}

function selectFringe(fringe_id)
{
	var which_type = '';
	var which_one = 0;
	var which_one2 = 0;

	if ( current_selected_fringe == '' )
	{
		how_many_items_fringe++;
		which_type = 'add';
		which_one = fringe_id;

		current_selected_fringe = document.getElementById('fringe_' + fringe_id + '_id').value;
		current_selected_fringe_count = fringe_id;
	}
	else
	{
		if ( current_selected_fringe_count == fringe_id )
		{
			which_type = 'remove';
			which_one = fringe_id;

			current_selected_fringe = '';
			current_selected_fringe_count = '';
		}
		else
		{
			which_type = 'remove';
			which_one = current_selected_fringe_count;
			which_one2 = fringe_id;

			current_selected_fringe = document.getElementById('fringe_' + fringe_id + '_id').value;
			current_selected_fringe_count = fringe_id;
		}
	}

	document.getElementById('fringe_' + which_one).style.borderColor = ( which_type == 'remove' ? '#FFFFFF' : '#b36328' );

	if ( which_one2 > 0 )
	{
		document.getElementById('fringe_' + which_one2).style.borderColor = '#b36328';
	}

	modify_field = 'fringe';
}

function selectFringeOption(option_id, option_type)
{
	var which_type = '';
	var which_one = 0;
	var which_one2 = 0;

	if ( current_selected_fringe_option == '' )
	{
		which_type = 'add';
		which_one = option_id;

		current_selected_fringe_option = document.getElementById('fringes_option_' + option_id + '_id').value;
		current_selected_fringe_option_count = option_id;
		current_selected_fringe_option_type = option_type;
	}
	else
	{
		if ( strstr(current_selected_fringe_option, '-' ) )
		{
			var is_there_multiple_options = current_selected_fringe_option.split('-');
			var is_there_multiple_options_count = current_selected_fringe_option_count.split('-');
			var is_there_multiple_options_type = current_selected_fringe_option_type.split('-');
			if ( is_there_multiple_options_count[0] == option_id )
			{
				which_type = 'remove';
				which_one = option_id;

				current_selected_fringe_option = current_selected_fringe_option[1];
				current_selected_fringe_option_count = current_selected_fringe_option_count[1];
				current_selected_fringe_option_type = current_selected_fringe_option_type[1];
			}
			else if ( is_there_multiple_options_type[0] == option_type )
			{
				which_type = 'remove';
				which_one = option_id;

				current_selected_fringe_option = current_selected_fringe_option[1];
				current_selected_fringe_option_count = current_selected_fringe_option_count[1];
				current_selected_fringe_option_type = current_selected_fringe_option_type[1];
			}
			else if ( is_there_multiple_options_count[1] == option_id )
			{
				which_type = 'remove';
				which_one = option_id;

				current_selected_fringe_option = current_selected_fringe_option[0];
				current_selected_fringe_option_count = current_selected_fringe_option_count[0];
				current_selected_fringe_option_type = current_selected_fringe_option_type[0];
			}
			else if ( is_there_multiple_options_type[1] == option_type )
			{
				which_type = 'remove';
				which_one = option_id;

				current_selected_fringe_option = current_selected_fringe_option[0];
				current_selected_fringe_option_count = current_selected_fringe_option_count[0];
				current_selected_fringe_option_type = current_selected_fringe_option_type[0];
			}
		}
		else
		{
			if ( current_selected_fringe_option_count == option_id )
			{
				which_type = 'remove';
				which_one = option_id;

				current_selected_fringe_option = '';
				current_selected_fringe_option_count = '';
				current_selected_fringe_option_type = '';
			}
			else if ( current_selected_fringe_option_type == option_type )
			{
				which_type = 'remove';
				which_one = current_selected_fringe_option_count;
				which_one2 = option_id;

				current_selected_fringe_option = document.getElementById('fringes_option_' + option_id + '_id').value;
				current_selected_fringe_option_count = option_id;
				current_selected_fringe_option_type = option_type;
			}
			else if ( current_selected_fringe_option_type != '' && current_selected_fringe_option_type != option_type )
			{
				which_type = 'add';
				which_one = option_id;

				current_selected_fringe_option = current_selected_fringe_option + '-' + document.getElementById('fringes_option_' + option_id + '_id').value;
				current_selected_fringe_option_count = current_selected_fringe_option_count + '-' + option_id;
				current_selected_fringe_option_type = current_selected_fringe_option_type + '-' + option_type;
			}
			else
			{
				which_type = 'remove';
				which_one = current_selected_fringe_option_count;
				which_one2 = option_id;

				current_selected_fringe_option = document.getElementById('fringes_option_' + option_id + '_id').value;
				current_selected_fringe_option_count = option_id;
				current_selected_fringe_option_type = option_type;
			}
		}
	}

	/*selected_fringe_option = new_selected_fringe_option + '' + new_option_id;
	selected_fringe_option_count = new_selected_fringe_option_count + '' + new_option_count;
	selected_fringe_option_type = new_selected_fringe_option_type + '' + new_option_type;*/

	document.getElementById('fringes_option_' + which_one).style.backgroundColor = ( which_type == 'remove' ? '#E2E2E2' : '#ed712d' );
	document.getElementById('fringes_option_' + which_one).style.color = ( which_type == 'remove' ? '#b36328' : '#FFFFFF' );
	document.getElementById('fringes_option_' + which_one + '_price').style.backgroundColor = ( which_type == 'remove' ? '#E2E2E2' : '#ed712d' );
	document.getElementById('fringes_option_' + which_one + '_price').style.color = ( which_type == 'remove' ? '#b36328' : '#FFFFFF' );

	if ( which_one2 > 0 )
	{
		document.getElementById('fringes_option_' + which_one2).style.backgroundColor = '#ed712d';
		document.getElementById('fringes_option_' + which_one2).style.color = '#FFFFFF';
		document.getElementById('fringes_option_' + which_one2 + '_price').style.backgroundColor = '#ed712d';
		document.getElementById('fringes_option_' + which_one2 + '_price').style.color = '#FFFFFF';
	}

	modify_field = 'fringe';
}

function nextStepHardware(type, add_to_cart, next_review)
{
	clearTimeout(hideProgress); // clear any existing timeouts

	/* set text to a loading box */
	$('progress_text').innerHTML = 'Loading...';
	Element.show('progress_box');

	selected_fringe = current_selected_fringe;
	selected_fringe_count = current_selected_fringe_count;
	selected_fringe_option = current_selected_fringe_option;
	selected_fringe_option_count = current_selected_fringe_option_count;
	selected_fringe_option_type = current_selected_fringe_option_type;

	//if ( selected_fringe != '' && selected_fringe_option != '' )
	//{
	var check_selection = ( selected_fringe == '' ? '' : '1' ) + ( selected_fringe_option == '' ? '' : '1' );
	if ( check_selection == '' || check_selection == '11' )
	{
		if ( removed_selection == '' && add_to_cart != '' )
		{
			full_selected_fringe = ( full_selected_fringe == '' ? '' : full_selected_fringe + ',' ) + selected_fringe;
			full_selected_fringe_count = ( full_selected_fringe_count == '' ? '' : full_selected_fringe_count + ',' ) + selected_fringe_count;

			full_selected_fringe_option = ( full_selected_fringe_option == '' ? '' : full_selected_fringe_option + ',' ) + selected_fringe_option;
			full_selected_fringe_option_count = ( full_selected_fringe_option_count == '' ? '' : full_selected_fringe_option_count + ',' ) + selected_fringe_option_count;
			full_selected_fringe_option_type = ( full_selected_fringe_option_type == '' ? '' : full_selected_fringe_option_type + ',' ) + selected_fringe_option_type;
		}
		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=' + ( removed_selection != '' ? 'review&remove=fringe' : 'hardware' ) + ( removed_selection == '' && $('step_hardware').innerHTML != '' ? '&type=save' : '' );

		if ( add_to_cart != '' && selected_fringe != '' )
		{
			how_many_items++;
		}
		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'fringe=' + full_selected_fringe + '&fringe_option=' + full_selected_fringe_option + '&special_fringe=' + selected_special_fringe + '&how_many_items=' + how_many_items,
			onSuccess: function(xhrResponse) {
				if ( removed_selection == '' )
				{
					if ( add_to_cart != '' && selected_fringe != '' )
					{
						how_many_items_fringe_added++;
						$('progress_text').innerHTML = how_many_items_fringe + ' item' + ( how_many_items_fringe == 1 ? '' : 's' ) + ' added to cart';
						hideProgress = setTimeout(hideProgressBox, 24000);

						if ( document.getElementById('how_many_items_fabric') )
						{
							$('how_many_items_fabric').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
						}
						if ( document.getElementById('how_many_items_tieback') )
						{
							$('how_many_items_tieback').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
						}
						if ( document.getElementById('how_many_items_fringe') )
						{
							$('how_many_items_fringe').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
						}
						if ( document.getElementById('how_many_items_hardware') )
						{
							$('how_many_items_hardware').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
						}
						if ( document.getElementById('how_many_items_special') )
						{
							$('how_many_items_special').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
						}

						if ( next_review == '' )
						{
							showMultipleItem('fringe');
						}
					}

					if ( add_to_cart == '' || next_review == 'fringe' || selected_fringe == '' )
					{
						if ( selected_fringe != '' )
						{
							multipleItem('fringe', 'fringe');
						}

						if ( $('step_hardware').innerHTML == '' )
						{
							$('step_hardware').innerHTML = xhrResponse.responseText;
						}

						if ( type != 'save' )
						{
							Element.show('step_hardware');
							if ( skip_steps == 1 )
							{
								Element.hide('step_' + last_step);
								skip_steps = 0;
								document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
							}
							else
							{
								Element.hide('step_' + last_step);
								document.getElementById('step_4_img').src = 'images/steps_04.jpg';
							}
							Element.hide('progress_box');
							current_step = 5;
							max_step = ( max_step < 5 ? 5 : max_step );
							last_step = 'hardware';
							parent.location.hash = 'step=hardware';
							modify_field = '';

							document.getElementById('step_5_img').src = 'images/steps2_05.jpg';
						}
						else
						{
							Element.hide('progress_box');
						}

						if ( how_many_items_fringe > 0 )
						{
							$('progress_text').innerHTML = how_many_items_fringe + ' item' + ( how_many_items_fringe == 1 ? '' : 's' ) + ' added to cart';
							Element.show('progress_box');
							hideProgress = setTimeout(hideProgressBox, 24000);
						}
						continue_goto = 1;
					}
				}
				else
				{
					$('step_review').innerHTML = xhrResponse.responseText;
					Element.hide('progress_box');
					if ( skip_steps == 1 )
					{
						Element.hide('step_' + last_step);
						skip_steps = 0;
						document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
					}
					else
					{
						Element.hide('step_fringe');
						document.getElementById('step_4_img').src = 'images/steps_04.jpg';
					}
					Element.show('step_review');
					current_step = 6;
					last_step = 'review';
					parent.location.hash = 'step=review';
					removed_selection = '';

					document.getElementById('step_4_img').src = 'images/steps_04.jpg';
					document.getElementById('step_6_img').src = 'images/steps2_06.jpg';
				}
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
	else
	{
		if ( selected_fringe == '' )
		{
			$('progress_text').innerHTML = 'Fringe required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( selected_fringe_option == '' )
		{
			$('progress_text').innerHTML = 'Fringe option required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
	}
}

function gotoHardware()
{
	if ( modify_field != '' )
	{
		if ( modify_field == 'begin' )
		{
			var check_selection = ( selected_van_model == '' ? '' : '1' ) + ( selected_van_year == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepFabric('save', '', '');
		}
		else if ( modify_field == 'fabric' )
		{
			var check_selection = ( selected_fabric == '' ? '' : '1' ) + ( selected_fabric_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepTieback('save');
		}
		else if ( modify_field == 'tieback' )
		{
			continue_goto = 1;
			nextStepFringe('save', '', '');
		}
		else if ( modify_field == 'fringe' )
		{
			var check_selection = ( selected_fringe == '' ? '' : '1' ) + ( selected_fringe_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepHardware('save', '', '');
		}
		else if ( modify_field == 'hardware' )
		{
			var check_selection = ( selected_hardware == '' ? '' : '1' ) + ( selected_hardware_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepReview('save', '', '');
		}
		modify_field = '';
	}

	if ( continue_goto == 1 && ((last_step != 'hardware' || show_forgot_password == 1) || register_customer == 1) && $('step_hardware').innerHTML != '' )
	{
		if ( last_step == 'checkout' )
		{
			Element.hide('checkout_step');
			last_step = 'review';
		}
		if ( max_step >= 5 )
		{
			if ( $('step_hardware').innerHTML != '' )
			{
				if ( show_forgot_password == 1 )
				{
					Effect.SlideDown('step_hardware', { duration: 1.0 });
				}
				else
				{
					Element.show('step_hardware');
				}

				if ( register_customer == 1 )
				{
					Element.hide('register_customer');
					register_customer = 0;
					clearRegisterCustomer();
				}
				else
				{
					if ( show_forgot_password == 1 )
					{
						Effect.SlideUp('forgot_password', { duration: 1.0 });
						show_forgot_password = 0;
					}
					else
					{
						Element.hide('step_' + last_step);
					}

					if ( $('step_specials').innerHTML != '' )
					{
						Element.hide('step_specials');
						$('step_specials').innerHTML = '';
					}
				}

				document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
				document.getElementById('step_5_img').src = 'images/steps2_05.jpg';
				last_step = 'hardware';
				current_step = 5;
				parent.location.hash = 'step=hardware';
			}
		}
	}
	else if ( add_specials == 1 )
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = 'Loading...';
		Element.show('progress_box');
		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=add_specials';

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'special_fabric=' + selected_special_fabric + '&special_tieback=' + selected_special_tieback + '&special_fringe=' + selected_special_fringe + '&special_hardware=' + selected_special_hardware + '&how_many_items=' + how_many_items,
			onSuccess: function(xhrResponse) {
				Element.hide('step_specials');
				Element.show('shopping');
				Element.show('progress_bar');
				Element.show('step_hardware');
				Element.hide('progress_box');

				document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
				document.getElementById('step_5_img').src = 'images/steps2_05.jpg';
				last_step = 'hardware';
				current_step = 5;
				parent.location.hash = 'step=hardware';

				add_specials = 0;
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
	else if ( $('step_hardware').innerHTML == '' )
	{
		skip_steps = 1;
		nextStepHardware('new', '', 'hardware');
		Element.show('start_over');
	}
}

function selectHardware(hardware_id)
{
	var which_type = '';
	var which_one = 0;
	var which_one2 = 0;

	if ( current_selected_hardware == '' )
	{
		how_many_items_hardware++;
		which_type = 'add';
		which_one = hardware_id;

		current_selected_hardware = document.getElementById('hardware_' + hardware_id + '_id').value;
		current_selected_hardware_count = hardware_id;
	}
	else
	{
		if ( current_selected_hardware_count == hardware_id )
		{
			which_type = 'remove';
			which_one = hardware_id;

			current_selected_hardware = '';
			current_selected_hardware_count = '';
		}
		else
		{
			which_type = 'remove';
			which_one = current_selected_hardware_count;
			which_one2 = hardware_id;

			current_selected_hardware = document.getElementById('hardware_' + hardware_id + '_id').value;
			current_selected_hardware_count = hardware_id;
		}
	}

	document.getElementById('hardware_' + which_one).style.borderColor = ( which_type == 'remove' ? '#FFFFFF' : '#b36328' );

	if ( which_one2 > 0 )
	{
		document.getElementById('hardware_' + which_one2).style.borderColor = '#b36328';
	}

	modify_field = 'hardware';
}

function selectHardwareOption(option_id, option_type)
{
	var which_type = '';
	var which_one = 0;
	var which_one2 = 0;

	if ( current_selected_hardware_option == '' )
	{
		which_type = 'add';
		which_one = option_id;

		current_selected_hardware_option = document.getElementById('hardwares_option_' + option_id + '_id').value;
		current_selected_hardware_option_count = option_id;
		current_selected_hardware_option_type = option_type;
		current_selected_hardware_option_amount = ( document.getElementById('hardwares_amount_' + option_id) ? document.getElementById('hardwares_amount_' + option_id) : 0 );
	}
	else
	{
		if ( current_selected_hardware_option_count == option_id )
		{
			which_type = 'remove';
			which_one = option_id;

			current_selected_hardware_option = '';
			current_selected_hardware_option_count = '';
			current_selected_hardware_option_type = '';
			current_selected_hardware_option_amount = '';
		}
		else if ( current_selected_hardware_option_type == option_type )
		{
			which_type = 'remove';
			which_one = current_selected_hardware_option_count;
			which_one2 = option_id;

			current_selected_hardware_option = document.getElementById('hardwares_option_' + option_id + '_id').value;
			current_selected_hardware_option_count = option_id;
			current_selected_hardware_option_type = option_type;
			current_selected_hardware_option_amount = ( document.getElementById('hardwares_amount_' + option_id) ? document.getElementById('hardwares_amount_' + option_id) : 0 );
		}
		else if ( current_selected_hardware_option_type != '' && current_selected_hardware_option_type != option_type )
		{
			which_type = 'add';
			which_one = option_id;

			current_selected_hardware_option = current_selected_hardware_option + '-' + document.getElementById('hardwares_option_' + option_id + '_id').value;
			current_selected_hardware_option_count = current_selected_hardware_option_count + '-' + option_id;
			current_selected_hardware_option_type = current_selected_hardware_option_type + '-' + option_type;
			current_selected_hardware_option_amount = ( document.getElementById('hardwares_amount_' + option_id) ? document.getElementById('hardwares_amount_' + option_id) : 0 );
		}
		else
		{
			which_type = 'remove';
			which_one = current_selected_hardware_option_count;
			which_one2 = option_id;

			current_selected_hardware_option = document.getElementById('hardwares_option_' + option_id + '_id').value;
			current_selected_hardware_option_count = option_id;
			current_selected_hardware_option_type = option_type;
			current_selected_hardware_option_amount = ( document.getElementById('hardwares_amount_' + option_id) ? document.getElementById('hardwares_amount_' + option_id) : 0 );
		}
	}

	/*selected_hardware_option = new_selected_hardware_option + '' + new_option_id;
	selected_hardware_option_count = new_selected_hardware_option_count + '' + new_option_count;
	selected_hardware_option_type = new_selected_hardware_option_type + '' + new_option_type;*/

	document.getElementById('hardwares_option_' + which_one).style.backgroundColor = ( which_type == 'remove' ? '#E2E2E2' : '#ed712d' );
	document.getElementById('hardwares_option_' + which_one).style.color = ( which_type == 'remove' ? '#b36328' : '#FFFFFF' );
	document.getElementById('hardwares_option_' + which_one + '_price').style.backgroundColor = ( which_type == 'remove' ? '#E2E2E2' : '#ed712d' );
	document.getElementById('hardwares_option_' + which_one + '_price').style.color = ( which_type == 'remove' ? '#b36328' : '#FFFFFF' );

	if ( which_one2 > 0 )
	{
		document.getElementById('hardwares_option_' + which_one2).style.backgroundColor = '#ed712d';
		document.getElementById('hardwares_option_' + which_one2).style.color = '#FFFFFF';
		document.getElementById('hardwares_option_' + which_one2 + '_price').style.backgroundColor = '#ed712d';
		document.getElementById('hardwares_option_' + which_one2 + '_price').style.color = '#FFFFFF';
	}

	modify_field = 'hardware';
}

function nextStepReview(type, add_to_cart, next_review)
{
	clearTimeout(hideProgress); // clear any existing timeouts

	/* set text to a loading box */
	$('progress_text').innerHTML = 'Loading...';
	Element.show('progress_box');

	selected_hardware = current_selected_hardware;
	selected_hardware_count = current_selected_hardware_count;
	selected_hardware_option = current_selected_hardware_option;
	selected_hardware_option_count = current_selected_hardware_option_count;
	selected_hardware_option_type = current_selected_hardware_option_type;
	selected_hardware_option_amount = current_selected_hardware_option_amount;
	
	//if ( selected_hardware != '' && selected_hardware_option != '' )
	//{
	var check_selection = ( selected_hardware == '' ? '' : '1' ) + ( selected_hardware_option == '' ? '' : '1' );
	if ( check_selection == '' || check_selection == '11' )
	{
		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=review' + ( removed_selection != '' ? '&mode=remove' : '' ); // always needs to reload

		if ( removed_selection == '' && add_to_cart != '' )
		{
			full_selected_hardware = ( full_selected_hardware == '' ? '' : full_selected_hardware + ',' ) + selected_hardware;
			full_selected_hardware_count = ( full_selected_hardware_count == '' ? '' : full_selected_hardware_count + ',' ) + selected_hardware_count;

			full_selected_hardware_option = ( full_selected_hardware_option == '' ? '' : full_selected_hardware_option + ',' ) + selected_hardware_option;
			full_selected_hardware_option_count = ( full_selected_hardware_option_count == '' ? '' : full_selected_hardware_option_count + ',' ) + selected_hardware_option_count;
			full_selected_hardware_option_type = ( full_selected_hardware_option_type == '' ? '' : full_selected_hardware_option_type + ',' ) + selected_hardware_option_type;
			full_selected_hardware_option_amount = ( full_selected_hardware_option_amount == '' ? '' : full_selected_hardware_option_amount + ',' ) + selected_hardware_option_amount;
		}
		
		if ( add_to_cart != '' && selected_hardware != '' )
		{
			how_many_items++;
		}
		
		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'hardware=' + full_selected_hardware + '&hardware_option=' + full_selected_hardware_option + '&hardware_option_amount=' + full_selected_hardware_option_amount + '&special_hardware=' + selected_special_hardware + '&how_many_items=' + how_many_items,
			onSuccess: function(xhrResponse) {
				if ( xhrResponse.responseText == 'no items' || how_many_items == 0 )
				{
					$('progress_text').innerHTML = 'Cart is empty.';
					hideProgress = setTimeout(hideProgressBox, 24000);
				}
				else
				{
					if ( add_to_cart != '' )
					{
						how_many_items_hardware_added++;
						$('progress_text').innerHTML = how_many_items_hardware + ' item' + ( how_many_items_hardware == 1 ? '' : 's' ) + ' added to cart';
						hideProgress = setTimeout(hideProgressBox, 24000);

						if ( document.getElementById('how_many_items_fabric') )
						{
							$('how_many_items_fabric').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
						}
						if ( document.getElementById('how_many_items_tieback') )
						{
							$('how_many_items_tieback').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
						}
						if ( document.getElementById('how_many_items_fringe') )
						{
							$('how_many_items_fringe').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
						}
						if ( document.getElementById('how_many_items_hardware') )
						{
							$('how_many_items_hardware').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
						}
						if ( document.getElementById('how_many_items_special') )
						{
							$('how_many_items_special').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
						}

						if ( next_review == '' )
						{
							showMultipleItem('hardware');
						}
					}
					if ( add_to_cart == '' || next_review == 'hardware' || selected_hardware == '' )
					{
						if ( selected_hardware != '' )
						{
							multipleItem('hardware', 'hardware');
						}
						document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
						$('step_review').innerHTML = xhrResponse.responseText;
						Element.show('step_review');

						if ( register_customer == 1 )
						{
							Element.hide('register_customer');
							register_customer = 0;
							clearRegisterCustomer();
						}
						else
						{
							Element.hide('step_' + last_step);
						}

						Element.hide('progress_box');
						current_step = 6;
						max_step = ( max_step < 6 ? 6 : max_step );
						last_step = 'review';
						parent.location.hash = 'step=review';
						removed_selection = '';
						modify_field = '';
						continue_goto = 1;

						document.getElementById('step_5_img').src = 'images/steps_05.jpg';
						document.getElementById('step_6_img').src = 'images/steps2_06.jpg';

						if ( how_many_items_hardware > 0 )
						{
							$('progress_text').innerHTML = how_many_items_hardware + ' item' + ( how_many_items_hardware == 1 ? '' : 's' ) + ' added to cart';
							Element.show('progress_box');
							hideProgress = setTimeout(hideProgressBox, 24000);
						}
					}
				}
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
	else
	{
		if ( selected_hardware == '' )
		{
			$('progress_text').innerHTML = 'Hardware required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( selected_hardware_option == '' )
		{
			$('progress_text').innerHTML = 'Hardware option required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
	}
}

function gotoReview()
{
	if ( modify_field != '' )
	{
		if ( modify_field == 'begin' )
		{
			var check_selection = ( selected_van_model == '' ? '' : '1' ) + ( selected_van_year == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepFabric('save', '', '');
		}
		else if ( modify_field == 'fabric' )
		{
			var check_selection = ( selected_fabric == '' ? '' : '1' ) + ( selected_fabric_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepTieback('save', '', '');
		}
		else if ( modify_field == 'tieback' )
		{
			continue_goto = 1;
			nextStepFringe('save', '', '');
		}
		else if ( modify_field == 'fringe' )
		{
			var check_selection = ( selected_fringe == '' ? '' : '1' ) + ( selected_fringe_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepHardware('save', '', '');
		}
		else if ( modify_field == 'hardware' )
		{
			var check_selection = ( selected_hardware == '' ? '' : '1' ) + ( selected_hardware_option == '' ? '' : '1' );
			continue_goto = ( check_selection == '' || check_selection == '11' ? 1 : 0 );
			nextStepReview('save', '', '');
		}
		modify_field = '';
	}

	//document.write(modify_field + '<br>' + add_specials + '<br>' + last_step + '<br>' + add_specials);

	if ( add_specials == 0 && ((last_step != 'review' || show_forgot_password == 1) || register_customer == 1 ) && $('step_review').innerHTML != '' )
	{
		if ( last_step == 'checkout' )
		{
			Element.hide('checkout_step');
		}
		//if ( max_step >= 6 )
		//{
		removed_selection = 'review';
		nextStepReview('new', '');
		document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
		document.getElementById('step_6_img').src = 'images/steps2_06.jpg';
		//}
	}
	else if ( add_specials == 1 )
	{
		//document.write(selected_special_fabric + '<br>' + selected_special_tieback + '<br>' + selected_special_fringe + '<br>' + selected_special_hardware);
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = 'Loading...';
		Element.show('progress_box');
		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=review&add_specials=1';

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'special_fabric=' + selected_special_fabric + '&special_tieback=' + selected_special_tieback + '&special_fringe=' + selected_special_fringe + '&special_hardware=' + selected_special_hardware + '&how_many_items=' + how_many_items,
			onSuccess: function(xhrResponse) {
				if ( xhrResponse.responseText == 0 || how_many_items == 0 )
				{
					$('progress_text').innerHTML = 'Cart is empty.';
					hideProgress = setTimeout(hideProgressBox, 24000);
				}
				else
				{
					if ( selected_special_fabric != '' || selected_special_tieback != '' || selected_special_fringe != '' || selected_special_hardware != '' )
					{
						Element.hide('step_specials');
					}
					else
					{
						document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
						Element.hide('step_' + last_step);
					}
					Element.show('shopping');
					Element.show('progress_bar');
					$('step_review').innerHTML = xhrResponse.responseText;
					Element.show('step_review');
					Element.hide('step_begin');
					Element.hide('progress_box');
					parent.location.hash = 'step=review';
					current_step = 6;
					last_step = 'review';

					document.getElementById('step_1_img').src = 'images/steps_01.jpg';
					document.getElementById('step_6_img').src = 'images/steps2_06.jpg';

					add_specials = 0;
				}
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
	else if ( $('step_review').innerHTML == '' )
	{
		skip_steps = 1;
		nextStepReview('new', '');
	}
	else
	{
		nextStepReview('new', '');
	}
}

function removeFabric(total_fabric)
{
	if ( full_selected_fabric != '' || full_selected_fabric_option != '' )
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = 'Loading...';
		Element.show('progress_box');

		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=begin&mode=remove'; // always needs to reload

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'remove=1',
			onSuccess: function(xhrResponse) {
				full_selected_fabric = '';
				full_selected_fabric_count = '';
				full_selected_fabric_type = '';
				full_selected_fabric_option = '';
				full_selected_fabric_option_count = '';
				full_selected_fabric_option_type = '';

				how_many_items_fabric = 0;
				how_many_items -= document.getElementById('total_fabric').value;
				if ( document.getElementById('how_many_items_fabric') )
				{
					$('how_many_items_fabric').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_tieback') )
				{
					$('how_many_items_tieback').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_fringe') )
				{
					$('how_many_items_fringe').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_hardware') )
				{
					$('how_many_items_hardware').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_special') )
				{
					$('how_many_items_special').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}

				/*$('step_fabric').innerHTML = xhrResponse.responseText;
				Element.show('step_fabric');
				Element.hide('step_' + last_step);
				$('progress_text').innerHTML = 'Fabric required.';
				current_step = 2;
				last_step = 'fabric';
				parent.location.hash = 'step=fabric';*/

				selected_fabric = '';
				selected_fabric_option = '';
				selected_fabric_count = '';
				Element.hide('progress_box');
				for ( var i=1; i<=total_fabric; i++ )
				{
					Element.hide('fabrics_image_' + i);
				}
				Element.hide('fabrics_price');
				$('total_amount').innerHTML = '$' + xhrResponse.responseText;
				/*removed_selection = 'fabric';
				hideProgress = setTimeout(hideProgressBox, 24000);

				document.getElementById('step_6_img').src = 'images/steps_06.jpg';
				document.getElementById('step_2_img').src = 'images/steps2_02.jpg';*/
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
}

function removeTieback(total_tieback)
{
	if ( full_selected_tieback != '' || full_selected_tieback_option != '' )
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = 'Loading...';
		Element.show('progress_box');

		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=fringe&mode=removetieback'; // always needs to reload

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'remove=1',
			onSuccess: function(xhrResponse) {
				full_selected_tieback = '';
				full_selected_tieback_count = '';
				full_selected_tieback_type = '';
				full_selected_tieback_option = '';
				full_selected_tieback_option_count = '';
				full_selected_tieback_option_type = '';
				how_many_items_tieback = 0;
				how_many_items -= document.getElementById('total_tieback').value;
				if ( document.getElementById('how_many_items_fabric') )
				{
					$('how_many_items_fabric').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_tieback') )
				{
					$('how_many_items_tieback').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_fringe') )
				{
					$('how_many_items_fringe').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_hardware') )
				{
					$('how_many_items_hardware').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_special') )
				{
					$('how_many_items_special').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				/*$('step_tieback').innerHTML = xhrResponse.responseText;
				Element.show('step_tieback');
				Element.hide('step_' + last_step);

				current_step = 3;
				last_step = 'tieback';
				parent.location.hash = 'step=tieback';*/
				Element.hide('progress_box');
				selected_tieback = '';
				selected_tieback_option = '';
				for ( var i=1; i<=total_tieback; i++ )
				{
					Element.hide('tiebacks_image_' + i);
				}
				Element.hide('tiebacks_price');
				$('total_amount').innerHTML = '$' + xhrResponse.responseText;
				//removed_selection = 'tieback';

				//document.getElementById('step_6_img').src = 'images/steps_06.jpg';
				//document.getElementById('step_3_img').src = 'images/steps2_03.jpg';
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
}

function removeFringe(total_fringe)
{
	if ( full_selected_fringe != '' || full_selected_fringe_option != '' )
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = 'Loading...';
		Element.show('progress_box');

		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=hardware&mode=removefringe'; // always needs to reload

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'remove=1',
			onSuccess: function(xhrResponse) {
				full_selected_fringe = '';
				full_selected_fringe_count = '';
				full_selected_fringe_option = '';
				full_selected_fringe_option_count = '';
				full_selected_fringe_option_type = '';

				how_many_items_fringe = 0;
				how_many_items -= document.getElementById('total_fringe').value;
				if ( document.getElementById('how_many_items_fabric') )
				{
					$('how_many_items_fabric').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_tieback') )
				{
					$('how_many_items_tieback').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_fringe') )
				{
					$('how_many_items_fringe').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_hardware') )
				{
					$('how_many_items_hardware').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_special') )
				{
					$('how_many_items_special').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				/*$('step_fringe').innerHTML = xhrResponse.responseText;
				Element.show('step_fringe');
				Element.hide('step_' + last_step);

				current_step = 4;
				last_step = 'fringe';
				parent.location.hash = 'step=fringe';*/
				Element.hide('progress_box');
				selected_fringe = '';
				selected_fringe_option = '';
				for ( var i=1; i<=total_fringe; i++ )
				{
					Element.hide('fringes_image_' + i);
				}
				Element.hide('fringes_price');
				$('total_amount').innerHTML = '$' + xhrResponse.responseText;
				//removed_selection = 'fringe';

				//document.getElementById('step_6_img').src = 'images/steps_06.jpg';
				//document.getElementById('step_4_img').src = 'images/steps2_04.jpg';
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
}

function removeHardware(total_hardware)
{
	if ( full_selected_hardware != '' || full_selected_hardware_option != '' )
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = 'Loading...';
		Element.show('progress_box');

		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=hardware&mode=remove&and=1'; // always needs to reload

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'remove=1',
			onSuccess: function(xhrResponse) {
				full_selected_hardware = '';
				full_selected_hardware_count = '';
				full_selected_hardware_option = '';
				full_selected_hardware_option_count = '';
				full_selected_hardware_option_type = '';
				full_selected_hardware_option_amount = '';
				
				how_many_items_hardware = 0;
				how_many_items -= document.getElementById('total_hardware').value;
				if ( document.getElementById('how_many_items_fabric') )
				{
					$('how_many_items_fabric').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_tieback') )
				{
					$('how_many_items_tieback').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_fringe') )
				{
					$('how_many_items_fringe').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_hardware') )
				{
					$('how_many_items_hardware').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_special') )
				{
					$('how_many_items_special').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				/*$('step_hardware').innerHTML = xhrResponse.responseText;
				Element.show('step_hardware');
				Element.hide('step_' + last_step);

				current_step = 5;
				last_step = 'hardware';
				parent.location.hash = 'step=hardware';*/
				Element.hide('progress_box');
				selected_hardware = '';
				selected_hardware_option = '';
				selected_hardware_option_amount = '';
				for ( var i=1; i<=total_hardware; i++ )
				{
					Element.hide('hardware_image_' + i);
				}
				Element.hide('hardware_price');
				$('total_amount').innerHTML = '$' + xhrResponse.responseText;
				//removed_selection = 'hardware';

				//document.getElementById('step_6_img').src = 'images/steps_06.jpg';
				//document.getElementById('step_5_img').src = 'images/steps2_05.jpg';
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
}

function nextStepCheckout()
{
	if ( selected_special_fabric != '' || selected_special_tieback != '' || selected_special_fringe != '' || selected_special_hardware != '' )
	{
		if ( selected_tieback == '' && selected_fringe == '' && selected_hardware == '' && selected_fabric == '' )
		{
			var pass_check = 0;
		}
		else
		{
			var pass_check = 1;
		}
	}
	else if ( selected_tieback == '' && selected_fringe == '' && selected_hardware == '' && selected_fabric == '' )
	{
		var pass_check = 0;
	}
	else
	{
		var pass_check = 1;
	}

	if ( pass_check == 0 )
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = '0 items in cart';
		Element.show('progress_box');

		/*Element.show('step_fabric');
		Element.hide('step_' + last_step);

		document.getElementById('step_2_img').src = 'images/steps2_02.jpg';
		document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
		last_step = 'fabric';
		current_step = 2;
		parent.location.hash = 'step=fabric';*/
		hideProgress = setTimeout(hideProgressBox, 24000);
	}
	else
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = 'Loading...';
		Element.show('progress_box');

		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=checkout';

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'checkout=1',
			onSuccess: function(xhrResponse) {
				Element.hide('progress_box');
				$('checkout_step').innerHTML = xhrResponse.responseText;
				if ( selected_fabric != '' && selected_fabric_option != '' )
				{
					Effect.SlideUp('review_step', { duration: 1.0 });
				}
				if ( selected_special_fabric != '' || selected_special_tieback != '' || selected_special_fringe != '' || selected_special_hardware != '' )
				{
					Effect.SlideUp('review_step_special', { duration: 1.0 });
				}
				Effect.SlideUp('review_step_continue', { duration: 1.0 });
				Effect.SlideDown('checkout_step', { duration: 1.0 });
				last_step = 'checkout'; // begin, fabric, tieback
				parent.location.hash = 'step=checkout';
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
}

function showReview(type)
{
	if ( selected_fabric != '' && selected_fabric_option != '' )
	{
		Effect.SlideDown('review_step', { duration: 1.0 });
	}
	if ( selected_special_fabric != '' || selected_special_tieback != '' || selected_special_fringe != '' || selected_special_hardware != '' )
	{
		Effect.SlideDown('review_step_special', { duration: 1.0 });
	}
	Effect.SlideDown('review_step_continue', { duration: 1.0 });
	Effect.SlideUp(type + '_step', { duration: 1.0 });
	if ( type == 'checkout' )
	{
		last_step = 'review'; // begin, fabric, tieback
		parent.location.hash = 'step=review';
	}
}

function showYear()
{
	var list = document.getElementById('vehicle_models').value;
	var explode_list = list.split(',');
	var selected_model = document.getElementById('van_model').options[document.getElementById('van_model').selectedIndex].value;

	var i = 0;
	while ( explode_list[i] )
	{
		Element.hide('year_' + explode_list[i]);
		i++;
	}
	Element.show('year_' + selected_model.replace(' ', '_'));
}

function startOver()
{
	clearTimeout(hideProgress); // clear any existing timeouts

	/* set text to a loading box */
	$('progress_text').innerHTML = 'Loading...';
	Element.show('progress_box');

	max_step = 1; // 1=begin, 2=fabric, 3=tieback, 4=fringe, 5=hardware, 6=review/checkout
	var modify_field = ''; // begin, fabric, tieback, fringe, hardware, review, checkout
	var continue_goto = 1;

	selected_van_model = '';
	selected_van_year = '';

	selected_fabric = '';
	selected_fabric_option = '';
	previous_show_fabric = '';
	previous_fabric_option = '';
	selected_fabric_count = '';
	selected_fabric_type = '';
	selected_fabric_option_count = '';
	selected_fabric_option_type = '';
	selected_special_fabric = '';
	selected_special_fabric_count = '';

	selected_tieback = '';
	selected_tieback_option = '';
	previous_show_tieback = '';
	previous_tieback_option = '';
	selected_tieback_count = '';
	selected_tieback_option_count = '';
	selected_special_tieback = '';
	selected_special_tieback_count = '';

	selected_fringe = '';
	selected_fringe_option = '';
	selected_fringe_count = '';
	selected_fringe_option_count = '';
	selected_special_fringe = '';
	selected_special_fringe_count = '';

	selected_hardware = '';
	selected_hardware_option = '';
	selected_hardware_option_amount = '';
	selected_hardware_count = '';
	selected_hardware_option_count = '';
	selected_special_hardware = '';
	selected_special_hardware_count = '';

	removed_selection = '';

	var steps = 'fabric,tieback,fringe,hardware,review';
	var steps_array = steps.split(',');
	var i = 0;
	while ( steps_array[i] )
	{
		if ( last_step != steps_array[i] )
		{
			if ( last_step != 'checkout' )
			{
				$('step_' + steps_array[i]).innerHTML = '';
			}
		}
		var j = (i + 2);

		i++;
	}

	if ( last_step == 'checkout' )
	{
		document.getElementById('username').value = '';
		document.getElementById('password').value = '';
	}
	else if ( last_step == 'login' )
	{
		document.getElementById('username').value = '';
		document.getElementById('password').value = '';
	}

	/* add the ajax request to the end of defined url variable */
	var url = 'shop_ajax.php?step=start_over';

	/* make the ajax request for the information */
	new Ajax.Request(url, {
		method: 'post',
		parameters: 'remove=1',
		onSuccess: function(xhrResponse) {
			$('step_begin').innerHTML = xhrResponse.responseText;
			Element.show('step_begin');
			if ( last_step == 'checkout' )
			{
				Element.hide('checkout_step');
				Element.hide('step_review');
			}
			else
			{
				Element.hide('step_' + last_step);
			}

			if ( register_customer == 1 )
			{
				Element.hide('register_customer');
				register_customer = 0;
			}

			$('step_' + last_step).innerHTML = '';
			last_step = 'begin'; // begin, fabric, tieback
			Element.hide('progress_box');
			parent.location.hash = '';
			Element.hide('start_over');

			document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
			current_step = 1; // 1=begin, 2=fabric, 3=tieback
			document.getElementById('step_1_img').src = 'images/steps2_01.jpg';
		},
		onFailure: function(xhrResponse) {
			$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
		}
	});
}

function nextStepLogin()
{
	if ( selected_special_fabric != '' || selected_special_tieback != '' || selected_special_fringe != '' || selected_special_hardware != '' )
	{
		if ( selected_tieback == '' && selected_fringe == '' && selected_hardware == '' && selected_fabric == '' )
		{
			var pass_check = 0;
		}
		else
		{
			var pass_check = 1;
		}
	}
	else if ( selected_tieback == '' && selected_fringe == '' && selected_hardware == '' && selected_fabric == '' )
	{
		var pass_check = 0;
	}
	else
	{
		var pass_check = 1;
	}

	if ( pass_check == 0 )
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = '0 items in cart';
		Element.show('progress_box');

		/*Element.show('step_fabric');
		Element.hide('step_' + last_step);

		document.getElementById('step_2_img').src = 'images/steps2_02.jpg';
		document.getElementById('step_' + current_step + '_img').src = 'images/steps_0' + current_step + '.jpg';
		last_step = 'fabric';
		current_step = 2;
		parent.location.hash = 'step=fabric';*/
		hideProgress = setTimeout(hideProgressBox, 24000);
	}
	else
	{
		if ( logged_in == 1 )
		{
			nextStepCheckout();
		}
		else
		{
			if ( selected_fabric != '' && selected_fabric_option != '' )
			{
				Effect.SlideUp('review_step', { duration: 1.0 });
			}
			if ( selected_special_fabric != '' || selected_special_tieback != '' || selected_special_fringe != '' || selected_special_hardware != '' )
			{
				Effect.SlideUp('review_step_special', { duration: 1.0 });
			}
			Effect.SlideUp('review_step_continue', { duration: 1.0 });
			Effect.SlideDown('login_step', { duration: 1.0 });
		}
	}
}

function loginCustomer()
{
	clearTimeout(hideProgress); // clear any existing timeouts

	/* set text to a loading box */
	$('progress_text').innerHTML = 'Loading...';
	Element.show('progress_box');

	var username = document.getElementById('login_username').value;
	var password = document.getElementById('login_password').value;

	/* add the ajax request to the end of defined url variable */
	var url = 'login_ajax.php';

	/* make the ajax request for the information */
	new Ajax.Request(url, {
		method: 'post',
		parameters: 'username=' + username + '&password=' + password,
		onSuccess: function(xhrResponse) {
			if ( xhrResponse.responseText == 0 )
			{
				$('progress_text').innerHTML = 'Invalid username or password.';
				hideProgress = setTimeout(hideProgressBox, 24000);
			}
			else
			{
				logged_in = 1;
				var login = xhrResponse.responseText;
				var login_position = login.indexOf('-eboltajaxmedia-');
				var login_plus = (login_position + 16);
				$('login_box').innerHTML = login.substring(0, login_position);
				$('checkout_step').innerHTML = login.substring(login_plus, login.length);

				Effect.SlideDown('checkout_step', { duration: 1.0 });
				Effect.SlideUp('login_step', { duration: 1.0 });
				last_step = 'checkout'; // begin, fabric, tieback
				Element.hide('progress_box');
				parent.location.hash = 'step=checkout';
			}
		},
		onFailure: function(xhrResponse) {
			$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
		}
	});
}

function billingShipping()
{
	if ( billing_shipping_check == 0 )
	{
		old_shipping_first_name = document.getElementById('checkout_shipping_first_name').value;
		old_shipping_last_name = document.getElementById('checkout_shipping_last_name').value;
		old_shipping_address = document.getElementById('checkout_shipping_address').value;
		old_shipping_city = document.getElementById('checkout_shipping_city').value;
		old_shipping_state = document.getElementById('checkout_shipping_state').value;
		old_shipping_zip = document.getElementById('checkout_shipping_zip').value;

		document.getElementById('checkout_shipping_first_name').value = document.getElementById('checkout_billing_first_name').value;
		document.getElementById('checkout_shipping_last_name').value = document.getElementById('checkout_billing_last_name').value;
		document.getElementById('checkout_shipping_address').value = document.getElementById('checkout_billing_address').value;
		document.getElementById('checkout_shipping_city').value = document.getElementById('checkout_billing_city').value;
		document.getElementById('checkout_shipping_state').value = document.getElementById('checkout_billing_state').value;
		document.getElementById('checkout_shipping_zip').value = document.getElementById('checkout_billing_zip').value;

		billing_shipping_check = 1;
	}
	else
	{
		document.getElementById('checkout_shipping_first_name').value = old_shipping_first_name;
		document.getElementById('checkout_shipping_last_name').value = old_shipping_last_name;
		document.getElementById('checkout_shipping_address').value = old_shipping_address;
		document.getElementById('checkout_shipping_city').value = old_shipping_city;
		document.getElementById('checkout_shipping_state').value = old_shipping_state;
		document.getElementById('checkout_shipping_zip').value = old_shipping_zip;

		old_shipping_first_name = '';
		old_shipping_last_name = '';
		old_shipping_address = '';
		old_shipping_city = '';
		old_shipping_state = '';
		old_shipping_zip = '';

		billing_shipping_check = 0;
	}
}

function changeTax()
{
	var selected_state = document.getElementById('checkout_billing_state').options[document.getElementById('checkout_billing_state').selectedIndex].value;

	/* add the ajax request to the end of defined url variable */
	var url = 'shop_ajax.php?step=tax';

	/* make the ajax request for the information */
	new Ajax.Request(url, {
		method: 'post',
		parameters: 'selected_state=' + selected_state,
		onSuccess: function(xhrResponse) {
			var tax = xhrResponse.responseText;
			var tax_position = tax.indexOf('-');
			var tax_plus = (tax_position + 1);
			$('tax_amount').innerHTML = '$' + tax.substring(0, tax_position);
			$('checkout_total').innerHTML = '$' + tax.substring(tax_plus, tax.length);
		},
		onFailure: function(xhrResponse) {
			$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
		}
	});
}

function submitOrder()
{
	clearTimeout(hideProgress); // clear any existing timeouts

	/* set text to a loading box */
	$('progress_text').innerHTML = 'Loading...';
	Element.show('progress_box');

	var billing_first_name = document.getElementById('checkout_billing_first_name').value;
	var billing_last_name = document.getElementById('checkout_billing_last_name').value;
	var billing_address = document.getElementById('checkout_billing_address').value;
	var billing_addres = billing_address.replace('#', '');
	var billing_city = document.getElementById('checkout_billing_city').value;
	var billing_state = document.getElementById('checkout_billing_state').value;
	var billing_zip = document.getElementById('checkout_billing_zip').value;
	var shipping_first_name = document.getElementById('checkout_shipping_first_name').value;
	var shipping_last_name = document.getElementById('checkout_shipping_last_name').value;
	var shipping_address = document.getElementById('checkout_shipping_address').value;
	var shipping_addres = shipping_address.replace('#', '');
	var shipping_city = document.getElementById('checkout_shipping_city').value;
	var shipping_state = document.getElementById('checkout_shipping_state').value;
	var shipping_zip = document.getElementById('checkout_shipping_zip').value;

	var cc_full_name = document.getElementById('checkout_cc_full_name').value;
	var cc_number = document.getElementById('checkout_cc_number').value;
	var cc_type = document.getElementById('checkout_cc_type').value;
	var cc_security = document.getElementById('checkout_cc_security').value;
	var cc_exp_date = document.getElementById('checkout_cc_exp_month').value + '/' + document.getElementById('checkout_cc_exp_year').value;

	/* add the ajax request to the end of defined url variable */
	var url = 'shop_ajax.php?step=order';

	var check_billing = ( billing_first_name != '' ? '' : 1 ) + ( billing_last_name != '' ? '' : 1 ) + ( billing_address != '' ? '' : 1 ) + ( billing_city != '' ? '' : 1 ) + ( billing_state != '' ? '' : 1 ) + ( billing_zip != '' ? '' : 1 );
	var check_shipping = ( shipping_first_name != '' ? '' : 1 ) + ( shipping_last_name != '' ? '' : 1 ) + ( shipping_address != '' ? '' : 1 ) + ( shipping_city != '' ? '' : 1 ) + ( shipping_state != '' ? '' : 1 ) + ( shipping_zip != '' ? '' : 1 );
	var check_cc = ( cc_full_name != '' ? '' : 1 ) + ( cc_number != '' ? '' : 1 ) + ( cc_type != '' ? '' : 1 ) + ( cc_security != '' ? '' : 1 ) + ( cc_exp_date != '00/0000' ? '' : 1 );

	if ( check_billing == '' && check_shipping == '' && check_cc == '' )
	{
		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'billing_first_name=' + billing_first_name + '&billing_last_name=' + billing_last_name + '&billing_address=' + billing_address + '&billing_city=' + billing_city + '&billing_state=' + billing_state + '&billing_zip=' + billing_zip + '&shipping_first_name=' + shipping_first_name + '&shipping_last_name=' + shipping_last_name + '&shipping_address=' + shipping_address + '&shipping_city=' + shipping_city + '&shipping_state=' + shipping_state + '&shipping_zip=' + shipping_zip + '&cc_full_name=' + cc_full_name + '&cc_number=' + cc_number + '&cc_type=' + cc_type + '&cc_security=' + cc_security + '&cc_exp_date=' + cc_exp_date,
			onSuccess: function(xhrResponse) {
				$('confirmation_step').innerHTML = xhrResponse.responseText;
				Effect.SlideDown('confirmation_step', { duration: 1.0 });
				Effect.SlideUp('step_review', { duration: 1.0 });
				Element.hide('progress_bar');
				Element.hide('progress_box');
				parent.location.hash = 'step=confirmation';
				last_step = 'confirmation';
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
	else
	{
		if ( billing_first_name == '' )
		{
			$('progress_text').innerHTML = 'Billing: First Name required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( billing_last_name == '' )
		{
			$('progress_text').innerHTML = 'Billing: Last Name required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( billing_address == '' )
		{
			$('progress_text').innerHTML = 'Billing: Address required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( billing_city == '' )
		{
			$('progress_text').innerHTML = 'Billing: City required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( billing_state == '' )
		{
			$('progress_text').innerHTML = 'Billing: State required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( billing_zip == '' )
		{
			$('progress_text').innerHTML = 'Billing: Zip required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( shipping_first_name == '' )
		{
			$('progress_text').innerHTML = 'Shipping: First Name required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( shipping_last_name == '' )
		{
			$('progress_text').innerHTML = 'Shipping: Last Name required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( shipping_address == '' )
		{
			$('progress_text').innerHTML = 'Shipping: Address required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( shipping_city == '' )
		{
			$('progress_text').innerHTML = 'Shipping: City required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( shipping_state == '' )
		{
			$('progress_text').innerHTML = 'Shipping: State required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( shipping_zip == '' )
		{
			$('progress_text').innerHTML = 'Shipping: Zip required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( cc_full_name == '' )
		{
			$('progress_text').innerHTML = 'Credit Card: Name required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( cc_number == '' )
		{
			$('progress_text').innerHTML = 'Credit Card: Number required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( cc_type == '' )
		{
			$('progress_text').innerHTML = 'Credit Card: Type required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( cc_security == '' )
		{
			$('progress_text').innerHTML = 'Credit Card: Security Code required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( cc_exp_date == '00/0000' )
		{
			$('progress_text').innerHTML = 'Credit Card: Expiration Date required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
	}
}

function checkEnter(inField, e)
{
	var key_pressed;

	if ( e && e.which )
	{
		key_pressed = e.which;
	}
	else if ( window.event )
	{
		e = window.event;
		key_pressed = e.keyCode;
	}

	if ( key_pressed == 13 )
	{
		customerLogin();
	}
}

function checkEnter2(inField, e)
{
	var key_pressed;

	if ( e && e.which )
	{
		key_pressed = e.which;
	}
	else if ( window.event )
	{
		e = window.event;
		key_pressed = e.keyCode;
	}

	if ( key_pressed == 13 )
	{
		loginCustomer();
	}
}

function customerLogin()
{
	clearTimeout(hideProgress); // clear any existing timeouts

	/* set text to a loading box */
	$('progress_text').innerHTML = 'Loading...';
	Element.show('progress_box');

	var username = document.getElementById('username').value;
	var password = document.getElementById('password').value;

	/* add the ajax request to the end of defined url variable */
	var url = 'login_ajax.php?type=mini';

	/* make the ajax request for the information */
	new Ajax.Request(url, {
		method: 'post',
		parameters: 'username=' + username + '&password=' + password,
		onSuccess: function(xhrResponse) {
			if ( xhrResponse.responseText == 0 )
			{
				$('progress_text').innerHTML = 'Invalid username or password.';
				hideProgress = setTimeout(hideProgressBox, 24000);
			}
			else
			{
				logged_in = 1;
				Element.hide('progress_box');
				$('login_box').innerHTML = xhrResponse.responseText;
			}
		},
		onFailure: function(xhrResponse) {
			$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
		}
	});
}

function showRegisterCustomer()
{
	if ( register_customer == 0 )
	{
		register_customer = 1;
		Effect.SlideDown('register_customer', { duration: 1.0 });

		if ( show_forgot_password == 1 )
		{
			Effect.SlideUp('forgot_password', { duration: 1.0 });
			show_forgot_password = 0;
		}
		else
		{
			Effect.SlideUp('step_' + last_step, { duration: 1.0 });
		}

		parent.location.hash = '';
		show_register_customer = 1;
	}
}

function registerCustomer()
{
	clearTimeout(hideProgress); // clear any existing timeouts

	/* set text to a loading box */
	$('progress_text').innerHTML = 'Loading...';
	Element.show('progress_box');

	var email = document.getElementById('email').value;
	var password = document.getElementById('customer_password').value;
	var password_again = document.getElementById('customer_password_again').value;
	var billing_first_name = document.getElementById('billing_first_name').value;
	var billing_last_name = document.getElementById('billing_last_name').value;
	var billing_address = document.getElementById('billing_address').value;
	var billing_city = document.getElementById('billing_city').value;
	var billing_state = document.getElementById('billing_state').value;
	var billing_zip = document.getElementById('billing_zip').value;
	var billing_shipping = ( document.getElementById('billing_shipping').checked == true ? 1 : 0 );

	/* add the ajax request to the end of defined url variable */
	var url = 'register_ajax.php' + ( current_step == 6 ? '?type=checkout' : '' );

	if ( email != '' && billing_first_name != '' && billing_last_name != '' && (password == password_again && password != '') )
	{
		Element.hide('submit_register');
		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'email=' + email + '&password=' + password + '&billing_first_name=' + billing_first_name + '&billing_last_name=' + billing_last_name + '&billing_address=' + billing_address + '&billing_city=' + billing_city + '&billing_state=' + billing_state + '&billing_zip=' + billing_zip + '&billing_shipping=' + billing_shipping,
			onSuccess: function(xhrResponse) {
				if ( xhrResponse.responseText == 0 )
				{
					$('progress_text').innerHTML = 'Email address already in use.';
					hideProgress = setTimeout(hideProgressBox, 24000);
				}
				else
				{
					register_customer = 0;
					logged_in = 1;
					Element.show('submit_register');
					clearRegisterCustomer();

					if ( current_step == 6 )
					{
						var login = xhrResponse.responseText;
						var login_position = login.indexOf('-eboltajaxmedia-');
						var login_plus = (login_position + 16);
						$('login_box').innerHTML = login.substring(0, login_position);
						$('checkout_step').innerHTML = login.substring(login_plus, login.length);

						Element.hide('login_step');
						Effect.SlideDown('step_review', { duration: 1.0 });
						Effect.SlideDown('checkout_step', { duration: 1.0 });
						Effect.SlideUp('register_customer', { duration: 1.0 });
						last_step = 'checkout'; // begin, fabric, tieback
						Element.hide('progress_box');
						parent.location.hash = 'step=checkout';
					}
					else
					{
						$('login_box').innerHTML = xhrResponse.responseText;
						Effect.SlideUp('register_customer', { duration: 1.0 });
						Effect.SlideDown('step_' + last_step, { duration: 1.0 });
					}
					Element.hide('progress_box');
				}
				Element.show('submit_register');
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
	else
	{
		if ( email == '' )
		{
			$('progress_text').innerHTML = 'Email is required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( password == '' )
		{
			$('progress_text').innerHTML = 'Password is required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( password != password_again )
		{
			$('progress_text').innerHTML = 'Passwords do not match.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( billing_first_name == '' )
		{
			$('progress_text').innerHTML = 'First Name is required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( billing_last_name == '' )
		{
			$('progress_text').innerHTML = 'Last Name is required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
	}
}

function clearRegisterCustomer()
{
	document.getElementById('email').value = '';
	document.getElementById('customer_password').value = '';
	document.getElementById('customer_password_again').value = '';
	document.getElementById('billing_first_name').value = '';
	document.getElementById('billing_last_name').value = '';
	document.getElementById('billing_address').value = '';
	document.getElementById('billing_city').value = '';
	document.getElementById('billing_state').value = '';
	document.getElementById('billing_zip').value = '';
	document.getElementById('billing_shipping').checked = false;
}

function logoutCustomer(type)
{
	clearTimeout(hideProgress); // clear any existing timeouts

	/* set text to a loading box */
	$('progress_text').innerHTML = 'Loading...';
	Element.show('progress_box');

	/* add the ajax request to the end of defined url variable */
	var url = 'login_ajax.php?mode=logout';

	/* make the ajax request for the information */
	new Ajax.Request(url, {
		method: 'post',
		parameters: 'logout=1',
		onSuccess: function(xhrResponse) {
			if ( type == 'shop' )
			{
				if ( current_step > 1 && last_step != 'confirmation' )
				{
					parent.location = 'shop.php';
				}
			}
			logged_in = 0;
			Element.hide('progress_box');
			$('login_box').innerHTML = xhrResponse.responseText;
		},
		onFailure: function(xhrResponse) {
			$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
		}
	});
}

function printOrder(order_id)
{
	window.open(main_url + 'orders.php?id=' + order_id,'confirmation_of_order','width=1000,height=800,resizable=yes,scrollbars=yes');
}

function customerContact()
{
	clearTimeout(hideProgress); // clear any existing timeouts

	/* set text to a loading box */
	$('progress_text').innerHTML = 'Loading...';
	Element.show('progress_box');

	var contact_first_name = escape(document.getElementById('contact_first_name').value);
	var contact_last_name = escape(document.getElementById('contact_last_name').value);
	var contact_phone = escape(document.getElementById('contact_phone').value);
	var contact_email = escape(document.getElementById('contact_email').value);
	var contact_question = escape(document.getElementById('contact_question').value);

	/* add the ajax request to the end of defined url variable */
	var url = 'contact_ajax.php';

	if ( contact_first_name != '' && contact_last_name != '' && ( contact_email != '' || contact_phone != '' ) && contact_question != '' )
	{
		Element.hide('contact');
		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'contact_first_name=' + contact_first_name + '&contact_last_name=' + contact_last_name + '&contact_phone=' + contact_phone + '&contact_email=' + contact_email + '&contact_question=' + contact_question,
			onSuccess: function(xhrResponse) {
				$('progress_text').innerHTML = 'Contact saved.';
				hideProgress = setTimeout(hideProgressBox, 24000);
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
	else
	{
		if ( contact_first_name == '' )
		{
			$('progress_text').innerHTML = 'First name is required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( contact_last_name == '' )
		{
			$('progress_text').innerHTML = 'Last name is required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( contact_phone == '' && contact_email == '' )
		{
			$('progress_text').innerHTML = 'Either a phone number or email address is required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else if ( contact_question == '' )
		{
			$('progress_text').innerHTML = 'Comment/Question is required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
	}
}

function forgotPasswordEmail(shop)
{
	clearTimeout(hideProgress); // clear any existing timeouts

	/* set text to a loading box */
	$('progress_text').innerHTML = 'Loading...';
	Element.show('progress_box');

	/* add the ajax request to the end of defined url variable */
	var url = 'password_ajax.php?type=password';

	var email = escape(document.getElementById('forgot_email').value);

	if ( email != '' )
	{
		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'email=' + email,
			onSuccess: function(xhrResponse) {
				if ( xhrResponse.responseText == 0 )
				{
					$('progress_text').innerHTML = 'Email address does not exist.';
					hideProgress = setTimeout(hideProgressBox, 24000);
				}
				else
				{
					if ( shop != '' )
					{
						Effect.SlideUp('forgot_password', { duration: 1.0 });
						Effect.SlideDown('step_' + last_step, { duration: 1.0 });
					}
					else
					{
						$('progress_text').innerHTML = 'Email sent.';
						hideProgress = setTimeout(hideProgressBox, 24000);
					}
				}
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
	else
	{
		$('progress_text').innerHTML = 'Email is required.';
		hideProgress = setTimeout(hideProgressBox, 24000);
	}
}

function showForgotPassword()
{
	Effect.SlideDown('forgot_password', { duration: 1.0 });
	if ( show_register_customer == 1 )
	{
		Effect.SlideUp('register_customer', { duration: 1.0 });
		show_register_customer = 0;
	}
	else
	{
		Effect.SlideUp('step_' + last_step, { duration: 1.0 });
	}

	parent.location.hash = '';
	show_forgot_password = 1;
}

function forgotPasswordReset()
{
	clearTimeout(hideProgress); // clear any existing timeouts

	/* set text to a loading box */
	$('progress_text').innerHTML = 'Loading...';
	Element.show('progress_box');

	/* add the ajax request to the end of defined url variable */
	var url = 'password_ajax.php?type=reset_password';

	var password = escape(document.getElementById('reset_password').value);
	var password_again = escape(document.getElementById('reset_password_again').value);
	var customer_key = document.getElementById('customer_key').value;

	if ( password != '' && password == password_again )
	{
		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'reset_password=' + password + '&customer_key=' + customer_key,
			onSuccess: function(xhrResponse) {
				parent.location = 'index.php';
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
	else
	{
		if ( password == '' )
		{
			$('progress_text').innerHTML = 'Password is required.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
		else
		{
			$('progress_text').innerHTML = 'Passwords did not match.';
			hideProgress = setTimeout(hideProgressBox, 24000);
		}
	}
}

function selectSpecialFabric(count_id, special_id)
{
	var add_vars = 1;
	var i = 0;
	var array_selected_special = selected_special_fabric.split(',');
	var array_selected_special_count = selected_special_fabric_count.split(',');
	if ( array_selected_special[0] != '' )
	{
		var new_special_id = '';
		var new_special_count = '';
		while ( array_selected_special[i] )
		{
			if ( array_selected_special_count[i] == count_id ) // remove it
			{
				var add_vars = 0;
			}
			else
			{
				new_special_id = ( new_special_id == '' ? '' : new_special_id + ',' ) + array_selected_special[i];
				new_special_count = ( new_special_count == '' ? '' : new_special_count + ',' ) + array_selected_special_count[i];
			}
			i++;
		}
		selected_special_fabric = new_special_id;
		selected_special_fabric_count = new_special_count;
	}

	var i = 1;
	while ( document.getElementById('special_fabric_image_' + i) )
	{
		document.getElementById('special_fabric_image_' + i).style.borderColor = '#FFFFFF';
		i++;
	}

	if ( add_vars > 0 )
	{
		how_many_items++;
		how_many_items_fabric++;

		selected_special_fabric = ( selected_special_fabric == '' ? '' : selected_special_fabric + ',' ) + special_id;
		selected_special_fabric_count = ( selected_special_fabric_count == '' ? '' : selected_special_fabric_count + ',' ) + count_id;
	}
	else
	{
		how_many_items--;
		how_many_items_fabric--;
	}

	var i = 0;
	var array_selected_special = selected_special_fabric_count.split(',');
	while ( array_selected_special[i] )
	{
		document.getElementById('special_fabric_image_' + array_selected_special[i]).style.borderColor = '#b36328';
		i++;
	}

	modify_field = 'fabric';
}

function selectSpecialTieback(count_id, special_id)
{
	var add_vars = 1;
	var i = 0;
	var array_selected_special = selected_special_tieback.split(',');
	var array_selected_special_count = selected_special_tieback_count.split(',');
	if ( array_selected_special[0] != '' )
	{
		var new_special_id = '';
		var new_special_count = '';
		while ( array_selected_special[i] )
		{
			if ( array_selected_special_count[i] == count_id ) // remove it
			{
				var add_vars = 0;
			}
			else
			{
				new_special_id = ( new_special_id == '' ? '' : new_special_id + ',' ) + array_selected_special[i];
				new_special_count = ( new_special_count == '' ? '' : new_special_count + ',' ) + array_selected_special_count[i];
			}
			i++;
		}
		selected_special_tieback = new_special_id;
		selected_special_tieback_count = new_special_count;
	}

	var i = 1;
	while ( document.getElementById('special_tieback_image_' + i) )
	{
		document.getElementById('special_tieback_image_' + i).style.borderColor = '#FFFFFF';
		i++;
	}

	if ( add_vars > 0 )
	{
		how_many_items++;
		how_many_items_tieback++;

		selected_special_tieback = ( selected_special_tieback == '' ? '' : selected_special_tieback + ',' ) + special_id;
		selected_special_tieback_count = ( selected_special_tieback_count == '' ? '' : selected_special_tieback_count + ',' ) + count_id;
	}
	else
	{
		how_many_items--;
		how_many_items_tieback--;
	}

	var i = 0;
	var array_selected_special = selected_special_tieback_count.split(',');
	while ( array_selected_special[i] )
	{
		document.getElementById('special_tieback_image_' + array_selected_special[i]).style.borderColor = '#b36328';
		i++;
	}

	modify_field = 'tieback';
}

function selectSpecialFringe(count_id, special_id)
{
	var add_vars = 1;
	var i = 0;
	var array_selected_special = selected_special_fringe.split(',');
	var array_selected_special_count = selected_special_fringe_count.split(',');
	if ( array_selected_special[0] != '' )
	{
		var new_special_id = '';
		var new_special_count = '';
		while ( array_selected_special[i] )
		{
			if ( array_selected_special_count[i] == count_id ) // remove it
			{
				var add_vars = 0;
			}
			else
			{
				new_special_id = ( new_special_id == '' ? '' : new_special_id + ',' ) + array_selected_special[i];
				new_special_count = ( new_special_count == '' ? '' : new_special_count + ',' ) + array_selected_special_count[i];
			}
			i++;
		}
		selected_special_fringe = new_special_id;
		selected_special_fringe_count = new_special_count;
	}

	var i = 1;
	while ( document.getElementById('special_fringe_image_' + i) )
	{
		document.getElementById('special_fringe_image_' + i).style.borderColor = '#FFFFFF';
		i++;
	}

	if ( add_vars > 0 )
	{
		how_many_items++;
		how_many_items_fringe++;

		selected_special_fringe = ( selected_special_fringe == '' ? '' : selected_special_fringe + ',' ) + special_id;
		selected_special_fringe_count = ( selected_special_fringe_count == '' ? '' : selected_special_fringe_count + ',' ) + count_id;
	}
	else
	{
		how_many_items--;
		how_many_items_fringe--;
	}

	var i = 0;
	var array_selected_special = selected_special_fringe_count.split(',');
	while ( array_selected_special[i] )
	{
		document.getElementById('special_fringe_image_' + array_selected_special[i]).style.borderColor = '#b36328';
		i++;
	}

	modify_field = 'fringe';
}

function selectSpecialHardware(count_id, special_id)
{
	var add_vars = 1;
	var i = 0;
	var array_selected_special = selected_special_hardware.split(',');
	var array_selected_special_count = selected_special_hardware_count.split(',');
	if ( array_selected_special[0] != '' )
	{
		var new_special_id = '';
		var new_special_count = '';
		while ( array_selected_special[i] )
		{
			if ( array_selected_special_count[i] == count_id ) // remove it
			{
				var add_vars = 0;
			}
			else
			{
				new_special_id = ( new_special_id == '' ? '' : new_special_id + ',' ) + array_selected_special[i];
				new_special_count = ( new_special_count == '' ? '' : new_special_count + ',' ) + array_selected_special_count[i];
			}
			i++;
		}
		selected_special_hardware = new_special_id;
		selected_special_hardware_count = new_special_count;
	}

	var i = 1;
	while ( document.getElementById('special_hardware_image_' + i) )
	{
		document.getElementById('special_hardware_image_' + i).style.borderColor = '#FFFFFF';
		i++;
	}

	if ( add_vars > 0 )
	{
		how_many_items++;
		how_many_items_hardware++;

		selected_special_hardware = ( selected_special_hardware == '' ? '' : selected_special_hardware + ',' ) + special_id;
		selected_special_hardware_count = ( selected_special_hardware_count == '' ? '' : selected_special_hardware_count + ',' ) + count_id;
	}
	else
	{
		how_many_items--;
		how_many_items_hardware--;
	}

	var i = 0;
	var array_selected_special = selected_special_hardware_count.split(',');
	while ( array_selected_special[i] )
	{
		document.getElementById('special_hardware_image_' + array_selected_special[i]).style.borderColor = '#b36328';
		i++;
	}

	modify_field = 'hardware';
}

function removeSpecialFabric(total_fabric)
{
	if ( selected_special_fabric != '' )
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = 'Loading...';
		Element.show('progress_box');

		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=fabric&mode=remove&special=1';

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'remove=1',
			onSuccess: function(xhrResponse) {
				how_many_items -= document.getElementById('total_special_fabric').value;
				if ( document.getElementById('how_many_items_fabric') )
				{
					$('how_many_items_fabric').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_tieback') )
				{
					$('how_many_items_tieback').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_fringe') )
				{
					$('how_many_items_fringe').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_hardware') )
				{
					$('how_many_items_hardware').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_special') )
				{
					$('how_many_items_special').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}

				/*$('step_fabric').innerHTML = xhrResponse.responseText;
				Element.show('step_fabric');
				Element.hide('step_' + last_step);

				current_step = 5;
				last_step = 'fabric';
				parent.location.hash = 'step=fabric';*/
				Element.hide('progress_box');
				selected_special_fabric = '';
				selected_special_fabric_count = '';
				for ( var i=1; i<=total_fabric; i++ )
				{
					Element.hide('special_fabrics_image_' + i);
				}
				Element.hide('special_fabrics_price');
				$('total_amount').innerHTML = '$' + xhrResponse.responseText;
				reload_step = ( reload_step == '' ? '' : reload_step + ',' ) + 'fabric';

				if ( selected_special_fabric == '' && selected_special_tieback == '' && selected_special_fringe == '' && selected_special_hardware == '' ) // all null
				{
					Element.hide('review_specials');
				}
				//removed_selection = 'fabric';

				//document.getElementById('step_6_img').src = 'images/steps_06.jpg';
				//document.getElementById('step_5_img').src = 'images/steps2_05.jpg';
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
}

function removeSpecialTieback(total_tieback)
{
	if ( selected_special_tieback != '' )
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = 'Loading...';
		Element.show('progress_box');

		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=fringe&mode=remove&special=1';

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'remove=1',
			onSuccess: function(xhrResponse) {
				how_many_items -= document.getElementById('total_special_tieback').value;
				if ( document.getElementById('how_many_items_fabric') )
				{
					$('how_many_items_fabric').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_tieback') )
				{
					$('how_many_items_tieback').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_fringe') )
				{
					$('how_many_items_fringe').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_hardware') )
				{
					$('how_many_items_hardware').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_special') )
				{
					$('how_many_items_special').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				/*$('step_tieback').innerHTML = xhrResponse.responseText;
				Element.show('step_tieback');
				Element.hide('step_' + last_step);

				current_step = 5;
				last_step = 'tieback';
				parent.location.hash = 'step=tieback';*/
				Element.hide('progress_box');
				selected_special_tieback = '';
				selected_special_tieback_count = '';
				for ( var i=1; i<=total_tieback; i++ )
				{
					Element.hide('special_tiebacks_image_' + i);
				}
				Element.hide('special_tiebacks_price');
				$('total_amount').innerHTML = '$' + xhrResponse.responseText;
				reload_step = ( reload_step == '' ? '' : reload_step + ',' ) + 'tieback';

				if ( selected_special_fabric == '' && selected_special_tieback == '' && selected_special_fringe == '' && selected_special_hardware == '' ) // all null
				{
					Element.hide('review_specials');
				}
				//removed_selection = 'tieback';

				//document.getElementById('step_6_img').src = 'images/steps_06.jpg';
				//document.getElementById('step_5_img').src = 'images/steps2_05.jpg';
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
}

function removeSpecialFringe(total_fringe)
{
	if ( selected_special_fringe != '' )
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = 'Loading...';
		Element.show('progress_box');

		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=hardware&mode=remove&special=1&which=fringe';

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'remove=1',
			onSuccess: function(xhrResponse) {
				how_many_items -= document.getElementById('total_special_fringe').value;
				if ( document.getElementById('how_many_items_fabric') )
				{
					$('how_many_items_fabric').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_tieback') )
				{
					$('how_many_items_tieback').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_fringe') )
				{
					$('how_many_items_fringe').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_hardware') )
				{
					$('how_many_items_hardware').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_special') )
				{
					$('how_many_items_special').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				/*$('step_fringe').innerHTML = xhrResponse.responseText;
				Element.show('step_fringe');
				Element.hide('step_' + last_step);

				current_step = 5;
				last_step = 'fringe';
				parent.location.hash = 'step=fringe';*/
				Element.hide('progress_box');
				selected_special_fringe = '';
				selected_special_fringe_count = '';
				for ( var i=1; i<=total_fringe; i++ )
				{
					Element.hide('special_fringes_image_' + i);
				}
				Element.hide('special_fringes_price');
				$('total_amount').innerHTML = '$' + xhrResponse.responseText;
				reload_step = ( reload_step == '' ? '' : reload_step + ',' ) + 'fringe';

				if ( selected_special_fabric == '' && selected_special_tieback == '' && selected_special_fringe == '' && selected_special_hardware == '' ) // all null
				{
					Element.hide('review_specials');
				}
				//removed_selection = 'fringe';

				//document.getElementById('step_6_img').src = 'images/steps_06.jpg';
				//document.getElementById('step_5_img').src = 'images/steps2_05.jpg';
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
}

function removeSpecialHardware(total_hardware)
{
	if ( selected_special_hardware != '' )
	{
		clearTimeout(hideProgress); // clear any existing timeouts

		/* set text to a loading box */
		$('progress_text').innerHTML = 'Loading...';
		Element.show('progress_box');

		/* add the ajax request to the end of defined url variable */
		var url = 'shop_ajax.php?step=hardware&mode=remove&special=1&which=hardware';

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'remove=1',
			onSuccess: function(xhrResponse) {
				how_many_items -= document.getElementById('total_special_hardware').value;
				if ( document.getElementById('how_many_items_fabric') )
				{
					$('how_many_items_fabric').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_tieback') )
				{
					$('how_many_items_tieback').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_fringe') )
				{
					$('how_many_items_fringe').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_hardware') )
				{
					$('how_many_items_hardware').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				if ( document.getElementById('how_many_items_special') )
				{
					$('how_many_items_special').innerHTML = '(' + how_many_items + ') Item' + ( how_many_items == 1 ? '' : 's' ) + ' in Cart';
				}
				/*$('step_hardware').innerHTML = xhrResponse.responseText;
				Element.show('step_hardware');
				Element.hide('step_' + last_step);

				current_step = 5;
				last_step = 'hardware';
				parent.location.hash = 'step=hardware';*/
				Element.hide('progress_box');
				selected_special_hardware = '';
				selected_special_hardware_count = '';
				for ( var i=1; i<=total_hardware; i++ )
				{
					Element.hide('special_hardwares_image_' + i);
				}
				Element.hide('special_hardware_price');
				$('total_amount').innerHTML = '$' + xhrResponse.responseText;
				reload_step = ( reload_step == '' ? '' : reload_step + ',' ) + 'hardware';

				if ( selected_special_fabric == '' && selected_special_tieback == '' && selected_special_fringe == '' && selected_special_hardware == '' ) // all null
				{
					Element.hide('review_specials');
				}
				//removed_selection = 'hardware';

				//document.getElementById('step_6_img').src = 'images/steps_06.jpg';
				//document.getElementById('step_5_img').src = 'images/steps2_05.jpg';
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
}

function selectSpecial(special_id, count_id, special_type) // ?mode=specials
{
	var add_vars = 1;
	var i = 0;
	var array_selected_special_count = specials_count.split(',');
	if ( special_type == 'fabric' )
	{
		var array_selected_special = selected_special_fabric.split(',');
	}
	else if ( special_type == 'tieback' )
	{
		var array_selected_special = selected_special_tieback.split(',');
	}
	else if ( special_type == 'fringe' )
	{
		var array_selected_special = selected_special_fringe.split(',');
	}
	else if ( special_type == 'hardware' )
	{
		var array_selected_special = selected_special_hardware.split(',');
	}

	if ( array_selected_special_count[0] != '' )
	{
		var new_special_id = '';
		var new_special_count = '';
		while ( array_selected_special_count[i] )
		{
			if ( array_selected_special_count[i] == count_id ) // remove it
			{
				var add_vars = 0;
				var remove_id = document.getElementById('special_item_' + count_id).value;
			}
			else
			{
				//new_special_id = ( new_special_id == '' ? '' : new_special_id + ',' ) + array_selected_special[i];
				new_special_count = ( new_special_count == '' ? '' : new_special_count + ',' ) + array_selected_special_count[i];
			}
			i++;
		}

		i = 0;
		while ( array_selected_special[i] )
		{
			if ( remove_id != array_selected_special[i] )
			{
				new_special_id = ( new_special_id == '' ? '' : new_special_id + ',' ) + array_selected_special[i];
			}
			i++;
		}

		specials_count = new_special_count;
		if ( special_type == 'fabric' )
		{
			selected_special_fabric = new_special_id;
			//selected_special_fabric_count = new_special_count;
		}
		else if ( special_type == 'tieback' )
		{
			selected_special_tieback = new_special_id;
			//selected_special_tieback_count = new_special_count;
		}
		else if ( special_type == 'fringe' )
		{
			selected_special_fringe = new_special_id;
			//selected_special_fringe_count = new_special_count;
		}
		else if ( special_type == 'hardware' )
		{
			selected_special_hardware = new_special_id;
			//selected_special_hardware_count = new_special_count;
		}
	}

	var i = 0;
	while ( document.getElementById('special_image_' + i) )
	{
		document.getElementById('special_image_' + i).style.borderColor = '#FFFFFF';
		i++;
	}

	if ( add_vars > 0 )
	{
		how_many_items++;
		specials_count = ( specials_count == '' ? '' : specials_count + ',' ) + count_id;
		if ( special_type == 'fabric' )
		{
			selected_special_fabric = ( selected_special_fabric == '' ? '' : selected_special_fabric + ',' ) + special_id;
			//selected_special_fabric_count = ( selected_special_fabric_count == '' ? '' : selected_special_fabric_count + ',' ) + count_id;
		}
		else if ( special_type == 'tieback' )
		{
			selected_special_tieback = ( selected_special_tieback == '' ? '' : selected_special_tieback + ',' ) + special_id;
			//selected_special_tieback_count = ( selected_special_tieback_count == '' ? '' : selected_special_tieback_count + ',' ) + count_id;
		}
		else if ( special_type == 'fringe' )
		{
			selected_special_fringe = ( selected_special_fringe == '' ? '' : selected_special_fringe + ',' ) + special_id;
			//selected_special_fringe_count = ( selected_special_fringe_count == '' ? '' : selected_special_fringe_count + ',' ) + count_id;
		}
		else if ( special_type == 'hardware' )
		{
			selected_special_hardware = ( selected_special_hardware == '' ? '' : selected_special_hardware + ',' ) + special_id;
			//selected_special_hardware_count = ( selected_special_hardware_count == '' ? '' : selected_special_hardware_count + ',' ) + count_id;
		}
	}
	else
	{
		how_many_items--;
	}

	var i = 0;
	if ( special_type == 'fabric' )
	{
		var array_selected_special = specials_count.split(',');
	}
	else if ( special_type == 'tieback' )
	{
		var array_selected_special = specials_count.split(',');
	}
	else if ( special_type == 'fringe' )
	{
		var array_selected_special = specials_count.split(',');
	}
	else if ( special_type == 'hardware' )
	{
		var array_selected_special = specials_count.split(',');
	}
	while ( array_selected_special[i] )
	{
		document.getElementById('special_image_' + array_selected_special[i]).style.borderColor = '#b36328';
		i++;
	}

	if ( specials_count != '' )
	{
		add_specials = 1;
	}
}

function previousSpecialPage()
{
	Element.hide('special_page_' + current_special_page);
	current_special_page -= 1;
	Element.show('special_page_' + current_special_page);

	if ( current_special_page == 1 )
	{
		Element.hide('previous_special_link');
	}

	Element.show('next_special_link');
}

function nextSpecialPage(max_pages)
{
	Element.hide('special_page_' + current_special_page);
	current_special_page += 1;
	Element.show('special_page_' + current_special_page);

	if ( current_special_page == max_pages )
	{
		Element.hide('next_special_link');
	}

	Element.show('previous_special_link');
}

function gotoSpecial()
{
	clearTimeout(hideProgress); // clear any existing timeouts

	/* set text to a loading box */
	$('progress_text').innerHTML = 'Loading...';
	Element.show('progress_box');

	/* add the ajax request to the end of defined url variable */
	var url = 'shop_ajax.php?step=reload_specials';

	/* make the ajax request for the information */
	new Ajax.Request(url, {
		method: 'post',
		parameters: 'reload=1',
		onSuccess: function(xhrResponse) {
			var special_response = xhrResponse.responseText;
			var special_response_position = special_response.indexOf('-eboltajaxmedia-');
			var special_response_plus = (special_response_position + 16); // 16 because -eboltajaxmedia- is 16 chars

			//specials_count = special_response.substring(0, special_response_position);
			$('step_specials').innerHTML = special_response.substring(special_response_plus, special_response.length);
			//add_specials = 1;

			Element.hide('step_' + last_step);
			last_step = 'special';
			//Element.hide('shopping');
			//Element.hide('progress_bar');
			for ( var i=1; i<=6; i++ )
			{
				document.getElementById('step_' + i + '_img').src = 'images/steps_0' + i + '.jpg';
			}
			Element.show('step_specials');
			Element.hide('progress_box');

			parent.location.hash = 'step=specials';
		},
		onFailure: function(xhrResponse) {
			$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
		}
	});
}

function closeConstruction()
{
	Element.hide('construction');
}

function openDescription(type, desc_id)
{
	window.open(main_url + 'shop.php?mode=description&type=' + type + '&desc_id=' + desc_id,'item_description','width=640,height=600,resizable=yes,scrollbars=yes');
}

function openPicture(image_id)
{
	window.open(main_url + 'contact.php?image=' + image_id,'picture_location','width=640,height=600,resizable=yes,scrollbars=yes');
}

function grayOut(vis, options) {
	// Pass true to gray out screen, false to ungray
	// options are optional.  This is a JSON object with the following (optional) properties
	// opacity:0-100         // Lower number = less grayout higher = more of a blackout
	// zindex: #             // HTML elements with a higher zindex appear on top of the gray out
	// bgcolor: (#xxxxxx)    // Standard RGB Hex color code
	// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
	// Because options is JSON opacity/zindex/bgcolor are all optional and can appear
	// in any order.  Pass only the properties you need to set.
	var options = options || {};
	var zindex = options.zindex || 50;
	var opacity = options.opacity || 70;
	var opaque = (opacity / 100);
	var bgcolor = options.bgcolor || '#000000';
	var dark=document.getElementById('darkenScreenObject');
	if (!dark) {
		// The dark layer doesn't exist, it's never been created.  So we'll
		// create it here and apply some basic styles.
		// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
		var tbody = document.getElementsByTagName("body")[0];
		var tnode = document.createElement('div');           // Create the layer.
		tnode.style.position='absolute';                 // Position absolutely
		tnode.style.top='0px';                           // In the top
		tnode.style.left='0px';                          // Left corner of the page
		tnode.style.overflow='hidden';                   // Try to avoid making scroll bars
		tnode.style.display='none';                      // Start out Hidden
		tnode.id='darkenScreenObject';                   // Name it so we can find it later
		tbody.appendChild(tnode);                            // Add it to the web page
		dark=document.getElementById('darkenScreenObject');  // Get the object.
	}
	if (vis) {
		// Calculate the page width and height
		if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
			var pageWidth = document.body.scrollWidth+'px';
			var pageHeight = document.body.scrollHeight+'px';
		} else if( document.body.offsetWidth ) {
			var pageWidth = document.body.offsetWidth+'px';
			var pageHeight = document.body.offsetHeight+'px';
		} else {
			var pageWidth='100%';
			var pageHeight='100%';
		}
		//set the shader to cover the entire page and make it visible.
		dark.style.opacity=opaque;
		dark.style.MozOpacity=opaque;
		dark.style.filter='alpha(opacity='+opacity+')';
		dark.style.zIndex=zindex;
		dark.style.backgroundColor=bgcolor;
		dark.style.width= pageWidth;
		dark.style.height= pageHeight;
		dark.style.display='block';
	} else {
		dark.style.display='none';
	}
}

var checkSession;
var user_browser = '';
var user_page = '';

function trackSessions(browser, page)
{
	clearInterval(checkSession);
	
	var screenW = 640;
	var screenH = 480;
	
	if ( parseInt(navigator.appVersion) > 3 )
	{
		screenW = screen.width;
		screenH = screen.height;
	}
	else if ( navigator.appName == "Netscape" && parseInt(navigator.appVersion)==3 && navigator.javaEnabled() )
	{
		var jToolkit = java.awt.Toolkit.getDefaultToolkit();
		var jScreenSize = jToolkit.getScreenSize();
		screenW = jScreenSize.width;
		screenH = jScreenSize.height;
	}

	var url = 'track-sessions.php';

	/* make the ajax request for the information */
	new Ajax.Request(url, {
		method: 'post',
		parameters: 'browser=' + browser + '&page=' + page + '&screen_width=' + screenW + '&screen_height=' + screenH + '&new_page=1',
		onSuccess: function(xhrResponse) {
			checkSession = setInterval("updateSession('" + browser + "', '" + page + "', " + screenW + ", " + screenH + ")", 1000);
		},
		onFailure: function(xhrResponse) {

		}
	});
}

function updateSession(browser, page, screenW, screenH)
{
	var url = 'track-sessions.php';
	
	/* make the ajax request for the information */
	new Ajax.Request(url, {
		method: 'post',
		parameters: 'browser=' + browser + '&page=' + page + '&screen_width=' + screenW + '&screen_height=' + screenH + '&new_page=0',
		onSuccess: function(xhrResponse) {
			
		},
		onFailure: function(xhrResponse) {

		}
	});

}