function quickFind( ){
	
	// Functionality for quick search lightbox feature on homepage
	$( 'find' ).addEvent( 'submit', function ( event ) {
				
		$$( 'input[name=for]' ).each( function( el ){
									    
			if(el.checked){
				
				type = el.get( 'value' );
				
			};
			
		});
				
		// validate
		if( $( 'zip' ).value == '' || !( checkZip( 'zip' ) ) ){
			
			$( 'zip' ).addClass( 'error' );
			$( 'zip' ).value = 'Enter a valid zip';
			
		} else if( $( 'date' ).value == '' || !( checkDate( 'date' ) ) ){

			$( 'date' ).addClass( 'error' );
			$( 'date' ).value = 'Enter a valid date';

		} else {
		
			$( 'zip' ).removeClass( 'error' );
			$( 'date' ).removeClass( 'error' );
			Mediabox.open( relative_path + 'quick-products.html&type=' + type + '&occasion=' + $( 'occasion' ).value + '&zip=' + $( 'zip' ).value + '&date=' + $( 'date' ).value, '', '674 460' );

		};
	
		event.stop();
		
	});
	
};

function swapLabels( ){

	// remove any click events just in case
	$$( '.for' ).removeEvents( 'click' );
	
	$$( '.for' ).addEvent( 'click', function( event ) {
	
		if( this.value == 'delivery' ){
		
			$( 'zipLabel' ).set( 'html', 'Where is it going?' );
			$( 'dateLabel' ).set( 'html', 'When should it arrive?' );
		
		} else if( this.value == 'pickup' ){
			
			$( 'zipLabel' ).set( 'html', 'Pickup Location:' );
			$( 'dateLabel' ).set( 'html', 'Pickup Date:' );
			
		};
		
		// the calendar dates will need to be updated regardless, assuming a zip has been chosen
		if( $( 'zip' ).value != '' && checkZip( 'zip' ) ){
		
			if ( typeof( myCal ) != "undefined" ){
			
				myCal.destroy( );
				
			};
			
			getDateSet( );
		
		} else {
			
			resetCalendar( );
		
		};
	
	});

};

function changeZip( ){

	// remove any click events just in case
	$( 'zip' ).removeEvents( 'keyup' );
	
	$( 'zip' ).addEvent( 'keyup', function( event ) {

		// check that this zip is correct
		if( $( 'zip' ).value != '' && checkZip( 'zip' ) ){
		
			if ( typeof( myCal ) != "undefined" ){
			
				myCal.destroy( );
				
			};
			
			// remove the error
			$( 'zip' ).removeClass( 'error' );
			
			// reset values for date field
			$( 'date' ).value = 'mm/dd/yyyy';
			
			getDateSet( );
			
		} else {

			//$( 'date' ).setAttribute( 'disabled', 'true' );
			$( 'date' ).value = 'mm/dd/yyyy';
			$( 'date' ).setStyle( 'background', 'none repeat #FFFFFF' );
			
			// display the error
			$( 'zip' ).addClass( 'error' );
			//resetCalendar( );
		
		};
	
	});

};

function validateZip( ){

	if( $( 'zip' ).value == '' || !( checkZip( 'zip' ) ) ){

		// if the zip is not properly entered, disable the date field
		//$( 'date' ).setAttribute( 'disabled', 'disabled' );
		
	} else {
		
		// if date is set, make sure the correct date set is displayed
		if ( typeof( myCal ) != "undefined" ){
		
			myCal.destroy( );
			
		};
		
		getDateSet( );
	
	}

}

