var step3 = false;
//var validationLoaded = false;

function init()
{
	initProducts();
	initBasket();
}

function updateInner(elementId, content)
{
	$(elementId).innerHTML = content;
}

function ajaxRequest(url, onSuccess, pars, method)
{
	var elmId = onSuccess;
	
	if (elmId && $(elmId).id)
		onSuccess = function(resp) {if (resp.responseText) { updateInner(elmId, resp.responseText)} };
		
	if(window.layoutCode != null)
	{
		url = url + (url ? '&' : '?') + "layout="+window.layoutCode;
	}
	
	new Ajax.Request
	(
		url,
		{
			method: method,
			parameters: pars,
			onSuccess: onSuccess
		}
	);
}

function loadScript(url, onLoad)
{
   var e = document.createElement("script");
   e.src = url;
   e.type = "text/javascript";
   
   e.onload = onLoad;
   e.onreadystatechange = onLoad;
   document.getElementsByTagName("head")[0].appendChild(e);
}

/*
 * Slider
 */
var sliderObj = new Array();
var initValue = null;

//cleanUp
function cu(x, cleaner)
{
	if(!cleaner)
		cleaner = 10000;
	return Math.round(x*cleaner) / cleaner;
}

function clearSlider(id)
{
	sliderObj[id] = null;
	//clear the slider?
}
					
function adjustSlider(id)
{
	var slide = function(value)
	{
		var priceInterval = parseFloat($('price_interval_'+id).value);
		var interval = parseFloat($('interval_'+id).value);
		var maxS = parseFloat($('price_max_'+id).value);
		var minS = parseFloat($('price_min_'+id).value);
		var minX = parseFloat($('amount_min_'+id).value);
		var minWeight = parseFloat($('start_weight_'+id).value);
		var weightInterval = parseFloat($('weight_interval_'+id).value);
		var unit = $('unit_'+id).value;
		
		if(!value && initValue)
			value = initValue;
		
		if(!value || value < minX)
			value = minX;

		$('amount_'+id).innerHTML = cu(value);
		$('unitText_'+id).innerHTML = unit;
		
		var totalPrice = ((value - minX) * priceInterval / interval) + minS;
		if(maxS > 0 && totalPrice > maxS)
			totalPrice = maxS;
			
		if($('totalPrice_'+id))
		{
			$('totalPrice_'+id).innerHTML = '&#0128;' + totalPrice.toFixed(2).replace(".", ",");
		}
		if($('totalWeight_'+id))
		{
			$('totalWeight_'+id).innerHTML = cu(minWeight + weight * value / interval);
		}
	}
	var interval = parseFloat($('interval_'+id).value);
	var maxX = parseFloat($('amount_max_'+id).value);
	var minX = parseFloat($('amount_min_'+id).value);
	var valueArray = new Array();
	
	var sliderVal = initValue ? initValue : minX;
	counter = 0;
	for(var i=minX; (cu(i) <= maxX && counter < 1000); i += interval)
	{
		counter++;
		valueArray.push(cu(i));
	}
	
	var options = {
		values: valueArray, 
		sliderValue: sliderVal,
		range: $R(minX,maxX),
		onSlide: slide,
		onChange: slide
	};
	
	if(!sliderObj[id])
	{
		sliderObj[id] = new Control.Slider('handle_'+id, 'wmSlider_'+id, options);
	}
	else
	{
		sliderObj[id].initialize('handle_'+id, 'wmSlider_'+id, options);
	}
	
	slide();
}
 



/*
 * Admin
 */

function removeShopForm(formId)
{
	var func = function(resp)
	{
		if(resp.responseText)
		{
			//$('form_settings_'+formId).hide();
			location.reload(true);
		}
	}
	
	if (confirm('Wilt u dit form echt uit de webwinkel verwijderen?'))
		ajaxRequest('?action=removeShopForm', func, 'formId='+formId, 'post');
	
}

// settings
function toggleAddShippingItem()
{
	$('add_new_shipping_method').toggle();
	$('add_new_shipping_method').descendants().each(function(elm) { elm.disabled = !$('add_new_shipping_method').visible(); });
}

function deleteShippingItem(shippingId)
{
	var func = function(resp)
	{
		if (resp.responseText)
			$('shipping_'+shippingId).hide();
	}
	
	if (confirm('Wilt u deze verzendmethode echt verwijderen?'))
		ajaxRequest('?action=deleteShippingItem', func, 'shippingId='+shippingId, 'post');
}

