$(function() {
	
	$('#messageflash').hide();
	$('#messageflash').slideDown('slow').delay(5000).slideUp('slow');

	$("#newspic a").fancybox({
		'titlePosition': 'over',
		'autoScale': 'true',
		'cyclic': 'false',
		'showNavArrows': 'false'
	});
	
	$("a.productpic").fancybox({
		'titlePosition': 'over',
		'autoScale': 'true',
		'cyclic': 'false',
		'showNavArrows': 'false'
	});
	
	$("a.gallerylink").fancybox({
		'titlePosition': 'over',
		'autoScale': 'true',
		'cyclic': 'false',
		'showNavArrows': 'true'
	});
	
	$("a.swatchlink").fancybox({
		'titlePosition': 'over',
		'autoScale': 'true',
		'cyclic': 'false',
		'showNavArrows': 'true'
	});
	
	
	$("a.sofaimg").fancybox({
		'titlePosition': 'over',
		'autoScale': 'true',
		'cyclic': 'false',
		'showNavArrows': 'true'
	});
	
	$('#collectionflash').cycle({
	    fx:     'fade',
        speed:  'slow',
        pager:  '#colnav',
        allowPagerClickBubble: true,

	    pagerEvent: 'mouseover',
		slideExpr: 'img',
		pagerAnchorBuilder: function(idx, slide) { 
		        // return selector string for existing anchor 
		        return '#colnav li:eq(' + idx + ') a'; 
	    }
	});
	

	$('#mainflashes-rotating').cycle({ 
	    fx:     'fade', 
	    speed:  'slow', 
	    timeout: 4000, 
        allowPagerClickBubble: true,
	    pager:  '#mainflashes-control'
	});
		
	$('#collectiongalleryflash').cycle({ 
	    fx:     'fade',
        speed:  'slow',
       	pager:  '#collectiongallerynav',
        allowPagerClickBubble: true,
	    pagerEvent: 'mouseover',
		slideExpr: 'div', 
		pagerAnchorBuilder: function(idx, slide) { 
		        // return selector string for existing anchor 
		        return '#collectiongallerynav li:eq(' + idx + ') '; 
	    }
	});
	
	$('#homepageflash').cycle();
	
	
	var tag;
	var existing_tags;
	$('.tagbutton').click(function(){
		tag = $(this).html();
		$(this).addClass("clickedtag");
		existing_tags = $('#tags').val();
		$('#tags').val(existing_tags+' '+tag+' ');
	});
	
	$('#cms-sub-categories ul li ul li').click(function(){
		tag = $(this).html();
		$(this).addClass("clickedtag");
		existing_tags = $('#tags').val();
		$('#tags').val(existing_tags+' '+tag+' ');
	});
	
	
	$(".pictureview #productswrapper").tabs({ selected: 0 });

	if (!($('#errormessage').children().size() > 0 )){
  		$("#recaptcha_area").hide();
  }

  $("form input").change(function(){
		$("#recaptcha_area:hidden").show("slow");
  });
  

	$(".finishselect").change(function() {
		var test = $(this).val();
		$(".finishselect").val(test);
	});



});