function getDateSet( ){
	
	var zip = $( 'zip' ).value;
	
	$$( 'input[name=for]' ).each( function( el ){
								    
		if(el.checked){
			
			type = el.get( 'value' );
			
		};
		
	});
	
	// run AJAX to get the new date set
	var myRequest = new Request({
		method:		'get',
		url:			relative_path + '?ajax=get date set&type=' + type + '&zip=' + zip,
		evalScripts: 	true,
		onRequest: 	function ( ) {
			
			$( 'date' ).setAttribute( 'disabled', 'true' );
			$( 'date' ).value = '';
			$( 'date' ).setStyle( 'background', '#FFFFFF url( ' + relative_path + 'images/small_loader.gif ) no-repeat 95% 50%' );
			
		},
		onSuccess:	function( html ) {

			//var dates = html;  /*-- kris@o3world.com  jun 16 '10  why was this commented out? --*/
			resetCalendar( dates );

			if( dates == '1-31 1-12 2000-2020' )
			{	// let the user know that FF doesn't service this zip code
				alert( 'We\'re sorry. FruitFlowers.com does not yet service the zip code ' + zip + '.' );
			}
			else
			{	/*-- kris@o3world.com  may 18 '10  update homepage featured items based on zip code user just entered --*/
				if($('featured_items'))
				{	var rq = new Request({ method: 'get', url: relative_path + '?ajax=featured items&zip=' + zip, evalScripts: true,
						onSuccess: function(ht)
						{	$('featured_items').set('html',ht);
							Cufon.replace('.home_prods h3');
						}
					}).send();
				}
				/*-- kris@o3world.com  may 18 '10  update product details 'similar products' based on zip code user just entered --*/
				if($('also'))
				{	var rq = new Request({ method: 'get', url: relative_path + 'product-details.html&ajax=similar products&product=' + $('product_availability').get('class') + '&zip=' + zip, evalScripts: true,
						onSuccess: function(ht)
						{	$('also').set('html',ht);
						}
					}).send();
				}
			}

			$( 'date' ).removeAttribute( 'disabled' );
			$( 'date' ).value = 'mm/dd/yyyy';
			$( 'date' ).setStyle( 'background', 'none repeat #FFFFFF' );
			
		},
		onFailure:	function( ) {
			
			resetCalendar( );
			
		}
	}).send();

/*-- kris@o3world.com  may 18 '10  provide phone number for pickup store, regardless of availability search outcome --*/

	var myRequest = new Request({ method: 'get', url: relative_path + '?ajax=order by phone&zip=' + zip, evalScripts: true,
		onSuccess: function(html)
		{	$( 'today_phone' ).set('html',html);
			$( 'order_by' ).set('html',html);
		}
	}).send();

};

function resetCalendar( blockedDates ){

	if ( typeof( blockedDates ) == "undefined" ){
		
		blockedDates = new Array( '1-31 1-12 2000-2020', '1 1 1999' );
		
	}

	// kris@o3world.com  apr 16 '10  what day is it 90 days from now?
	var eDt = new Date(); eDt.setTime(eDt.getTime() + (90 * (24 * 60 * 60 * 1000)));

	// run AJAX to find the dates available
	var myCal = new Calendar({ date: 'm/d/Y' }, { blocked: blockedDates, enddate: eDt, todaysdate: serverDateTime });

};

function paginateProducts( ){
	
	// remove any click events just in case
	$$( '.paginate_products' ).removeEvents( 'click' );
	
	// look for pagination objects to set click event	s
	$$( '.paginate_products' ).addEvent( 'click', function( event ) {
				
		var action = product_action;
		var method = pagination_method;
		var start = this.get( 'rel' );
		var keywords = product_keywords;
		var prod_sort = $( 'product_sort' ).value;
		var prod_sort_2 = $( 'product_sort_2' ).value;
		if(!prod_sort) { prod_sort = prod_sort_2; }
		
		// paginajax
		var myRequest = new Request({
							   
			method:		'get',
			url:			relative_path + action +'.html&ajax=' + method + ' products&start=' + start + '&keywords=' + keywords + '&sort=' + prod_sort,
			onRequest: 	function ( ) {
				
				
				
			},
			onSuccess:	function( html ) {
				
				// insert the new html
				$( 'content' ).set( 'html', html );
				
				// reinstantiate all events
				initialize( );
				
			},
			onFailure:	function( ) {
				
				//alert( 'Something went wrong... we couldn\'t paginate the products!' );

			}
		}).send();
		
		event.stop( );
		
	});
};