function toggleAddTaxClassItem()
{
	$('add_new_tax_class').toggle();
	$('add_new_tax_class').descendants().each(function(elm) { elm.disabled = !$('add_new_tax_class').visible(); });
}

function deleteTaxClassItem(taxClassId)
{
	var func = function(resp)
	{
		if (resp.responseText)
			$('tax_class_'+taxClassId).hide();
	}
	
	if (confirm('Wilt u dit BTW-tarief echt verwijderen?'))
		ajaxRequest('?action=deleteTaxClassItem', func, 'taxClassId='+taxClassId, 'post');
}

function toggleAddDiscountItem()
{
	$('add_new_discount_item').toggle();
	$('add_new_discount_item').descendants().each(function(elm) { elm.disabled = !$('add_new_discount_item').visible(); });
}

function deleteDiscountItem(discountId)
{
	var func = function(resp)
	{
		if (resp.responseText)
			$('discount_'+discountId).hide();
	}
	
	if (confirm('Wilt u deze korting echt verwijderen?'))
		ajaxRequest('?action=deleteDiscountItem', func, 'discountId='+discountId, 'post');
}

// orders

function loadShopOrdersTable(resp)
{
	if (resp.responseText) 
	{ 
		
		updateInner('shop_orders_edit', resp.responseText);
		resp.responseText.evalScripts();
	} 
}

function sort(field, direction, status)
{
	//alert('sort on '+field+" "+direction);
	$('shop_orders_edit').innerHTML = '';
	
	ajaxRequest('?action=sort', 'shop_orders_table', "field="+field+"&direction="+direction+"&select_status="+status, 'post');
	
}

function deleteOrder(id, page, field, direction)
{
	if(confirm('Wilt u bestelling '+id+' echt verwijderen?'))
	{
		//alert('delete '+id);
		ajaxRequest('?action=delete', 'shop_orders_table', "id="+id+"&field="+field+"&direction="+direction+"&page="+page, 'post');
	}
}

function hideTable(id)
{
	$$('tr.hideable').each(function(elm){if(elm.id != id) elm.hide();});
	$$('div.pagenumbers').each(function(elm){elm.hide();});
	$('statusFields').hide();
}

function editOrder(id, page, field, direction, status)
{
	hideTable(id);
	//hideTable(id);
	ajaxRequest('?action=edit', loadShopOrdersTable, "id="+id+"&field="+field+"&direction="+direction+"&page="+page+"&select_status="+status, 'post');
}

function closeEditOrder()
{
	$('shop_orders_edit').innerHTML = '';
	
	$$('tr.hideable').each(function(elm){elm.show();});
	$$('div.pagenumbers').each(function(elm){elm.show();});
	$('statusFields').show();
}

function editPaymentStatus(id, page, field, direction, status)
{
	hideTable(id);
	
	ajaxRequest('?action=editPaymentStatus', 'shop_orders_edit', "id="+id+"&field="+field+"&direction="+direction+"&page="+page+"&select_status="+status, 'post');
}

function editShipmentStatus(id, page, field, direction, status)
{
	hideTable(id);
	
	ajaxRequest('?action=editShipmentStatus', 'shop_orders_edit', "id="+id+"&field="+field+"&direction="+direction+"&page="+page+"&select_status="+status, 'post');
}

function editCancelStatus(id, page, field, direction, status)
{
	hideTable(id);
	
	ajaxRequest('?action=editCancelStatus', 'shop_orders_edit', "id="+id+"&field="+field+"&direction="+direction+"&page="+page+"&select_status="+status, 'post');
}

function selectOrders(field, direction, last_clicked)
{
	var classes = $(last_clicked).className;
	if(classes.indexOf('selected') == -1)
	{
		 classes = classes + ' selected';	
	}
	else
	{
		classes = classes.replace('selected', '');
	}
	$(last_clicked).className = classes;
		
	var selected = "";
	
	$$('span.selected').each
	(
		function(elm)
		{
			selected += elm.id;
			selected += "|";
		}
	);
	
	ajaxRequest('?action=selectStatus', 'shop_orders_table', 'field='+field+'&direction='+direction+'&select_status='+selected+'&last_clicked='+last_clicked, 'post');
}

