// JavaScript Document
function fixImages(){
	$("#pageContent img").each(function(){
		var img = $(this),
	    src = img.attr("src");
		if(src.indexOf("/thumbs/") == -1){
			img.attr("src",src + "?width=" + img.width() + "&height=" + img.height());
		}

	});
}

(function ($) {
	$.fn.gwpImageFade = function(options){
		var opts = $.extend({}, $.fn.gwpImageFade.defaults, options);
		
		return this.each(function(){
			$this = $(this);
			$image = $this.find("img:last");
			$clone = $image.clone();
			pauseInt = parseInt(opts.pause) * 1000;
			durationInt = parseInt(opts.duration) * 1000;
			var rotate = function rotateImage(){
				$image.stop().fadeTo(pauseInt,1).fadeTo(durationInt,0,function(){
					$image.remove();
					$this.prepend($clone);
					$.fn.gwpImageFade.rotate();
				});
			};
			rotate();
		});
	};
	$.fn.gwpImageFade.defaults = {
		pause:5,
		duration:5
	};
})(jQuery);


function rotateImage()
{
	var $carousel = $("#imageCarouselWrap"),
		$image = $("#imageCarouselWrap > img:last"),
		$clone = $image.clone();
	$image.stop().fadeTo(5000,1).fadeTo(5000,0,function(){
		$image.remove();
		$carousel.prepend($clone);
		rotateImage();
	});
	
	return false;
}

function startRotation()
{
	$("#imageCarouselWrap").fadeIn();
	rotateImage();
}

$(document).ready(function(){
	$("input[name=delType]").change(function(){
		var $this = $(this),
			value = $this.val();
		$(".delField").addClass('jsHide');
		if(value == 'BU'){
			$(".delField").removeClass('jsHide');
		}
		else if(value == 'AF'){
			$(".delField:not(.BUfield)").removeClass('jsHide');
		}
		return true;
	});
        
});