function sortProducts( bottomSort ){
	
	// remove any click events just in case
	var sortElName = 'product_sort';
	if(bottomSort) { sortElName = 'product_sort_2'; }
	$( sortElName ).removeEvents( 'change' );
	
	// look for sorting change to set click events
	$( sortElName ).addEvent( 'change', function( event ) {
		
		var action = product_action;
		var method = pagination_method;
		var start = 0
		var keywords = product_keywords;
		var prod_sort = $( sortElName ).value;

		// paginajax
		var myRequest = new Request({
							   
			method:		'get',
			url:			relative_path + action +'.html&ajax=' + method + ' products&start=' + start + '&keywords=' + keywords + '&sort=' + prod_sort,
			onRequest: 	function ( ) {
				
				
				
			},
			onSuccess:	function( html ) {
				
				// insert the new html
				$( 'content' ).set( 'html', html );
				
				// reinstantiate all events
				initialize( );
				
			},
			onFailure:	function( ) {
				
				//alert( 'Something went wrong... we couldn\'t paginate the products!' );

			}
		}).send();

		event.stop( );
		
	});
};

function editAvailability( ){

	// remove any click events just in case
	$$( '.edit_availability' ).removeEvents( 'click' );
	
	// look for pagination objects to set click event	s
	$$( '.edit_availability' ).addEvent( 'click', function( event ) {
	
		var clearCart = confirm( "If you change your zip code, date or any other purchase option, any existing items in your cart will be removed and you will need to start over.\n\n Do you want to continue?" );

		if ( clearCart ){

			// edajax
			var myRequest = new Request({
								   
				method:		'get',
				url:			relative_path +'product-details.html&ajax=edit availability&product=' + $( 'product_availability' ).get( 'class' ),
				evalScripts: 	true,
				onRequest: 	function ( ) {
					
					$( 'product_availability' ).set( 'html', '<img src="' + relative_path + 'images/loading.gif">' );
					
				},
				onSuccess:	function( html ) {
					
					// insert the new html
					$( 'product_availability' ).set( 'html', html );
					
					// redraw the fonts
					Cufon.replace( '#prod_head h1' );
					
					// reinstantiate all events
					initialize( );
					
				},
				onFailure:	function( ) {
					
					alert( 'An error occurred. Please reload this page and try again!' );
	
				}
			}).send();
			
		};

		event.stop( );
	
	});

};

function checkAvailability( ){

	// remove any click events just in case
	$( 'availability' ).removeEvents( 'submit' );
	
	// look for a submit event
	$( 'availability' ).addEvent( 'submit', function( event ) {
	
		$$( 'input[name=for]' ).each( function( el ){
									    
			if(el.checked){
				
				type = el.get( 'value' );
				
			};
			
		});

		// validate
		if( $( 'zip' ).value == '' || !( checkZip( 'zip' ) ) ){
			
			$( 'zip' ).addClass( 'error' );
			$( 'zip' ).value = 'Enter a valid zip';
			delete inputList;
			inputList = new InputClearAndReplace();
			
		} else if( $( 'date' ).value == '' || !( checkDate( 'date' ) ) ){

			$( 'date' ).addClass( 'error' );
			$( 'date' ).value = 'Enter a valid date';
			
		} else {

			// checkajax
			var myRequest = new Request({
								   
				method:		'post',
				url:			relative_path +'product-details.html&ajax=check availability',
				evalScript: 	true,
				onRequest: 	function ( ) {
					
					$( 'product_availability' ).set( 'html', '<img src="' + relative_path + 'images/loading.gif">' );
					
				},
				onSuccess:	function( html ) {
					
					// insert the new html
					$( 'product_availability' ).set( 'html', html );
					
					// redraw the fonts
					Cufon.replace( '#prod_head h1' );

					// reinstantiate all events
					initialize( );
					
				},
				onFailure:	function( ) {
					
					alert( 'An error occurred while checking the availability of this product. Please reload this page and try again!' );
	
				}
			}).send( $( 'availability' ) );
			
		};
		
		event.stop( );
	
	});

};