/*
function setStatus(id)
{
	//alert('setStatus'+id);
	
	var status = $('status'+id).value;
	
	ajaxRequest('?action=setStatus', 'shop_orders_edit', "id="+id+"&status="+status, 'post');
}

function selectStatus(status)
{
	ajaxRequest('?action=selectStatus', 'shop_orders_table', "status="+status, 'post');
}

function viewPage(page, field, direction, status)
{
	ajaxRequest('?action=viewPage', 'shop_orders_table', "page="+page+"&field="+field+"&direction="+direction+"&status="+status, 'post');
}
*/

function viewPage(page, field, direction, status)
{
	ajaxRequest('?action=viewPage', 'shop_orders_table', "page="+page+"&field="+field+"&direction="+direction+"&select_status="+status, 'post');
}

/*
 * Categories
 */

var activeId=0;
var activePageId=1;

function refreshTree()
{
	if($('editCategories').checked)
	{
		var func = function(resp)
		{
			$('shop_admin_tree').innerHTML = resp.responseText;
			resp.responseText.evalScripts();
			initTree();
		}
		
		ajaxRequest('?action=refreshTree', func, '', 'post');
	}
	else
	{
		var func = function(resp)
		{
			$('shop_admin_tree').innerHTML = resp.responseText;
			resp.responseText.evalScripts();
			initTree();
			initTreeDraggable();
		}
	
		ajaxRequest('?action=frontEndTree', func, '', 'post');
	}
}

function deleteCategory(categoryId)
{
	var func = function(resp)
	{
		$('shop_admin_tree').innerHTML = resp.responseText;
		resp.responseText.evalScripts();
		initTree();
		activeId=0;
	}
		
	ajaxRequest('?action=deleteCategory', func, 'categoryId='+categoryId, 'post');
}

function addCategoryToProduct(categoryId, productId)
{
	ajaxRequest('?action=addCategoryToProduct', 'shop_product_category_list_'+productId, "categoryId="+categoryId+"&productId="+productId, 'post');
}

function deleteProductCategory(productId, categoryId)
{
	ajaxRequest('?action=deleteProductCategory', 'shop_product_category_list_'+productId, "categoryId="+categoryId+"&productId="+productId, 'post');
}

function initTree()
{
	$$('li.list_1').each(
		function(elm) 
		{
			Droppables.add(elm.id, 
			{
				accept: 'product_draggable',
				hoverclass: 'highlight',
				onDrop: function(dragged, dropped, event) 
				{ 
					categoryId = (dropped.id).substr((dropped.id).indexOf('_')+1, (dragged.id).length-1);
					productId = (dragged.id).substr((dragged.id).indexOf('_')+1, (dragged.id).length-1);

					addCategoryToProduct(categoryId, productId);
				}
			});
		}
	);
}

function initTreeDraggable()
{
	$$('li.list_1').each
	(
		function(elm) 
		{
			new Draggable
			(
				elm.id, 
				{ 
					revert: true, ghosting: true, starteffect: function(elm) 
					{
						new Effect.Opacity
						(
							elm, 
							{ 
								duration: 0.1, from: 1.0, to: 0.2 
							}
						)
					}
					, endeffect: function(elm) 
					{
						new Effect.Opacity
						(
							elm, 
							{ 
								duration: 0.1, from: 0.2, to: 1.0 
							}
						)
					} 
				}
			) 
		}
	);
}

function initDiscounts()
{
	$$('div.shop_admin_discounts_discount').each(
		function(elm) 
		{
			Droppables.add(elm.id, 
			{
				accept: ['list_1', 'product_draggable'],
				hoverclass: 'highlight',
				onDrop: function(dragged, dropped, event) 
				{ 
					var type = dragged.id.substr(0, dragged.id.indexOf('_'));
					var itemId = (dragged.id).substr((dragged.id).indexOf('_')+1, (dragged.id).length-1);
					discountId = (dropped.id).substr((dropped.id).indexOf('_')+1, (dragged.id).length-1);
					
					if(type == "product")
					{
						addProductToDiscount(itemId, discountId);
					}
					else
					{
						addCategoryToDiscount(itemId, discountId);
					}
				}
			});
		}
	);
}

function addCategoryToDiscount(categoryId, discountId)
{
	func = function(resp) { if (resp.responseText) 
		{ 
			updateInner("shop_admin_discounts", resp.responseText); 
			resp.responseText.evalScripts(); 
			initDiscounts();} 
		};
	ajaxRequest('?action=addCategoryToDiscount', func, 'categoryId='+categoryId+'&discountId='+discountId, 'post');
}

