/**
 * Contains ajax button events
 */
var ButtonRules = {

	/**
	 * Parameters
	 */
	productUrl : '/',
	hashToTrigger : "#order",
		
	/**
	 * Applies required events to ajax button
	 */
	apply : function () {
		var body = $$('body')[0];
		var button = $('ajax_button');

		// review-product-list
		if(body.hasClassName('review-product-list')) {
			// Attach redirection to product page
			button.observe('click', function () {
				document.location.href = ButtonRules.productUrl + ButtonRules.hashToTrigger;
			});
		}
		
		// catalog-product-view
		if(body.hasClassName('catalog-product-view')) {
			// Trigger if required
			if(document.location.hash == ButtonRules.hashToTrigger) {
				ButtonRules.play();
			}

			// Attach event
			button.observe('click', function () {
				ButtonRules.play();
			});
		}	
	},
	
	/**
	 * Plays animation
	 */
	play : function () {
		Effect.toggle('options_glasses', 'appear',  { duration: 0 });
		Effect.toggle('ajax_button', 'appear', { duration: 0 });
		Effect.ScrollTo('lnk_product', { duration: 0.8 });
	}
}
