function gotoAnchor() {
   window.location.href="#simple_solutions";
}

$(document).ready(function() {
	
	//clear inputs on search form
	
	$("#keywords").focus(function(){
        if($(this).val() == $(this).attr('defaultValue')){
            $(this).val('');
        }
    });

    $("#keywords").blur(function(){
        if($(this).val() == ''){
            $(this).val($(this).attr('defaultValue'));
        }
    });

	// target = blank faking
	$('#find_a_store').addClass("external").attr("target","_blank").attr("title","Opens in a new window");

	//same page scrolling
	$('#pagelinks li a').smoothScroll();
	
	//$('#ing_list div.ing').css('height', '42px').toggle(function() {
	//	var high = $(this).find('p').css('height');
	//	$(this).animate({height: high}, 400);
	//}, function() {
	//	$(this).animate({height: '42px'}, 400);
	//});
	//;

	//flash detection for html nav
	
	if (swfobject.getFlashPlayerVersion().major == 0) { //if no flash player found
		$('html').addClass('noflash');	
		};
		
	//uses jquery tools tab function + nested tabs
		
	$("#prod_tabs").tabs("div.prod_panes > div");
	
	$("#cl_tip_cats").tabs("div.tip_panes > div");
	
	$("ul.pagination").tabs("> div.nested");
		
	//tooltip on list items - replaced this with qtip 
	$("ul.science li[title]").hover(function() {
		$(this).css('cursor', 'pointer');
	}, function() {
		$(this).css('cursor', 'default');
	}).qtip( { style: { 
							name: 'dark', 
							tip: true
						},
					 position: {
					      corner: {
					         target: 'topLeft',
					         tooltip: 'bottomRight'
					      }
					   }
				
				}); 
	
	
	$(".rating").rating({showCancel: false, cancelValue: null});
	
	// onHide : fade the window out, remove overlay after fade.
	
	var myClose=function(hash) {hash.w.fadeOut('1200',function(){ hash.o.remove(); }); };
	var myOpen=function(hash){ hash.w.fadeIn('1200'); };
	$('#dialog').jqm({onShow:myOpen});
	
	// freeclear - tangerine thyme show/hide

	//if ($.browser.safari) { //needs to happen onload for webkit browsers
		
	//		$('#p_img_1').load(function() { 
	//			hi = $(this).height();
	//			hi = String(hi)+"px";
	//			$('#sample_product').height(hi);
	//		});
		
	//} else {
		
	//	hi = $('#p_img_1').height();
	//	hi = String(hi)+"px";
	//	$('#sample_product').height(hi);
	//	
	//};	
	
	$('#tangarine').click(function() {
		$('#p_img_1').fadeOut('fast');
		$('#p_img_2').fadeIn('fast');
	});
	
	$('#free_and_clear').click(function() {
		$('#p_img_2').fadeOut('fast');
		$('#p_img_1').fadeIn('fast');
	});
	
	$('#form_1886').click(function() {
		$('#p_img_1').fadeOut('fast');
		$('#p_img_2').fadeIn('fast');
	});
	
	$('#five_simple_ingredients').click(function() {
		$('#p_img_2').fadeOut('fast');
		$('#p_img_1').fadeIn('fast');
	});
	

	// call, show & hide chick rating box without use of the modal script, already too much going on there
	
	$('a.ratingtrigger').click(function() {		
		the_id = $(this).attr('rel');
		the_ref = $(this).attr('href');
		result = "result_"+the_id;
		the_id = "#" + the_id;
		result = "#" + result;
		$(result).load(the_ref);
		return false;
	});

	
	$('#tip_rate_close').live('click', function(event) { //live because rating box is called in via ajax
		$(this).parent().remove();
		return false;
	});
	
	//basic slideshow for the press cover pages
	$("body.press #thumbs li a").click(function() {
			var largePath = $(this).attr("href");
			$("#gallery img:first").attr({src: largePath});
			return false;
		});
		
	
	$('#login_link').hover(function() {
		$(this).css('color', '#CC0B19');
	}, function() {
		$(this).css('color', '#0000EE');
	});
	
	$('#welcome_pop ul li a img').hover(function() {
		$(this).css('opacity', '0.7');
	}, function() {
		$(this).css('opacity', '1');
	});
	
	//login pane weirdness
	
	$('#login_link').css({color: '#cccccc', textDecoration: 'none'});
	
	//remove border from every-third cleaning tip - jQuery the duct tape of the internet!
	$('#cleaningtips div.nested div.tipcontent:nth-child(3)').css('border', '0');
	
	//modal windows
	
	$("#login_link").overlay({ 
				expose: { 
				        color: '#a6938e', 
				        loadSpeed: 25, 
				        opacity: 0.8,
						zIndex: 1000,
						close: $("#login_window a.close")
				    },
		    color: '#eeeeee', 
		    top: 74,
			left: 10,
			speed: 200,
			closeOnClick: false
		});
		
		$("#submit_a_review").overlay({ 
					expose: { 
					        color: '#a6938e', 
					        loadSpeed: 25, 
					        opacity: 0.8,
							zIndex: 1000
					    },
			    color: '#eeeeee', 
			    top: 74,
				left: 10,
				speed: 200,
				closeOnClick: false
			});
			
			$("#win_new a[rel]").overlay({ 
						expose: { 
						        color: '#a6938e', 
						        loadSpeed: 25, 
						        opacity: 0.8,
								zIndex: 1000
						    },
				    color: '#eeeeee', 
				    top: 0,
					left: 10,
					speed: 200,
					closeOnClick: false
				});
				
				$("#trigger_popup").overlay({ 
							expose: { 
							        color: '#a6938e', 
							        loadSpeed: 25, 
							        opacity: 0.8,
									zIndex: 1000
							    },
					    color: '#eeeeee', 
					    top: 74,
						left: 10,
						speed: 200,
						closeOnClick: false
					});
				
				$("#submit_a_profile").overlay({ 
							expose: { 
							        color: '#a6938e', 
							        loadSpeed: 25, 
							        opacity: 0.8,
									zIndex: 1000
							    },
					    color: '#eeeeee', 
					    top: 74,
						left: 10,
						speed: 200,
						closeOnClick: false
					});
					
					$("#submit_a_tip").overlay({ 
								expose: { 
								        color: '#a6938e', 
								        loadSpeed: 25, 
								        opacity: 0.8,
										zIndex: 1000
								    },
						    color: '#eeeeee', 
						    top: 74,
							left: 10,
							speed: 200,
							closeOnClick: false
						});
						
						$("#purchase_online").overlay({ 
									expose: { 
									        color: '#a6938e', 
									        loadSpeed: 25, 
									        opacity: 0.8,
											zIndex: 1000
									    },
							    color: '#eeeeee', 
							    top: 74,
								left: 10,
								speed: 200,
								closeOnClick: false
							});
});


