$(document).ready(function(){
	OBSHome = function(){
		return{
			init: function(){
				// "constants" for use by jQuery to find dom elements
				var __SHOE_CLASS__ 		= "product_image";
				var __SHOES__ 			= "." + __SHOE_CLASS__;
				
				var __PURSE_CLASS__ 	= "product_image_solo";
				var __PURSES__ 			= "." + __PURSE_CLASS__;

				var __TREND_ID__		= "trend_block";
				var __TREND__			= "#" + __TREND_ID__;
				
				var __REWARD_ID__		= "reward_block";
				var __REWARD__			= "#" + __REWARD_ID__;
				
				var __BANNER_ID__		= "banner_block";
				var __BANNER__			= "#" + __BANNER_ID__;
				
				var __ALL_PRODUCTS__ 	= __SHOES__ + "," + __PURSES__ + "," + __TREND__ + "," + __REWARD__ + "," + __BANNER__;				
				var __ALL_ROLLOVERS__ 	= __SHOES__ + "," + __TREND__ + "," + __REWARD__ + "," + __BANNER__ + "," + ".banner";
				
				
				
			    // rollovers are for everything except purses
				$(__ALL_ROLLOVERS__).hover(
					function(){
						$($(this).children()[0]).addClass('hidden');
					},
					
					function(){
					    if(!$(this).attr("current")){
   							$($(this).children()[0]).removeClass('hidden');						      
					    };							
					}
				);

				
				// handle the product clicks, leaving the highlight on the clicked item
				// and removing the highlight state from the previously clicked one
				$(__ALL_PRODUCTS__).click(function(){

				    // if it's a trend, show_trends
					if($(this).attr("id") == __REWARD_ID__){
						show_rewards($(this).attr("delay"));
					// if it's a reward, show_rewards
					} else if($(this).attr("id") == __TREND_ID__){
						show_trends($(this).attr("video"));
					// if it's a banner, link
					} else if($(this).attr("id") == __BANNER_ID__){
						location.href="/giftcards";
					} else {
						// if it's a shoe or a purse, call shoe_products
					    show_products($(this).attr("delay"), $(this).attr("params"));												
					}

				    // turn off rollovers
				    $(__ALL_ROLLOVERS__).each(function(){
				        $($(this).children()[0]).removeClass('hidden');							
                        $(this).removeAttr("current");
				    });
				    
				    // turn this on
					if(!$(this).hasClass(__PURSE_CLASS__)){
						$($(this).children()[0]).addClass('hidden');						
	                    $(this).attr("current", "true");
					};
				});
				
				
			}
		}
	}();
	OBSHome.init();
});
