$(document).ready(function() {

// breadcrumb BR replace
	$('#breadcrumbs br').replaceWith(' - ');

// input idles + clears
	$('input[type="text"]:not(.qty)').addClass('idleField');
	$('input[type="text"]:not(.qty)').focus(function() {$(this).removeClass('idleField').addClass('focusField'); if (this.value == this.defaultValue) this.value = ''; if(this.value != this.defaultValue)	this.select();	});
  $('input[type="text"]:not(.qty)').blur(function() {$(this).removeClass('focusField').addClass('idleField'); if ($.trim(this.value) == '') this.value = (this.defaultValue ? this.defaultValue : '');});

// qty bg
	$('.qty').each(function(){if ($(this).val().length != 0) $(this).removeClass('qty-on'); else $(this).addClass('qty-on');});
	$('.qty').focus(function(){$(this).removeClass('qty-on').addClass('qty-off');});
	$('.qty').blur(function(){if ($(this).val() != 0) $(this).removeClass('qty-off');});

// lightbox
	$('a[rel*=lightbox]').fancybox({hideOnContentClick:true, showNavArrows:false, titlePosition:'inside', transitionIn:'none', transitionOut:'none'});
	$('a[rel*="iframe"], #accordion a[rel*=lightbox]').fancybox({type:'iframe', autoDimensions:false, showNavArrows:false, width:'75%', height:'75%', scrolling:'yes', transitionIn:'none', transitionOut:'none'});

// smooth + external
	$('a[href*=#]').click(function() {if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {var $target = $(this.hash); $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']'); if ($target.length) {var targetOffset = $target.offset().top; $('html,body').animate({scrollTop: targetOffset}, 2000);return false;}}});
	$('a[rel="external"]').attr('target', '_blank');

// button icons
	if ($('a.button').attr('rel')){$('a.button').each(function(){$(this).append('<span style="background-image:url(\'_images/_icons/' + $(this).attr('rel') + '.png\')"></span>');});}

// category3 hover image swap
	$('.product-list .swatches div a').hover(function(){$(this).parent().parent().parent().find('span img').attr('src', $(this).attr('href'));});

// capture enter
	$('.qty').keypress(function(e) {if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) __doPostBack('ctl00$PageContent$Add','');});
	$('.estship').keypress(function(e) {if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) __doPostBack('ctl00$PageContent$UCviewcart$estshipsubmit','');});
	$('.contact input').keypress(function(e) {if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) __doPostBack('ctl00$PageContent$SubmitButton','');});
	$('.register fieldset input').keypress(function(e) {if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) __doPostBack('ctl00$PageContent$UCcheckout$Continue1','');});
	$('.form.register input').keypress(function(e) {if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)){ __doPostBack('ctl00$PageContent$ContinueCheckout',''); Freeze('Your account is being created...');};});
	$('#ctl00_UCsearchbox_SearchBox').keypress(function(e) {if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) __doPostBack('ctl00$UCsearchbox$SearchButton2','');});
	$('#ctl00_PageContent_Emaila').keypress(function(e) {if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) __doPostBack('ctl00$PageContent$Forgot','');});
	$('#ctl00_PageContent_NewPassword2').keypress(function(e) {if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) __doPostBack('ctl00$PageContent$ChangePass','');});
	$('#ctl00_PageContent_UClogin_orderpanel').keypress(function(e) {if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) __doPostBack('ctl00$PageContent$UClogin$Login','');});
	$('#ctl00_PageContent_SearchFor').keypress(function(e) {if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) __doPostBack('ctl00$PageContent$SearchOrders','');});
	$('#ctl00_PageContent_UClogin_orderpanel input').keypress(function(e) {if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) __doPostBack('ctl00$PageContent$UClogin$Login','');});
	$('#ctl00_PageContent_UCcheckout3_PromoCode').keypress(function(e) {if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) __doPostBack('ctl00$PageContent$UCcheckout3$PromoButton','');});
	$('#ctl00_PageContent_UCcheckout3_PurchaseOrder').keypress(function(e) {if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$PageContent$UCcheckout3$SubmitButton", "", false, "", "checkout3.aspx", false, true)); Freeze('Thank you, your order is being processed...');};});
});

function Freeze(msg) {
	$('#freeze').addClass('on');
	$('#freeze div').text(msg);
	$('body').css('overflow', 'hidden');
	$('.checkout-submit-button').hide();
}