////////////////////////////////////////////
///////// PRODUCT DETAILS //////////////////
////////////////////////////////////////////
function addOnProduct( ){

	// remove any click events just in case
	$$( '.add' ).removeEvents( 'click' );
	
	// look for a click event
	$$( '.add' ).addEvent( 'click', function( event ) {
		
		btn = this;
		
		// check for an attribute set on this product
		attribute = '';
		if( $( btn.id + "_attribute" ) ){
			
			attribute = $( btn.id + "_attribute" ).value;
			
		}
		
		// we only want to do this if the class is 'add', otherwise kill the event
		if( btn.get( 'class' ) == 'add' ){
		
			// addajax
			var myRequest = new Request({
								   
				method:		'get',
				url:			relative_path +'product-details.html&ajax=add on item&product=' + btn.id + '&attribute= ' + attribute,
				onRequest: 	function ( ) {
					
					btn.set( 'class', 'loading' );
					
				},
				onSuccess:	function( html ) {
					
					btn.set( 'class', 'added' );
					
					var newElement = $( parent.document.createElement( 'li' ) );
					
					newElement.set( 'id', 'add_on_' + btn.id );
					
					newElement.set( 'html', html );
					
					var parentBox = parent.document.getElementById( 'addOnProducts' );
					
					//$( parentBox ).grab( newElement ); 
					newElement.inject( parentBox, 'bottom' );
					
					// recalc the subTotal
					parent.subTotal( );

					// reinstantiate all events
					parent.initialize( );
					
				},
				onFailure:	function( ) {
					
					alert( 'Something went wrong... we couldn\'t add this to your item!' );
	
				}
			}).send();
		
		}
		
		event.stop( );
										    
	});
	
}

function removeAddOnProduct( ){

	// remove any click events just in case
	$$( '.remove_addon' ).removeEvents( 'click' );
	
	// look for a click event
	$$( '.remove_addon' ).addEvent( 'click', function( event ) {

		var item = this;

/*-- kris@o3world.com  may 10 '10  just when you though you were done doing browser-specific hacks... --*/
		if(Browser.Engine.webkit)  
		{	$('add_on_' + item.id).dispose();
			parent.subTotal();
		}
		else {
			$('add_on_' + item.id).fade('out').get('tween').chain(
				function() { 
					$('add_on_' + item.id ).destroy();
					parent.subTotal();
				}.bind(item)
			);
		}
		event.stop( );
		
	});
						 
}

function subTotal( ){

	var subTotal = parseFloat( $( 'originalSubTotal' ).value );
	
	$$( '.remove_addon' ).each( function( el ) {
	
		subTotal = subTotal + parseFloat( $( 'item_' + el.id ).value );
	
	});
	
	$( 'subTotal' ).set( 'html', formatCurrency( subTotal ) );

}





//////////////////////////////////////
///////// CART INFO //////////////////
//////////////////////////////////////

function addUpSellToCart( ){

	// remove any click events just in case
	$$( '.add' ).removeEvents( 'click' );
	
	// look for a click event
	$$( '.add' ).addEvent( 'click', function( event ) {
		
		btn = this;
		
		// check for an attribute set on this product
		attribute = '';
		if( $( btn.id + "_attribute" ) ){
			
			attribute = $( btn.id + "_attribute" ).value;
			
		}
		
		// we only want to do this if the class is 'add', otherwise kill the event
		if( btn.get( 'class' ) == 'add' ){
		
			product = btn.id.split( "_" );
		
			// addajax
			var myRequest = new Request({
								   
				method:		'get',
				url:			relative_path +'cart.html&ajax=add on item&product=' + product[ 1 ] + '&item=' + product[ 0 ] + '&attribute=' + attribute,
				onRequest: 	function ( ) {
					
					btn.set( 'class', 'loading' );
					
				},
				onSuccess:	function( html ) {
					
					btn.set( 'class', 'added' );
					
					var newElement = $( parent.document.createElement( 'li' ) );  // <-- create element in parent.document
					
					newElement.set( 'id', 'add_on_' + product[ 1 ] );
					
					newElement.set( 'html', html );
					
					var parentBox = parent.document.getElementById( 'addOnProducts_' + product[ 0 ] );
					
					//$( parentBox ).grab( newElement ); 
					newElement.inject( parentBox, 'bottom' );
										
					var originalPrice 	= parseFloat( parent.document.getElementById( 'original_subTotal_' + product[ 0 ] ).value );
					var itemPrice 		= parseFloat( parent.document.getElementById( 'item_' + product[ 1 ] + '_' + product[ 0 ] ).value );
				
					// recalculate the original pricing for the source item
					parent.document.getElementById( 'original_subTotal_' + product[ 0 ] ).value = originalPrice + itemPrice;
					
					// recalc the subTotal
					parent.cartSubTotal( product[ 0 ] );
					
				},
				onFailure:	function( ) {
					
					alert( 'Something went wrong... we couldn\'t add this to your item!' );
	
				}
			}).send();

		};
		
		event.stop( );
										    
	});
	
}

