var YM = {            
	layout: {
		init: function() { 
			// IE6 .png fix
			$('#header h1, #touts a, #sidebar .talking-point').supersleight({
				shim: '/images/blank.gif'
			});        
			
			
			// font replacement
			Cufon.replace('h1, h3, label, #sale h2');
			Cufon.replace('#tabs a, .caption', {
				hover: true
			});
			// get IE to behave
			Cufon.now();  
			
			// hide subnav
			var $subnav_yantraway = $('#nav li.yantra ul');
			var $subnav_using = $('#nav li.using ul');
			var $yantraway_link = $('#nav a.yantra');
			var $using_link = $('#nav a.use');

			
			$('#nav li.yantra').hoverIntent(function() {
				$subnav_yantraway.show();
			}, function() {
				$subnav_yantraway.hide();
			}); 
			
			$('#nav li.using').hoverIntent(function() {
				$subnav_using.show();
			}, function() {
				$subnav_using.hide();
			}); 
			
			// open links in new windows
			$('a.target-blank').click(function() {
				window.open(this.href);
				return false;
			});
			
			// get image buttons to have hover effect in IE6 
			if(typeof document.body.style.maxHeight === "undefined") {
				$('input.img-button').hover(function() {
					$(this).css('background-position', 'center left');
				}, function() {
					$(this).css('background-position', 'top left');
				});
			}
			
		}
	},
	
	index: {
		init: function() {
            YM.Shared.Nav.make_selected('home');

			// reset order confirmed cookie
			YM.Shared.Cookies.reset_order();

			// basic positions slideshow (not in IE6) 		
			if(typeof document.body.style.maxHeight === "undefined") {
				var truthy = true;
			} else {  
				
				var $pos_back = $('<img src="/images/hp_tout_pos1.jpg" alt="Basic Positions - Back" />');
				var $pos_sit = $('<img src="/images/hp_tout_pos3.jpg" alt="Basic Positions - Sitting" />');			
				var $pos_cheek = $('<img src="/images/hp_tout_pos4.jpg" alt="Basic Positions - Cheek" />');
				
			    $('#slideshow').append($pos_back, $pos_sit, $pos_cheek).cycle({
					fit: 1,
					delay: 6000,
					timeout: 8000
				});
			}
		}
	},
	
	yantra_way: {
		init: function() {   
			// reset order confirmed cookie
			YM.Shared.Cookies.reset_order();
						
			YM.Shared.Tabs.init();
		    YM.Shared.Nav.make_selected('yantra');
		
			$('#body-mind .enlarge a').lightBox(YM.Shared.Lightbox.options);
			$('#the-yantra .enlarge a').lightBox(YM.Shared.Lightbox.options);
		}
	}, 
	
	use: {
		init: function() { 
									
			YM.Shared.Tabs.init(); 
		    YM.Shared.Nav.make_selected('use');
		
			// reset order confirmed cookie
			YM.Shared.Cookies.reset_order();		
		    
			// hide buzz sidebar if on Buzz page
			var subpage = YM.Shared.Tabs.get_tab_path(location.pathname);
			if (subpage == 'testimonials') {
				$('#sidebar .buzz').hide();
			};			
		}
	},
	
	contact: {
		init: function() {      
		    YM.Shared.Nav.make_selected('contact');
		
			// reset order confirmed cookie
			YM.Shared.Cookies.reset_order();		
		
			// pre-populate textarea depending on topic dropdown
			var $topic_menu = $('#email-us select');
			var $textarea = $('#email-us textarea');
			
			$topic_menu.change(function() {
				var $topic = $('#email-us select option:selected');
				var prepopulate = "";
				switch($topic.val()) {
					case "Product Questions":
						break;
					case "Placing an Order":
						prepopulate = "Please include your full name and mailing address.";
					    break;
				    case "Shipping and Delivery":
						prepopulate = "Please include all that apply: 1) the ZIP/postal code we're shipping to; 2) when you placed your order; and 3) your order number.";
						break;
					case "Returns":
						prepopulate = "Please include your mailing address and all that apply: 1) the date you shipped the item; 2) the purchase date.";
						break;
					default:
						prepopulate = "Please include your mailing address and/or any other information that will help us answer your question.";
				}
				$textarea.val(prepopulate);        
			});          
		}                
	},               
	
	buy: {
		init: function() { 
			
		  YM.Shared.Nav.make_selected('buy');	   

			// reset order confirmed cookie
			YM.Shared.Cookies.reset_order();		   		
			
			// disable autocomplete attr in form to workaround FF selected radio button bug
			$('form').attr('autocomplete', 'off');
			
			// insert price display HTML
      // var $price_display = $('<h4 class="clear"></h4>');
      // $('.select-size').after($price_display);  
			                                        
      // // price callback function
      // function get_price_display(size) {
      //  $.get('/mat-prices', {size: size}, function(data, response) {
      //    if (response == 'success') {
      //      $price_display.text(data);
      //    };
      //  });
      // }
    	    
			// get initial price
			// TODO -- logic for making the initial price display the next highest size if lower sizes are out of stock
			// get_price_display('med'); 
			
			// enable price display change depending on size      		 
			$('input[name="size"]').click(function() {
				var size = $(this).val();  
				get_price_display(size);     				
			});
			
			// enable photo change depending on color
			var $mat_pic = $('#main-content.buy img');
			var $pic_link = $('#main-content.buy .enlarge a');
			$('input[name="color"]').click(function() {
				var color = $(this).val();
				var thumb_src, img_src;
				switch(color) {
					case 'green':
						thumb_src = "/images/buynow_mat_green.jpg";
						img_src = "/images/buynow_large_green.jpg";
						break;
					default:
						thumb_src = "/images/buynow_mat.jpg";
						img_src = "/images/buynow_large_purple.jpg";						
				}
				$mat_pic.attr('src', thumb_src);
				$pic_link.attr('href', img_src);
			});
			
			// lightbox
		   	$('#main-content.buy .enlarge a').lightBox(YM.Shared.Lightbox.options);
			
			// new get price for new catalog / display pages 5.14.2010
		  $('#catalog select').change(function() {
		    var $price_display = $(this).parent().parent().find('h4');
		    var size = $(this).val();
		    $.get('/mat-prices', {size: size}, function(data, response) {
					if (response == 'success') {
					  $price_display.text(data);
					  return false;
					} else {
					  return false;
					}
				});		    	    
		  });
		  
		  
		  // VERY kludgy way to 'disable' select options in IE6 & 7
		  // http://www.goodercode.com/wp/disable-select-options-internet-explorer-jquery/
		  // THIS MAY BREAK IF ALL VARIANTS ARE OUT OF STOCK!!!
		  $('option[disabled]').css({'color': '#999999'});
		  $('select').change(function() {
		    if (this.options[this.selectedIndex].disabled) {
		      if (this.options.length == 0) {
		        this.selectedIndex = -1;
		      } else {
		        this.selectedIndex--;
		      }
		      $(this).trigger('change');
		    }
		  });
		  $('select').each(function(index) {
		    if (this.options[this.selectedIndex].disabled) {
		      this.onchange();
		    };
		  });
		}
	},
	
	details: {
	  
	  init: function() {
	    
	    // price display changes with radio click event
			$('#catalog-details input[type="radio"]').click(function() {
		    var $price_display = $(this).parent().parent().parent().find('h4');
		    var size = $(this).val();
		    $.get('/mat-prices', {size: size}, function(data, response) {
					if (response == 'success') {
					  return $price_display.text(data);
					} else {
					  return false;
					}
				});
			});
			
	    // determine proper price display based on which radio button is clicked
	    var $initial_radio = $('#catalog-details input[type="radio"]:checked');
      // console.info($initial_radio);
	    $initial_radio.click();			
			
		 	// disable radio buttons for out of stock variants
			// each time the user selects a color radio button, make an AJAX request to determine which variants are in stock
			// for each variant that's out of stock, disable the radio buttons			
      // function check_availability(color) {
      //  $.getJSON('/in-stock', {color: color}, function(data, response) {
      //    if (response == "success") {
      //      $.each(data, function(index, value) {
      //        $('input[type="radio"][value="' + value[0] + '"]').attr('disabled', value[1]);
      //      });
      //    };
      //  });
      //  
      // }
      // var $color = $('input[type="hidden"]').val();
      // check_availability($color);      
	  }
	},
	
	cart: { 
		
		init: function() {
			// remove the JS message
			$('.js-required').hide();   
			
			// reset order confirmed cookie
			YM.Shared.Cookies.reset_order();	
		}, 
		
		items: function() {       		
			// set the shipping select menu at the proper rate
			var $shipping_select = $('#cart select[name="shipping"]');
			var get_random_number = function() {
				return Math.floor(Math.random() * 1000001);
			};    
			$.get('/get-shipping/' + get_random_number(), function(data) {
			   $shipping_select.val(data); 
			});			
			
			
			// modify shipping costs
			var $grand_total = $('#cart tr.total td.price strong'); 
			
			$shipping_select.change(function() {
				var shipping_id = $(this).val();
				$.post('/post-shipping', {shipping_id: shipping_id}, function(data) {
					$grand_total.text(data);
					get_coupon();
				});
			});
			
	 		// add proper checkout links  
			var $checkout_link = $('#actions a.checkout');
			$checkout_link.attr('href', '/checkout/start');
			var $ppe_link = $('#actions a.ppe');
			$ppe_link.attr('href', '/checkout/paypal-express');
			
			
			// get coupon data on load 
			var $coupon = $('input[name="coupon"]');
			var $coupon_row = $('#coupon-row');
			var $coupon_apply = $('input[name="apply-coupon"]');
			var $discount = $('#coupon-row .price');
			var $description = $('#coupon-row .description');
	 		var $coupon_code = $('#coupon-row span');
						
			var get_coupon = function() {
				$.getJSON('/coupon/' + get_random_number(), function(data) {
				   	$discount.text(data[0]);
					$description.text(data[1]);
					$coupon_code.text(data[2]); 
				});
			};
			get_coupon();
			
			
			// coupon AJAX call
			$coupon_apply.click(function() {
				var coupon_code = $.trim($coupon.val());     			
				var data = {code: coupon_code};
				$.post('/coupon', data, function(data) {
					clear_coupon(); 
					if (data[0]) {
					  	$discount.text(data[1]);
						$description.text(data[2]);
						$coupon_code.text(data[3]);  
					} else {
						$message = $('<span></span>').addClass('required')
						             .css({
										position: 'absolute',
										fontStyle: 'italic'
									}).text(data[1]);
						$coupon.after($message).css({
						   border: '1px dotted #f00' 
						});
						clear_coupon_row();
					};
					$shipping_select.change();
				}, 'json');
			});
			
			
			$coupon.focus(function() {
				clear_coupon();
			});
			
			var clear_coupon = function() {
				$('#coupon-code .required').remove();
				$coupon.css('border', '1px solid #fff');
			};
			
			var clear_coupon_row = function() {
				$discount.text('-$0.00');
				$description.text('n/a');
			};
			
			// gift logic
			// $gift_checkbox = $('input[name="send_as_gift"]');
			// $gift_area = $('#gift_area');
			// $gift_textarea = $('#gift_area textarea');
			// $gift_msg_button = $('#gift_area button');
			// $gift_row = $('#gift-row');
			// $gift_total = $('#gift-total');     
			
			// changed event from 'change' to 'click' for IE compat
			//  			$gift_checkbox.click(function() {
			//  				if ($(this).attr('checked')) {
			// 		$gift_area.show(); 		  
			// 		data = {gift: true};
			// 		post_gift(data, function() {
			// 			$gift_row.show();
			// 		});   
			// 	} else {
			// 		$gift_area.hide();
			// 		data = {gift: false};
			// 		post_gift(data, function() {
			// 			$gift_row.hide();
			// 		});
			// 	};
			//  			});
			// 
			// var get_gift = function() {
			// 	$.getJSON('/gift/' + get_random_number(), function(data) {
			// 		$gift_total.text(data);
			// 		if (data == '$0.00') {                   
			// 			$gift_checkbox.attr('checked', false);
			// 			$gift_area.hide();
			// 			$gift_row.hide();
			// 		} else { 
			// 			$gift_checkbox.attr('checked', true);
			// 			$gift_area.show();
			// 			$gift_row.show();
			// 		};
			// 	});				
			// };
			// get_gift();   
			
			// gift message 'validation'
			// $gift_textarea.textlimit('span.counter', 200);			
			// $gift_textarea.charCount({
			// 	allowed: 200
			// });   
			
						
			// var post_gift = function(data, callback) {
			// 	$.post('/gift', data, function(data) {
			// 	   	$shipping_select.change();
			// 	   	$gift_total.text(data[0]);
			// 	    get_gift();
			// 	  	callback();
			// 	});				
			// };
			// 
			// 		    var post_gift_msg = function(data) {
			// 	$.post('/gift-msg', data, function(data) {
			// 	});
			// 		    };          

			
			// gift msg autosave
			// $gift_textarea.typeWatch({
			// 	callback: function() {
			// 		// gift message validation
			// 		var text = $gift_textarea.val();
			// 		var regex = /^[a-z-!;:?.,()'\"\s\d]+$/i;
			// 		if (!text.match(regex)) {
			// 			$('label.error').remove();  
			// 			var error_label = $('<label class="error">Only letters, numbers, spaces and standard punctuation, please.</label>');
			// 			$('span.counter').after(error_label);
			// 			$gift_textarea.addClass('error');
			// 		} else {
			// 			$('label.error').remove();
			// 			$gift_textarea.removeClass('error');
			// 			var data = {gift_msg: $gift_textarea.val()};
			// 			post_gift_msg(data);
			// 		}
			// 		return false;
			// 	}
			// });  
		}
	},
	
	checkout_address: {
		init: function() { 
			// check if order confirmed
			YM.Shared.Cookies.order_confirmed();			
			
			// copy billing address to shipping address
			var $billing_shipping = $('input[name="billing_shipping"]');
			$billing_shipping.click(function() {
				if ($(this).is(':checked')) { 
					$('input[name*="shipping_"]').each(function(index) { 
						var name = $(this).attr('name');
						var billing_name = name.replace('shipping_', 'billing_');  
						var billing_val = $('input[name="' + billing_name + '"]').val();
						$(this).val(billing_val);
					});
					$('select[name*="shipping_"]').each(function(index) { 
						var name = $(this).attr('name');
						var billing_name = name.replace('shipping_', 'billing_');  
						var billing_val = $('select[name="' + billing_name + '"]').val();
						$(this).val(billing_val);
					});
	
					validate_address_form();
  
				} else {
					$('input[name*="shipping_"]').each(function(index) {
						$(this).val("");
					});
					$('select[name*="shipping_"]').each(function(index) {
						$(this).val("");
					});
				}
			});
			
			// handle sticky address form fields
			var $address_submit = $('input[type="submit"]');
			var $text_inputs = $('input[type="text"]');
			var $selects = $('select');			
                           
			$address_submit.click(function() {
				$text_inputs.each(function(index) {
					$(this).cookify();
				});
				$selects.each(function(index) {
					$(this).cookify();
				});
			});
			
			if ($.cookies.get()) {
				$text_inputs.each(function(index) {
					$(this).cookieFill();
				});
				$selects.each(function(index) {
					$(this).cookieFill();
				});
			};     
			
			// validate the address form
			jQuery.validator.addMethod("postalcode", function(postalcode, element) {
			// 	return this.optional(element) || postalcode.match(/(^\d{5}(-\d{4})?$)|(^[ABCEGHJKLMNPRSTVXYabceghjklmnpstvxy]{1}\d{1}[A-Za-z]{1} ?\d{1}[A-Za-z]{1}\d{1})$/);
			// }, "Please specify a valid zip code.");
				return this.optional(element) || postalcode.match(/(^\d{5}(-\d{4})?$)/);
			}, "Please specify a valid zip code."); 
			
			jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
			    phone_number = phone_number.replace(/\s+/g, ""); 
				return this.optional(element) || phone_number.length > 9 &&
					phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})[-.]?[2-9]\d{2}[-.]?\d{4}$/);
			}, "Please specify a valid phone number.");
			
			jQuery.validator.addMethod("AK_HI", function(state, element) {
				return this.optional(element) || !state.match(/^AK|HI$/);
			}, "Please call (508) 403-0505 for sales to Alaska or Hawaii.");
			
			
			function validate_address_form() { 
				$('#checkout').validate({
					rules: {
						'customer[billing_first_name]': {
							required: true,
							maxlength: 40
						},
						'customer[billing_last_name]': {
							required: true,
							maxlength: 40						
						},
						'customer[billing_address_1]': {
							required: true,
							maxlength: 40						
						},
						'customer[billing_city]': {
							required: true,
							maxlength: 40						
						},
						'customer[billing_state]': {
							required: true,
							AK_HI: true					
						},
						'customer[billing_zip]': {
							required: true,
							maxlength: 10,
							postalcode: true  					
						},
						'customer[billing_country]': {
							required: true						
						},
						'customer[billing_phone]': {
							required: true,
							maxlength: 20,
							phoneUS: true						
						},
						'customer[email]': {
	 						required: true,
							maxlength: 255,
							email: true   					
						},
						'customer[shipping_first_name]': {
							required: true,
							maxlength: 40						
						},
						'customer[shipping_last_name]': {
							required: true,
							maxlength: 40						
						},
						'customer[shipping_address_1]': {
							required: true,
							maxlength: 40						
						},
						'customer[shipping_city]': {
							required: true,
							maxlength: 40						
						},
						'customer[shipping_state]': {
							required: true,
							AK_HI: true				
						},
						'customer[shipping_zip]': {
							required: true,
							maxlength: 10,
							postalcode: true 					
						},
						'customer[shipping_country]': {
							required: true 					
						},
						'customer[shipping_phone]': {
							required: true,
							maxlength: 20,
							phoneUS: true						
						}					
					},
					messages: {
						'customer[billing_first_name]': {
							required: "Please enter your first name."         
						},
						'customer[billing_last_name]': {
							required: "Please enter your last name."         						
						},
						'customer[billing_address_1]': {
							required: "Please enter your billing street address." 
						},
						'customer[billing_city]': {
							required: "Please enter your billing city."  						
						},
						'customer[billing_state]': {
							required: "Please enter your billing state or province."
						},
						'customer[billing_zip]': {
							required: "Please enter your billing zip code."
						},
						'customer[billing_country]': {
							required: "Please enter your billing city."  						
						},
						'customer[billing_phone]': {
							required: "Please enter your billing phone number."
						},
						'customer[email]': {
							required: "Please enter your email address.",
							email: "Please enter a valid email address."
						},
						'customer[shipping_first_name]': {
							required: "Please enter the shipping first name."   						
						},
						'customer[shipping_last_name]': {
							required: "Please enter the shipping last name."
						},
						'customer[shipping_address_1]': {
							required: "Please enter the shipping street address."
						},
						'customer[shipping_city]': {
							required: "Please enter the shipping city."
						},
						'customer[shipping_state]': {
							required: "Please enter the shipping state or province."
						},
						'customer[shipping_zip]': {
							required: "Please enter the shipping zip code."
						},
						'customer[shipping_country]': {
							required: "Please enter the shipping country."
						},
						'customer[shipping_phone]': {
							required: "Please enter the shipping phone number."
						}					                                     
					}
				});   			
			}
			validate_address_form();		   
		}
	},
	
	checkout_pay: {
		init: function() { 
			// check if order confirmed
			YM.Shared.Cookies.order_confirmed();
			
			
			// CVV2 popup
			var $cvv = $('#cvv');
			// var $cvv_html = '<p>The <span>Card Verification Number</span> is a 3 or 4 digit code found on your credit card. We are requesting it as an added security precaution.</p><img src="/images/cc_logos/ccv2-275x108px.jpg" alt="CCV2"/>';
			// $cvv.bt($cvv_html, { 
			// 	fill: '#fff',
			// 	positions: 'right',
			// 	shadow: true,
			// 	shadowBlur: 8,
			// 	strokeStyle: '#999',
			// 	width: '275px'
			// });   
			$cvv.click(function() {
				return false;
			});

			// credit card info animation  
			// COMMENTED OUT FOR NO_PPE BRANCH!!!
			var $cc_radio = $('#checkout .paypal-cc input[value="credit_card"]');
			var $pp_radio = $('#checkout .paypal-cc input[value="paypal"]');
			var $payment_radios = $('#checkout .paypal-cc input[name="payment_method"]'); 
			var $cc_info = $('#checkout #credit-card-info');
			var $ppe = $('#checkout #place-order a.ppe');
			var $cc_submit = $('#checkout #place-order .img-button');
			// if ($cc_radio.is(':checked')) {
			// 	$cc_info.show();
			// 	$cc_submit.show();
			// } else {
			// 	$ppe.show();
			// };   
			$payment_radios.click(function() {
				if ($cc_radio.is(':checked')) {
					$cc_info.show();
					$cc_submit.show();
					$ppe.hide();
				} else {
					$cc_info.hide();
					$cc_submit.hide();
					$ppe.show();
				};
			});   
			
			// validate form
			$('#checkout').validate({
				rules: {
					// payment_option: {
					// 	required: true
					// },    
					'cc[type]': {
						required: true
					},
					'cc[number]': {
						required: true,
						// creditcard: true 
						creditcard2: function() {
							// cc type values for creditcard2 rule must be: amex, discover, mastercard, visa
							cc_type = $('select[name="cc[type]"]').val();
							mapped_cc_type = cc_type;
							if (cc_type == 'american_express') {
								mapped_cc_type = 'amex';
							};                          
							if (cc_type == 'master') {
								mapped_cc_type = 'mastercard';
							};  
							return mapped_cc_type; 
						}            
					},
					'cc[verification_value]': {
						required: true,
						digits: true,
						rangelength: [3, 4]
					},
					'cc[month]': {
						required: true
					},
					'cc[year]': {
						required: true
					}
				},
				messages: {
					// payment_option: {
					// 	required: "Please select a payment option."
					// },   
					'cc[type]': {
						required: "Please choose your credit card issuer."
					},
					'cc[number]': {
						required: "Please enter your credit card number.",
						creditcard2: "Please enter a valid credit card number."
					},
					'cc[verification_value]': {
						required: "Please enter your card verification value.",
						digits: "Your card verification value must only consist of digits.",
						rangelength: "Your card verification value can be only 3 or 4 digits."
					},
					'cc[month]': {
						required: "Please select the date your card expires."
					},
					'cc[year]': {
						required: "Please select the date your card expires."
					}
				}
			});
			
			var creditcard2_counter = 0;
			
			$('select[name="cc[type]"]').change(function() { 
				if (creditcard2_counter > 0) {
					$('#checkout').validate().element('input[name="cc[number]"]');					
				};
				creditcard2_counter += 1;
			});   
		}
	},
		
	ppe_checkout_pay: {
		
		init: function() {
			// check if order confirmed
			YM.Shared.Cookies.order_confirmed();			
		}
	},
	
	order_confirmation: {
		
		init: function() {
			$.cookies.set('order_confirmed', 'true');
		}
	},
	
	admin: {
		general: {
			init: function() {
				$('input[name$="date]"]').datepicker({
					dateFormat: 'yy-mm-dd'
				});
				
				// zebra stripe
				$('tr:odd').addClass('striped');
			}
		},
		
		coupons: {
        	init: function() {}
		},
		
		press: {
			init: function() {},
      
      index: function() {
        $('table').tableDnD({
          onDragStart: function(table, row) {
            $(row).removeClass('striped');
          },
          onDrop: function(table, row) {
            // restripe the rows
            $('tr').removeClass('striped');
            $('tr:odd').addClass('striped');
            // get the entry id
            var pm_id = $(row).find('input[name="id"]').val();
            // determine the new position
            var new_pm_index = $('table tr').index(row);
            // send AJAX request updating order
            $.post('/admin/press-mentions/order', {id: pm_id, position: new_pm_index}, function(data, textStatus, xhr) {
              // optional stuff to return
            });
            
          }
        });
      }
		},
		
		shipping: {
			init: function() {}
		}
	},
	
	Shared: {
		
		Tabs: {
			init: function() {
				var $tabs = $('#tabs li a');
				var $container = $('.tabs');
				var $divs = $('.tabs > div');
				var subpage = YM.Shared.Tabs.get_tab_path(location.pathname);

				// logic for hiding/showing divs
				$divs.hide();
        if (subpage) {
	        $('#' + subpage).show();
				} else {
					$divs.eq(0).show(); 
				}; 
				
				// logic for selecting/unselecting navs 
				make_selected = function(href) {      
					$tabs.removeClass('selected');
					if (href) {
						$tabs.filter('[href*=' + href + ']').addClass('selected');   	
					} else {
						$tabs.eq(0).addClass('selected');
					};
				};
				make_selected(subpage);
		  
			},
			
			get_tab_path: function(pathname) {
			   	var tab_regex = /^.+\/(.+)$/;
				var path_match = pathname.match(tab_regex);
				if (path_match) {
					return path_match[1];
				}
				return false; 
			}
		},
		
		Nav: {
			make_selected: function(page) {
				$('#nav li a').removeClass('selected');
				// ie6 workaround
				$('#nav li a').each(function(i) {
				   $(this).get(0).className == $(this).get(0).className.replace(/\b\w+_selected\b/g, '');
				});
				$('#nav li a.' + page).addClass('selected').addClass(page + '_selected');
			}
		},
		
		Lightbox: {
			options: {
				imageLoading: '/images/lightbox/lightbox-ico-loading.gif',
				imageBtnClose: '/images/lightbox/lightbox-btn-close.gif',
				imageBtnPrev: '/images/lightbox/lightbox-btn-prev.gif',
				imageBtnNext: '/images/lightbox/lightbox-btn-next.gif'
			}
		},
		
		Cookies: {
			order_confirmed: function() {
				// check if order confirmed
				if ($.cookies.get('order_confirmed')) {
					var base_url = location.host;
					window.location = "http://" + base_url + "/sorry";
				};
			},
			
			reset_order: function() {
				if ($.cookies.get('order_confirmed')) {
					$.cookies.del('order_confirmed');
				};
			}
		}
	}
};
