$(document).ready(function() {
	$('.inner_box').each(function() {
		$(this).parent().children('h2').wrapInner('<a href="javascript:;" />');
		if (!$(this).parent().hasClass('box_login') && !$(this).hasClass('inner_box_logged_in') && !$(this).parent().hasClass('box_news') && $(this).find('.cartheader_small').length<1) {
			$(this).hide();
		}
	});
	$('.modules h2 a').click(function() {
		$(this).parent().parent().children('.inner_box').slideToggle('normal');
	});
	$('.box_search #search_term').each(function() {
		window.orig_search_value = this.value;
		$(this).focus(function(){
			$(this).addClass('active');
			if (this.value==window.orig_search_value) this.value = '';
		});
		$(this).blur(function(){
			$(this).removeClass('active');
			if (this.value=='') this.value = window.orig_search_value;
		});
	});
	$('#form_login_small .small_button').click(function() {
		$('#form_login_small').submit();
	});
	$('#form_logout_small #logout_submit').click(function() {
		$('#form_logout_small').submit();
	});
	$('#form_logout .bulleted_2').click(function() {
		$('#form_logout').submit();
	});
	$('.form_button_row a').each(function() {
		if ($(this).attr('href').indexOf('#')==0 && !($.browser.msie===true && $.browser.version<=6)) {
			$(this).attr('href','javascript:;');
		}
	});
	if ($.browser.msie===true&&$.browser.version>7) {
		$('#logo_we').css('margin-right','-200px');
	}
	$('.panel_specs .page_nav a').click(function(){
		var target = $(this).attr('href');
		$('.copy_spec').hide();
		$(target).show();
		$('.page_nav a').removeClass('selected');
		$(this).addClass('selected');
	});
	$('.link-no-login').click(function(){
		//$('.gallery-hint-login').animate({backgroundColor: '#cc0000'},500);
	});
	//$('#flash_promo_1').css('visibility','visible');
	$('#box-14p a img').each(function(){
		var t = $(this).parent().attr('title');
		$(this).data('tt',$(this).parent().attr('title'));
		$(this).parent().removeAttr('title');
		$(this).parents('#box-14p').append('<div id="hint-delivery"><div class="close">&times;</div><div class="copy">'+t+'</div></div>');
		$(this).parent().click(function(){
			$('#hint-delivery').show();
		});
		$('#hint-delivery .close').click(function(){
			$('#hint-delivery').hide();
		});
	});
	$('#box-promo-grill a img').each(function(){
		var t = $(this).parent().attr('title');
		$(this).data('tt',$(this).parent().attr('title'));
		$(this).parent().removeAttr('title');
		$(this).parents('#box-promo-grill').append('<div id="hint-sidebar"><div class="close">&times;</div><div class="copy">'+t+'</div></div>');
		$(this).parent().click(function(){
			$('#hint-sidebar').show();
		});
		$('#hint-sidebar .close').click(function(){
			$('#hint-sidebar').hide();
		});
	});
	$('#box-promo-stencilforfree a img').each(function(){
		var t = $(this).parent().attr('title');
		$(this).data('tt',$(this).parent().attr('title'));
		$(this).parent().removeAttr('title');
		$(this).parents('#box-promo-stencilforfree').append('<div id="hint-sidebar"><div class="close">&times;</div><div class="copy">'+t+'</div></div>');
		$(this).parent().click(function(){
			$('#hint-sidebar').show();
		});
		$('#hint-sidebar .close').click(function(){
			$('#hint-sidebar').hide();
		});
	});
	$('#box-promo-currencies a img').each(function(){
		var t = $(this).parent().attr('title');
		$(this).data('tt',$(this).parent().attr('title'));
		$(this).parent().removeAttr('title');
		$(this).parents('#box-promo-currencies').append('<div id="hint-sidebar2"><div class="close">&times;</div><div class="copy">'+t+'</div></div>');
		$(this).parent().click(function(){
			$('#hint-sidebar2').show();
		});
		$('#hint-sidebar2 .close').click(function(){
			$('#hint-sidebar2').hide();
		});
	});
	$('.affiliate_overview textarea').focus(function(){this.select();});
	$('.we-stage-modular li').click(function(){
		var u = $(this).find('a').attr('href');
		window.location = u;
	});
	$('.change-currency').each(function(){
		$(this).find('a').click(function(){
			//$(this).parents('.change-currency').find('select').toggle(); 
		});
		$(this).find('select').change(function(){
			var c = $(this).find('option:selected').val();
			//$(this).hide();
			currency_url = window.currency_url;
			var cb = function(data){
				if ($('.cart_header').length==0) {
					updatePrice();
					if(typeof updateComparePrice == 'function') { 
						updateComparePrice(1); 
						updateComparePrice(2); 
						updateComparePrice(3); 
					}
				} else {
					window.location.reload();
				}
			};
			$.post(currency_url,'c='+c,cb);
		});
	});
	
	
});