function removeProductFromCart( ){

	// remove any click events just in case
	$$( '.remove_product' ).removeEvents( 'click' );
	
	// look for a click event
	$$( '.remove_product' ).addEvent( 'click', function( event ) {

		var item = this;
	
		// remove this item from the cart in question then destroy
		var myRequest = new Request({
							   
			method:		'get',
			url:			relative_path + 'cart.html&ajax=remove product&product=' + item.id,
			onRequest: 	function ( ) {

				$( 'product_' + item.id ).set( 'html', '<img src="images/loading.gif">' );

			},
			onSuccess:	function( html ) {

/*-- kris@o3world.com  apr 20 '10  if cart is now empty, break out of here (redirect) --*/
if(html.indexOf("cartIsEmpty") != -1)
{	location.href = relative_path + "cart.html&ts=" + (new Date()).getTime();
}
else { /*-- kris@o3world.com  may 7 '10 --*/  refreshPromoCode(); }
				
				$( 'product_' + item.id ).fade( 'out' ).get( 'tween' ).chain( 
		
					function( ){ 
				
						// destroy the product
						$( 'product_' + item.id ).destroy( );
		
						// recalc the total
						parent.cartGrandTotal( );

					}.bind( item )
					
				);

/*-- kris@o3world.com  apr 20 '10  update # of items in top nav --*/
var cartCount = $$('.prod').length;
$$('.cart')[0].innerHTML = cartCount + " Item" + (cartCount != 1 ? 's' : '');

			},
			onFailure:	function( ) {
				
				alert( 'Something went wrong... we couldn\'t remove the item from your cart!' );

			}
		}).send();
				
		event.stop( );
		
	});
						 
}

function removeUpSellFromCart( ){

	// remove any click events just in case
	$$( '.remove_addon' ).removeEvents( 'click' );
	
	// look for a click event
	$$( '.remove_addon' ).addEvent( 'click', function( event ) {

		var item = this;
	
		// remove this item from the cart in question then destroy
		var myRequest = new Request({
							   
			method:		'get',
			url:			relative_path + 'cart.html&ajax=remove product&product=' + item.id,
			onRequest: 	function ( ) {

				//$( 'add_on_' + item.id ).set( 'html', '<img src="images/loading.gif">' );

			},
			onSuccess:	function( html ) {

/*-- kris@o3world.com  may 7 '10 --*/
refreshPromoCode();

				$( 'add_on_' + item.id ).fade( 'out' ).get( 'tween' ).chain( 
		
					function( ){ 
					
						var originalPrice 	= $( 'original_subTotal_' + item.get( 'rel' ) ).value;
						var itemPrice 		= $( 'item_' + item.id + '_' + item.get( 'rel' ) ).value;
					
						// recalculate the original pricing for the source item
						$( 'original_subTotal_' + item.get( 'rel' ) ).value = originalPrice - itemPrice;
						
						$( 'add_on_' + item.id ).destroy( );
						
						// recalculate the sub total
						parent.cartSubTotal( item.get( 'rel' ) );

					}.bind( item )
		
				);
				
			},
			onFailure:	function( ) {
				
				alert( 'Something went wrong... we couldn\'t remove the item from your cart!' );

			}
		}).send();
		
		event.stop( );
		
	});
						 
};

function addPromoCode( ){

	// remove any click events just in case
	$( 'add_promo_code' ).removeEvents( 'click' );
	
	// look for a click event
	$( 'add_promo_code' ).addEvent( 'click', function( event ) {
	
		var code = this;
	
		// process the promo code
		var myRequest = new Request({
							   
			method:		'get',
			url:			relative_path +'cart.html&ajax=add promo code&code=' + $( 'promotionalCode' ).value,
			onRequest: 	function ( ) {
				
				code.setAttribute( 'src', 'images/small_loader.gif' );
				
			},
			onSuccess:	function( html ) {
				
				// display the promo code value or the redo form
				$( 'promo_code' ).set( 'html', html );
				
				// reinstantiate all ajax calls
				initialize( );
				
			},
			onFailure:	function( ) {
				
				alert( 'Something went wrong... we couldn\'t add this promo code!' );

			}
		}).send();
	
	
		event.stop( );
	});
};

