$(function() {
	$("#messageflash").slideDown('slow');
	
    $("#portfoliopieces").cycle({ 
	    prev:   '#prev', 
	    next:   '#next', 
	    timeout: 0 
	});

	$("a#single_image").fancybox();
	
	
	$("#toadgallery a").fancybox({
		titlePosition	: 'inside'			
	});
	
	$(".youtube").click(function() {
		$.fancybox({
				'padding'		: 0,
				'autoScale'		: false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'title'			: this.title,
				'width'			: 680,
				'height'		: 495,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'			: {
				   	 'wmode'		: 'transparent',
					'allowfullscreen'	: 'true'
				}
			});
		return false; 
	});
	
	
	
	$(".deletebutton").click(function(){
		deletePortfolioImage($(this).attr("rel"));
	});

	function deletePortfolioImage(number) {
	
		var existingstring = $('#existingportfolioimage'+number).val();
		var hiddenField = '<input type="hidden" name="deleteexistingportfolioimage'+number+'" value="'+existingstring +'" />';
		
		$("#portfolioformfieldset").append(hiddenField);
		var hidediv = "#existingportfolioimage"+number+"wrapper";
		
		$(hidediv).hide();
	}
	
	
	
	
});
