$(document).ready(function(){
	$("a[@rel=external]").addClass('out').attr("target", "_blank");
	$(document).pngFix();
	
	//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);
		});
	});
	
	//product gallery
	$('.more a').click(function(event){
		$('.node-product .more a').removeClass('active');
		ttl = ($(this).attr('title')) ? $(this).attr('title') : "";
		$(this).addClass('active');
		$('.node-product #caption').html(ttl);
		$('.node-product #imgContainer img').attr('src', $(this).attr('href'));
		href = $(this).attr('href').replace('images/', '').replace('.', '_large.');
		$('.node-product #imgContainer').attr('href', '/xyz/gallery.htm');
		event.preventDefault();
	});
	
	//admin products filter jumpto
	$('.filter #cats option').click(function(){
		val = $(this).val();
		document.location.href = "#jump"+val;
	});
	
	//FAQs
	$('.node-faqs, .node-faqs h2').css('cursor', 'pointer');
	$('.node-faqs').click(function(event){
		if ($(this).attr('class').indexOf('active') <= -1) $(this).addClass('active');
		showhide = ($(this).find('h2 a').html() == "View Answer") ? "Hide Answer" : "View Answer";
		$(this).find('div').slideToggle(500);
		$(this).find('h2 a').html(showhide);
		event.preventDefault();
	});
	
	//fieledset
	$('fieldset.collapsible legend').click(function(event){
		rent = $(this).parent();
		exClass = (rent.attr('class').indexOf('collapsed') <= -1) ? "collapsed" : "expanded";
		rent.removeClass('collapsed').css('height', 'auto').addClass(exClass);
		event.preventDefault();
	});
	
	//up/downlinks
	$('.adminlinks a.off').click(function(event){
		event.preventDefault();
	});
	
	//checkout copy address
	$('#checkout #copy').focus(function(){
		$(this).parent().parent().parent('fieldset').next().toggle();
	});
	
	//messages banner
	$('#messages').css({cursor: 'pointer'}).click(function(){
		linkTo = $(this).children().find('a').attr('href');
		if (linkTo) document.location.href = linkTo;
	});
	//$('#messages').click()
});
	