/*-- kris@o3world.com  apr 27 '10 --*/
function removePromoCode( ){

	// remove any click events just in case
	$( 'remove_promo_code' ).removeEvents( 'click' );
	
	// look for a click event
	$( 'remove_promo_code' ).addEvent( 'click', function( event ) {
	
		var code = this;

		// remove the promo code
		var myRequest = new Request({
							   
			method:		'get',
			url:			relative_path +'cart.html&ajax=remove promo code',
			onRequest: 	function ( ) {
				
				code.setAttribute( 'src', 'images/small_loader.gif' );
				
			},
			onSuccess:	function( html ) {
				
				// display the promo code value or the redo form
				$( 'promo_code' ).set( 'html', html );
				
				// reinstantiate all ajax calls
				initialize( );
				
			},
			onFailure:	function( ) {
				
				alert( 'Something went wrong... we couldn\'t remove the promo code!' );

			}
		}).send();
	
	
		event.stop( );
	});
};

/*-- kris@o3world.com  may 7 '10 --*/
function refreshPromoCode( ){
	var myRequest = new Request({
		method: 'get',
		url: relative_path +'cart.html&ajax=refresh promo code',
		onRequest: function ( ) { },
		onSuccess: function( html ) { $( 'promo_code' ).set('html',html); }
	}).send();
};

function cartSubTotal( item ){
	
	// reinstantiate just in case
	initialize( );
	
	var itemSubTotal = 0;

	if( $$( '.subTotal_' + item ) ){
		  
		$$( '.subTotal_' + item ).each( function( el ) {

			itemSubTotal = itemSubTotal + ( parseFloat( el.value ) * $( 'quantity_' + item ).value );

		});
		  
	};
	
	$( 'subTotal_label_' + item ).set( 'html', formatCurrency( itemSubTotal ) );

	// update the grandTotal as well
	cartGrandTotal( );
};

function cartGrandTotal( ){
	
	// reinstantiate just in case
	initialize( );

	var purchaseGrandTotal = 0;

	if( $$( '.grandTotal' ) ){
		  
		$$( '.grandTotal' ).each( function( el ) {

			purchaseGrandTotal = purchaseGrandTotal + parseFloat( el.get( 'html' ).replace( '$', '' ) );

		});
		  
	};
	
	if( $( 'delivery_grandTotal_label' ) ){
		
		// we need to update the delivery information
		$( 'delivery_grandTotal_label' ).set( 'html', formatCurrency( purchaseGrandTotal ) );
		
		// add the delivery charge to the grand total
		purchaseGrandTotal = purchaseGrandTotal + parseFloat( $( 'delivery_charge' ).get( 'html' ).replace( '$', '' ) );
																    
		// now update the grand total label
		$( 'grandTotal_label' ).set( 'html', formatCurrency( purchaseGrandTotal ) );											    
	
	} else {
		
		// just update the grand total
		$( 'grandTotal_label' ).set( 'html', formatCurrency( purchaseGrandTotal ) );
		
	};

};

function changeQuantity( ){

	// remove any click events just in case
	$$( '.item_quantity' ).removeEvents( 'change' );
	
	// look for a click event
	$$( '.item_quantity' ).addEvent( 'change', function( event ) {

		var itemID 		= this.id.replace( "quantity_", "" );
		var newSubTotal 	= parseFloat( $( 'original_subTotal_' + itemID ).value ) * this.value;

		$( 'subTotal_label_' + itemID ).set( 'html',  formatCurrency( newSubTotal ) );
		
		// recalculate the grand total
		cartGrandTotal( );
		
		event.stop( );
		
	});
						 
}

function resetNotification( ){

	// remove any click events just in case
	$$( '.reset' ).removeEvents( 'click' );
	
	// look for a click event
	$$( '.reset' ).addEvent( 'click', function( event ) {

		var clearCart = confirm( "If you change your zip code, date or any other purchase option, any existing items in your cart will be removed and you will need to start over.\n\n Do you want to continue?" );
		
		if( clearCart ){
		
			window.location.href = relative_path + 'clearCart.html&redirect=' + this.get( 'rel' );
		
		};
		
		event.stop( );
		
	});

};




