$(function(){
	
	$('.deleteCat').click(function(){
		return confirm('Are you sure you want to delete this category?\n\nDeleting this category will remove all subcategories and products of this category')
	});
	
	$('.deleteAttr').click(function(){
		return confirm('Are you sure you want to delete this product attribute?')
	});

        $('.deleteNews').click(function(){
		return confirm('Are you sure you want to delete this news article?')
	});
        
	$('.viewVars').click(function(){
		
		var id = $(this).attr('id').replace('viewVar','');
		
		if($(this).html() == 'view'){
			
			if($.browser.msie){
				$('#vars_'+id).css('display','block');
			}else{
				$('#vars_'+id).css('display','table-row');
			}
			$(this).html('hide');
			
		}else{
			
			$('#vars_'+id).css('display','none');
			$(this).html('view');
			
		}
		
		return false;
	});
	
	$('a').click(function(){
		$(this).blur();
	});

        /* document ready */
        $(document).ready(function() {

            /* external links */
            $("a[rel=external]").attr('target','_blank');

            /* search box */
            $('#search-terms').focus(function() {
                if($(this).attr('value') == 'Search Alton Ladders') {
                    $(this).attr('value', '');
                }
            }).blur(function() {
                if($(this).attr('value') == '') {
                    $(this).attr('value', 'Search Alton Ladders');
                }
            });

            /* scroll to selected product */
            url = window.location.hash;
            url = url.split('#');
            url = url[url.length - 1];
            if($(url).length > 0) {
                $.scrollTo(url);
            }
        });
});
