
	//================================//
	// GLOBAL
	//--------------------------------//
	
	$().ready(function() {

		if(typeof sIFR == "function") { 
			sIFR.replaceElement(named({sSelector:"h4.grey_box_title", sFlashSrc:"/swf/avenir.swf", sColor:"#ffffff", sWmode:"transparent"}));
			sIFR.replaceElement(named({sSelector:"h4.white_box_title", sFlashSrc:"/swf/avenir.swf", sColor:"#666666", sWmode:"transparent"}));
			sIFR.replaceElement(named({sSelector:"h4.content_box_title", sFlashSrc:"/swf/avenir.swf", sColor:"#666666", sWmode:"transparent"}));
			sIFR.replaceElement(named({sSelector:"h4.top_content_box_title", sFlashSrc:"/swf/avenir.swf", sColor:"#666666", sWmode:"transparent"}));
			sIFR.replaceElement(named({sSelector:"h4.bottom_content_box_title", sFlashSrc:"/swf/avenir.swf", sColor:"#666666", sWmode:"transparent"}));
		}
		$("div#footer ul li:last").css("border","none");
		if($.browser.safari) {
			setTimeout("update_box_heights()",300);
		} else {
			update_box_heights();
			setTimeout("update_box_heights()",2000);
		}
		$("div#header div.account div.default a.log_in").click(function() {
			$("div#header div.account div.login_popup").css({top:"4px",right:"-6px"}).fadeIn(400);
			return false;																
		});
		$("div#header div.account div.login_popup a.close").click(function() {
			$("div#header div.account div.login_popup").fadeOut(400);
			return false;																
		});
		$("div#header div.login_popup a.log_in").click(function() {
			document.login_form.submit();
			return false;														
		});
		$("div.rules a").click(function() {
			$("div.rules_popup").fadeIn(400);
			return false;
		});
		$("div.rules_popup a.close").click(function() {
			$("div.rules_popup").fadeOut(400);
			return false;
		});
	});
	
	function update_box_heights() {
		// GREY BOX
		$("div.grey_box ul.styles li.tm").each(function() { $(this).css("width",parseFloat($(this).parent().parent().width()-12)); });
		$("div.grey_box ul.styles li.l").each(function() { $(this).css("height",parseFloat($(this).parent().parent().height()-50)); });
		$("div.grey_box ul.styles li.r").each(function() { $(this).css("height",parseFloat($(this).parent().parent().height()-50)); });
		$("div.grey_box ul.styles li.bm").each(function() { $(this).css("width",parseFloat($(this).parent().parent().width()-12)); });
		// WHITE BOX
		$("div.white_box ul.styles li.tm").each(function() { $(this).css("width",parseFloat($(this).parent().parent().width()-12)); });
		$("div.white_box ul.styles li.l").each(function() { $(this).css("height",parseFloat($(this).parent().parent().height()-30)); });
		$("div.white_box ul.styles li.r").each(function() { $(this).css("height",parseFloat($(this).parent().parent().height()-30)); });
		$("div.white_box ul.styles li.bm").each(function() { $(this).css("width",parseFloat($(this).parent().parent().width()-12)); });
		// CONTENT BOX
		$("div.content_box ul.styles li.tm").each(function() { $(this).css("width",parseFloat($(this).parent().parent().width()-362)); });
		$("div.content_box ul.styles li.l").each(function() { $(this).css("height",parseFloat($(this).parent().parent().height()-234)); });
		$("div.content_box ul.styles li.r").each(function() { $(this).css("height",parseFloat($(this).parent().parent().height()-234)); });
		$("div.content_box ul.styles li.bm").each(function() { $(this).css("width",parseFloat($(this).parent().parent().width()-362)); });
		// TOP CONTENT BOX
		$("div.top_content_box ul.styles li.tm").each(function() { $(this).css("width",parseFloat($(this).parent().parent().width()-362)); });
		$("div.top_content_box ul.styles li.l").each(function() { $(this).css("height",parseFloat($(this).parent().parent().height()-117)); });
		$("div.top_content_box ul.styles li.r").each(function() { $(this).css("height",parseFloat($(this).parent().parent().height()-117)); });
		$("div.top_content_box ul.styles li.bm").each(function() { $(this).css("width",parseFloat($(this).parent().parent().width()-12)); });
		// BOTTOM CONTENT BOX
		$("div.bottom_content_box ul.styles li.tm").each(function() { $(this).css("width",parseFloat($(this).parent().parent().width()-12)); });
		$("div.bottom_content_box ul.styles li.l").each(function() { $(this).css("height",parseFloat($(this).parent().parent().height()-117)); });
		$("div.bottom_content_box ul.styles li.r").each(function() { $(this).css("height",parseFloat($(this).parent().parent().height()-117)); });
		$("div.bottom_content_box ul.styles li.bm").each(function() { $(this).css("width",parseFloat($(this).parent().parent().width()-362)); });		
	}
	
	//================================//
	// SHOP THE COLLECTION
	//--------------------------------//
	
	$().ready(function() {
		
		$("div#exclusively_available_at div ul li:last").css("background","none");
		$("div#exclusively_available_at div ul li div.popup a").click(function() {
			if($(this).parent().find("p").is(":hidden")) {
				$(this).parent().find("p").css("opacity","0.8").slideDown(300);
				$(this).css("background-position","0 -16px");
			} else {
				$(this).parent().find("p").stop().slideUp(100);
				$(this).css("background-position","0 0");
			}
			return false;
		});
		
	});

	//================================//
	// WHAT IS RIGHT FIT
	//--------------------------------//

	var version = parseInt(jQuery.browser.version);
	$().ready(function() {
		$("div.the_problem a.next").stop().click(function() {
			$("div.slides").animate({left:"-909px"},700,"easeInOutExpo",function() {
				if(!$.browser.msie||(version>=7)) {
					thisMovie("whatIsFlash").init();
				}
			});
			$("ul.position li.active").removeClass("active");
			$("ul.position li#pos_the_study").addClass("active");
			return false;
		});
		$("div.the_study a.previous").stop().click(function() {
			$("div.slides").animate({left:"0"},700,"easeInOutExpo");
			if(!$.browser.msie||(version>=7)) {
				thisMovie("whatIsFlash").pause();
			}
			$("ul.position li.active").removeClass("active");
			$("ul.position li#pos_the_problem").addClass("active");
			return false;
		});
		$("div.the_study a.next").stop().click(function() {
			$("div.slides").animate({left:"-1818px"},700,"easeInOutExpo");
			if(!$.browser.msie||(version>=7)) {
				thisMovie("whatIsFlash").pause();
			}
			$("ul.position li.active").removeClass("active");
			$("ul.position li#pos_the_results").addClass("active");
			return false;
		});
		$("div.the_results a.previous").stop().click(function() {
			$("div.slides").animate({left:"-909px"},700,"easeInOutExpo");
			$("ul.position li.active").removeClass("active");
			$("ul.position li#pos_the_study").addClass("active");
			return false;
		});
	});

	//================================//
	// WHAT PEOPLE ARE SAYING
	//--------------------------------//
	
	var active_photo = null;
	$().ready(function() {
		$("div#watnat ul.photos li").css("margin","0 3px 3px 0");
		$("div#watnat ul.photo_overlays li").css("margin","0 3px 3px 0");
		var photos = $("div#watnat ul.photos li");
		var overlays = $("div#watnat ul.photo_overlays li");
		for(var i=0;i<24;i++) {
			if((i%6)==5) $(photos[i]).css("margin-right","0px");
			if((i%6)==5) $(overlays[i]).css("margin-right","0px");
			if(i>17) $(photos[i]).css("margin-bottom","0px");
			if(i>17) $(overlays[i]).css("margin-bottom","0px");
		}
		$("div#watnat ul.photo_overlays li a").hover(function() {
			var photo_id = get_id($(this).parent().attr("id"));
			active_photo = $("div#watnat ul.photos li img#image_"+photo_id).parent();
			setTimeout("set_talkbox()",50);
		},function() {
			active_photo = null;
			setTimeout("set_talkbox()",50);
		});
		$("div#fm div ul li:last").css("background","none");
		$("div.bottom_content_box_nav ul li:last").css("border","none");
		$("div#featured_question div ul li:last").css("margin-right","0");
		$("div#watnat_overlay").css("opacity","0");
	});
	
	function set_talkbox() {
		if(active_photo==null) {
			unset_photo();
			hide_overlay();
		} else {
			set_photo();
			show_overlay();
			switch_talkbox();
		}
	}
	
	function unset_photo() {
		$("div#watnat ul.photos li#active_photo").removeAttr("id").find("div").remove();
	}
	
	function set_photo() {
		unset_photo();
		$(active_photo).attr("id","active_photo").append($("<div></div>"));
	}
	
	function switch_talkbox() {
		$("div.talk_box div.content").css("display","none");
		$("div.talk_box div#talk_content_"+get_id($(active_photo).find("img").attr("id"))).css("display","block");
	}
	
	function hide_overlay() {
		if($("div#watnat_overlay").is(":visible")) {
			$("div#watnat_overlay").stop().animate({opacity:"0"},500,function() {
				$(this).css("display","none");														   
			});
		}
	}
	
	function show_overlay() {
		var hex_color = null;
		if($(active_photo).attr("class")=="blue") {
			hex_color = "#00a4e7";
		} else if($(active_photo).attr("class")=="red") {
			hex_color = "#f43769";
		} else {
			hex_color = "#eec915";
		}
		$("div#watnat_overlay").css("display","block").stop().animate({backgroundColor:hex_color,opacity:"0.5"},500);
	}

	//================================//
	// ACCOUNT - PROFILE / SIGNUP
	//--------------------------------//
	$().ready(function() {
		$("input#custom_image").click(function() {
			if($(this).is(":checked")) {
				$("div.custom_image").css("display","block");
				$("div.avatar").css("display","none");	
			} else {
				$("div.custom_image").css("display","none");
				$("div.avatar").css("display","block");	
			}
		});
		$("div.my_right_fit_color ul li a").click(function() {
			$("div.my_right_fit_color ul li input:checked").removeAttr("checked");
			$(this).parent().find("input").attr("checked","checked");
			return false;												   
		});
		$("div#rf_mania div.right ul li a").click(function() {
			$("div.my_right_fit_color ul li input:checked").removeAttr("checked");
			$(this).parent().find("input").attr("checked","checked");
			return false;												   
		});
		$("div.avatar a").click(function() {
			$("div.avatar img.selected").removeClass("selected");
			$(this).find("img").addClass("selected");
			$("input#avatar").val($(this).attr("class"));
			return false;
		});
	});

	
	