// search validation
if( $( 'search_form' ) ){

	$( 'search_form' ).addEvent( 'submit', function( event ) {

		// validate there are search terms in the field
		if( $( 'keywords' ).value == '' || $( 'keywords' ).value == 'Search Products' || $( 'keywords' ).value == 'Enter Your Search Terms' ){
			
			// display notice
			$( 'keywords' ).addClass( 'error' );
			$( 'keywords' ).value = 'Enter Your Search Terms';
			
			event.stop( );
			
		} else {
		
			$( 'keywords' ).removeClass( 'error' );
			
			/*
			// ajaxisearch
			var myRequest = new Request({
								   
				method:		'post',
				url:			relative_path + 'products.html&ajax=search products',
				onRequest: 	function ( ) {
					
				},
				onComplete:	function( html ) {
	
					// set the new content
					$( 'content' ).set( 'html', html );
					
					// reinstantiate all clases
					initialize( );
	
				},
				onFailure: 	function( ){

					alert( 'Something went wrong... couldn\'t perform your search' );

				}
				
			}).send( $( 'search_form' ) );
			*/
		}
	
		/* event.stop( ); */
		
	});

};

function initialize( ){


/*-- kris@o3world.com  apr 20 '10  if we just completed an order, show '0 Items' in top nav --*/
	if($$('.step_4').length != 0) { $$('.cart')[0].innerHTML = "0 Items"; }


	if( $$( '.for' ).length ){

		swapLabels( );
		
	};
	
	if( $( 'zip' ) ){
		
		changeZip( );
		
		validateZip( );
		
	};
	
	if ( $( 'find' ) ) {
	
		quickFind( );
		
	};
	
	if( $$( '.paginate_products' ).length ){
		
		paginateProducts( );
		
	};
	
	if( $( 'product_sort' ) ){
		sortProducts( );
	};
	if( $( 'product_sort_2' ) ){
		sortProducts( true );
	};
	
	if( $$( '.edit_availability' ).length ){
		
		editAvailability( );
		
	};
	
	// calendar funcationality
	if ( $( 'find' ) || $( 'availability' ) ) {

		// kris@o3world.com  apr 16 '10  what day is it 90 days from now?
		var eDt = new Date(); eDt.setTime(eDt.getTime() + (90 * (24 * 60 * 60 * 1000)));

		// Date Picker
		var myCal = new Calendar({ date: 'm/d/Y' }, { blocked: dates, enddate: eDt, todaysdate: serverDateTime });
		
	};
	
	if( $( 'availability' ) ){
	
		checkAvailability( );
	
	};
	
	// PRODUCT DETAILS FUNCTIONS
	if ( $( 'product_details' ) ) {
	
		if( $$( '.add' ).length ) {
	
			addOnProduct( );
		
		};
		
		if( $$( '.remove_addon' ).length ) {
		
			removeAddOnProduct( );
		
		};
		
	};
	
	// CART FUNCTIONS
	if ( $( 'cart' ) ) {
		
		if( $$( '.remove_product' ).length ) {
		
			removeProductFromCart( );
		
		};
		
		if( $$( '.remove_addon' ).length ) {
		
			removeUpSellFromCart( );
		
		};
		
		if( $$( '.add' ).length ) {
	
			addUpSellToCart( );
		
		};
		
		if( $$( '.item_quantity' ).length ) {
	
			changeQuantity( );
		
		};
		
		if( $( 'add_promo_code' ) ){
		
			addPromoCode( );
			
		};

/*-- kris@o3world.com  apr 27 '10 --*/
		if( $( 'remove_promo_code' ) ){
			removePromoCode( );
		};

	};
	
	// RESET CART
	if( $$( '.reset' ).length ) {
	
		resetNotification( );
	
	};
	
	if ( typeof( Mediabox ) != "undefined" ){
		
		// look for any mediabox portions of the page
		Mediabox.scanPage( );
		
	};
	

};

window.addEvent( 'domready', function( ) {
	
	initialize( );
	
});
