$(document).ready(function(){
	$("a[rel=external]").addClass('out').attr("target", "_blank");
	
	//form input focus/blur
	$("input[type=password], input[type=text], textarea").focus(function() {
		val = $(this).attr('def');
		if ($(this).val() == val) $(this).val('');
		$(this).blur(function(){
			if ($(this).val() == '') $(this).val(val);
		});
	});

	$('#offers .box').mouseover(function(){
		$(this).css({'cursor': 'pointer'});
	});
	$('#offers .box').click(function(){
		href = $(this).children().children().find('a').attr('href');
		document.location = href;
	});
	
	//login Block
	$('#loginBlock .first').click(function(event){
		$('#loginBlock').addClass('active');
		$('#loginForm').slideDown(500, function(){$(this).find('input:first')[0].focus();})
		event.preventDefault();
	});
	
	//$('.node-product-tbl .qty .form-text').focus(function(){
	$('.node-product .qty .form-text').focus(function(){
		if ($(this).val() == "qty"){
			$(this).val('0').select()[0];
		} else {
			$(this).select()[0];
		}
	});
	
	if ($('#catMenu').length > 0){
		//show/hide catMenu
		$('#browsecats').click(function(event){
			if ($(this).attr('class').indexOf('link') <= -1){
				$('#catMenu').toggleClass('open');
				$('#catMenu li.active ul').slideToggle('slow');
				$('#catMenu .rent').slideToggle('slow');
				$(this).toggleClass('open');
				event.preventDefault();
			}
		});
	}
	
	//product teaser
	/*$('#productView .product td').hover(function(){
		tr = $(this).parent();
		if ($(this).attr('class').indexOf('qty') <= -1){
			$(tr).css({'cursor': 'pointer'}).addClass('hover');
			$(this).click(function(){
				href = $(tr).children().find('a').attr('href');
				document.location = href;
			});
		}
	}, function(){
		$(this).parent().removeClass('hover');
	});*/
	$('#cartAdd td.hover').hover(function(){
		tr = $(this).parent();
		if ($(this).attr('class').indexOf('qty') <= -1 && $(tr).attr('class').indexOf('active') <= -1){
			$(tr).css({'cursor': 'pointer'}).addClass('hover');
			$(this).click(function(){
				href = $(tr).children().find('a').attr('href');
				document.location = href;
			});
		}
	}, function(){
		$(this).parent().removeClass('hover');
	});
	
	/*//checkout
	$('#main input.error, #main textarea.error, #main select.error').each(function(){
		$(this).before('<div class="msg"><div>'+$(this).attr('msg')+'</div></div>');
	});*/
	
	//category nodes
	$('.node-category').hover(function(){
		$(this).addClass('hover');
	}, function(){
		$(this).removeClass('hover');
	});
});