function removeCategoryFromDiscount(categoryId, discountId)
{
	func = function(resp) { if (resp.responseText) { updateInner("shop_admin_discounts", resp.responseText); initDiscounts();} };
	ajaxRequest('?action=removeCategoryFromDiscount', func, 'categoryId='+categoryId+'&discountId='+discountId, 'post');
}

function addProductToDiscount(productId, discountId)
{
	func = function(resp) { if (resp.responseText) 
		{ 
			updateInner("shop_admin_discounts", resp.responseText); 
			resp.responseText.evalScripts(); 
			initDiscounts();} 
		};
	ajaxRequest('?action=addProductToDiscount', func, 'productId='+productId+'&discountId='+discountId, 'post');
}

function removeProductFromDiscount(productId, discountId)
{
	func = function(resp) { if (resp.responseText) { updateInner("shop_admin_discounts", resp.responseText); initDiscounts();} };
	ajaxRequest('?action=removeProductFromDiscount', func, 'productId='+productId+'&discountId='+discountId, 'post');
}

function changeCategoryButtonStatus()
{
	if (!$('tree_category_add').empty())
		$('tree_category_add_button').enable();
	else
		$('tree_category_add_button').disable();
}

function editCategory(categoryId)
{
	var func = function(resp)
	{
		$('shop_admin_productlist').innerHTML = resp.responseText;
		resp.responseText.evalScripts();
	}
	
	$('shop_admin_productlist_add').hide();
		
	ajaxRequest('?action=editCategory', func, 'categoryId='+categoryId, 'post');
}

function closeCategory()
{
	if(activeId > 0)
		updateAdminCategories(activeId);
	else
		$('shop_admin_productlist').innerHTML = '';
	
	refreshTree();
}

function addCategory()
{
	if($F('tree_category_add').length == 0)
	{
		alert('Geef eerst een categorienaam op');
		return;
	}
		
	var func = function(resp)
	{
		$('shop_admin_tree').innerHTML = resp.responseText;
		resp.responseText.evalScripts();
		initTree();
		activeId=0;
	}
	
	ajaxRequest('?action=addCategory', func, "activeId="+activeId+"&name="+($F('tree_category_add')), 'post');
}

function updateAdminCategories(categoryId, page)
{
	activeId = categoryId;
	activePageId = page;
	
	var func = function(resp)
	{
		$('shop_admin_productlist').innerHTML = resp.responseText;
		$$('li.active').each(function (elm) {elm.removeClassName('active')});
		$('li_'+categoryId).addClassName('active');
		$('shop_admin_productlist_add').show();
		initTree();
		initProducts();
	};
	
	ajaxRequest('?action=updateProducts', func, "categoryId="+categoryId+'&page='+page, 'post');
}

function updateCategories(categoryId)
{
	activeId = categoryId;

	var func = function(resp)
	{
		$('shop_sidebar_categories').innerHTML = resp.responseText;
		resp.responseText.evalScripts();
	}
	
	if ($('shop_sidebar_categories'))
		ajaxRequest('?subsection=categories', func, 'categoryId='+categoryId, 'post');
	
	viewProducts(categoryId, 1);
}

function deleteCategoryImage(categoryId)
{
	var func = function(resp)
	{
		$('category_image').hide();
	}	

	if(confirm('Weet je zeker dat je de afbeelding van de categorie wilt verwijderen?'))
	ajaxRequest('?action=deleteCategoryImage', func, 'categoryId='+categoryId, 'post');
}

/*
 * Products
 */

function initProducts(isAdmin)
{
	$$('.product_draggable').each(function(elm) { new Draggable(elm.id, { revert: true, ghosting: true, starteffect: function(elm) {new Effect.Opacity(elm, { duration: 0.1, from: 1.0, to: 0.2 })}, endeffect: function(elm) {new Effect.Opacity(elm, { duration: 0.1, from: 0.2, to: 1.0 })} }) });
}

function viewProducts(categoryId, page)
{
	activePageId = page;
	
	var func = function(resp) 
	{ 
		if (resp.responseText) 
		{
			updateInner('shop_main', resp.responseText); 
			resp.responseText.evalScripts();
			initProducts(); 
		} 
	};
	
	ajaxRequest('?subsection=products', func, 'categoryId='+categoryId+'&page='+page, 'post');
}

/*
 * Product
 */

function viewProduct(productId)
{
	var func = function(resp)
	{
		$('shop_main').innerHTML = resp.responseText;
		resp.responseText.evalScripts();
		initProducts();
	}

	ajaxRequest('?subsection=product', func, 'productId='+productId, 'post');
}

function addProduct()
{
	var func = function(resp)
	{
		$('shop_admin_productlist').innerHTML = resp.responseText;
		resp.responseText.evalScripts();
	}
		
	ajaxRequest('?action=addProduct&categoryId='+activeId, func, '', 'post');
	
	$('shop_admin_productlist_add').hide();
}

function editProduct(productId)
{
	var func = function(resp)
	{
		$('shop_admin_productlist').innerHTML = resp.responseText;
		resp.responseText.evalScripts();
	}
	
	ajaxRequest('?action=editProduct', func, 'productId='+productId, 'post');
	
	$('shop_admin_productlist_add').hide();
}

function deleteProduct(productId)
{
	if(confirm('Weet je zeker dat je het product wilt verwijderen?'))
	{
		ajaxRequest('?action=deleteProduct', null, 'productId='+productId, 'post');
		closeProduct();
	}
}

function closeProduct()
{
	if(activeId > 0)
		updateAdminCategories(activeId, activePageId);
	else
		$('shop_admin_productlist').innerHTML = '';
}

function deleteProductImage(productId, imageId)
{
	var func = function(resp)
	{
		$('product_image_'+imageId).hide();
	}	

	if(confirm('Weet je zeker dat je de afbeelding van het product wilt verwijderen?'))
	ajaxRequest('?action=deleteProductImage', func, 'productId='+productId+'&imageId='+imageId, 'post');
}

/*
 * Basket
 */

var funcBasket = function(resp) {
		if (resp.responseText)
		{
			$('shop_sidebar_basket').innerHTML = resp.responseText;
			
			if(step3)
			{
				updateStep3();
			}
					
			initBasket();
		}
	};

function updateStep3()
{
	ajaxRequest('?subsection=checkout&action=updateStep3', 'order_overview_wrapper', '', 'post');
}

function initBasket()
{
	/*
	Droppables.add('shop_sidebar_basket_droppable', {
		accept: 'product_draggable',
		hoverclass: 'highlight',
		onDrop: function(dragged, dropped, event) { updateProductAmount(dragged.id, null); }
	});
	*/
}

function updateBasket(highlight)
{
	var func = function(resp)
	{
		if(resp.responseText)
		{
			funcBasket(resp);
			if(highlight)
			{
				highlightBasket();
			}
		}
	}
	
	ajaxRequest('?subsection=basket', func, '', 'post');
}

function blaat()
{
	alert("blaat");
}

function getSliderParameter(id)
{
	if($('amount_'+id))
	{
		return $('amount_'+id).innerHTML;
	}
}

function highlightBasket()
{
	new Effect.Highlight($('shop_sidebar_basket_content'), 
	{ 
		startcolor: '#60c94b',
		endcolor: '#d9d9d9'
	});
}

function addNewProduct(productId, slider)
{
	sliderAmount = (slider == "slider" ? getSliderParameter(productId) : null);
	var params = 'productId='+productId+'&sliderAmount_'+productId+'='+sliderAmount; 

	var func = function(resp)
	{
		funcBasket(resp);
		highlightBasket();
	}
		
	ajaxRequest('?subsection=basket&action=addNewProduct', func, params, 'post');
}

function editOrderProduct(orderProductId, productId, slider)
{
	sliderAmount = (slider == "slider" ? getSliderParameter(productId) : null);
	var params = 'productId='+productId+'&orderProductId='+orderProductId+'&sliderAmount_'+productId+'='+sliderAmount; 
	ajaxRequest('?subsection=basket&action=editOrderProduct', funcBasket, params, 'post');
}

function showEditOrderProduct(orderProductId)
{
	var func = function(resp)
	{
		if(resp.responseText)
		{
			$('shop_main').innerHTML = resp.responseText;
			resp.responseText.evalScripts();
		}
	}
	
	ajaxRequest('?subsection=basket&action=showEditOrderProduct', func, 'orderProductId='+orderProductId, 'post');
}

function minusOne(orderProductId)
{
	ajaxRequest('?subsection=basket&action=minusOne', funcBasket, 'orderProductId='+orderProductId, 'post');
}

function plusOne(orderProductId)
{
	ajaxRequest('?subsection=basket&action=plusOne', funcBasket, 'orderProductId='+orderProductId, 'post');
}

function removeOrderProduct(orderProductId)
{
	ajaxRequest('?subsection=basket&action=removeProduct', funcBasket, 'orderProductId='+orderProductId, 'post');
}

function submitAddProductForm(productId, detailView)
{
	if($('amount_'+productId))
	{
		$('sliderAmount_'+productId).value = $('amount_'+productId).innerHTML;
	}
}

function afterSubmitAddProductForm(productId, detailView)
{
	if(!detailView)
	{
		$('addProductFormContainer_'+productId).innerHTML= '';
		$('addButton_'+productId).show();
	}
	updateBasket(true);
}

function showAddProductForm(productId)
{
	var func = function(resp)
	{
		if(resp.responseText)
		{
			$('addProductFormContainer_'+productId).innerHTML = resp.responseText;
			
			if($('addButton_'+productId))
				$('addButton_'+productId).hide();
						
			var onLoad = function() { resp.responseText.evalScripts(); }
			loadScript('/includes/js/datepicker/datepicker.js', onLoad);
		}
	}
	
	ajaxRequest('?subsection=product&action=showAddProductForm', func, 'productId='+productId, 'post');
}

function updateProductAmount(orderProductId, amount)
{
	ajaxRequest('?subsection=basket&action=updateProductAmount', funcBasket, 'orderProductId='+orderProductId+'&amount='+amount, 'post');
}

function addCouponCode()
{
	if ($F('coupon_code'))
		ajaxRequest('?subsection=basket&action=addCouponCode', funcBasket, 'couponCode='+$F('coupon_code'), 'post');
	else
		alert('Vul een couponcode in');
}

function deleteCouponCode(couponCode)
{
	ajaxRequest('?subsection=basket&action=deleteCouponCode', funcBasket, 'couponCode='+couponCode, 'post');
}

/*
 * Search
 */
 
function performAdminSearch(orderId)
{
	query = $F('searchText');
	ajaxRequest('?action=search', 'admin_search_results', 'orderId='+orderId+'&query='+query, 'post');
}

function addProductToOrderAdmin(orderId, productId)
{	
	//"id" "field" "direction" "page" "select_status"
	field = $F('field');
	direction = $F('direction');
	page = $F('page');
	select_status = $F('select_status');
	
	ajaxRequest('?action=addProductToOrderAdmin', 'shop_orders_edit', 
		'orderId='+orderId+'&productId='+productId+'&id='+orderId+
		'&field='+field+'&direction='+direction+'&page='+page+
		'&select_status='+select_status
		, 'post');
}

function setProductAmountAdmin(orderId, productId, amount)
{
	var r=confirm("Weet u zeker dat u de aantallen in deze order wil aanpassen?");
	if (r==true)
	{
  
		field = $F('field');
		direction = $F('direction');
		page = $F('page');
		select_status = $F('select_status');
		
		ajaxRequest('?action=setProductAmountAdmin', 'shop_orders_edit', 
			'orderId='+orderId+'&productId='+productId+'&amount='+amount+
			'&id='+orderId+
			'&field='+field+'&direction='+direction+'&page='+page+
			'&select_status='+select_status
			, 'post');
	}
}

function performSearch(query, page)
{
	var func = function(resp) { if (resp.responseText) {updateInner('shop_main', resp.responseText); } };
	ajaxRequest('?subsection=search', func, 'query='+query+'&page='+page, 'post');
}

/*
 * Checkout
 */
/*
function performCheckout(step)
{
	if (!step || step < 1 || step > 4)
		step = 1;
	
	var func = function(resp) 
	{ 
		if (resp.responseText) 
		{
			if(step == 4)
				updateBasket();
		
			updateInner('shop_main', resp.responseText, step == 3);
			
			if (!validationLoaded)
			{
				var onLoad = function() { resp.responseText.evalScripts(); }
				
				loadScript('/includes/js/validation.js.php', onLoad);
				validationLoaded = true;
			}
			else
				resp.responseText.evalScripts();
		} 
	};

	ajaxRequest('?subsection=checkout&step='+step, func, '', 'post');
}
*/

