$(document).ready(function() {
	$.externallinks();
	$.firstchildamend();
	$('input[title!=""]').hint();
	$('textarea[title!=""]').hint();
	$('.survey input[type=radio][value="1"]').addClass("yes");
	$('.survey input[type=radio][value="0"]').addClass("no");
	$('.survey input[type=checkbox].no,.survey input[type=radio].no').prettyCheckboxesno({
		checkboxWidth: 76,
		checkboxHeight: 39
	});
	$('.survey input[type=checkbox].yes,.survey input[type=radio].yes').prettyCheckboxesyes({
		checkboxWidth: 76,
		checkboxHeight: 39
	});

	$("a.videofancybox,a.lightbox").fancybox({
		'hideOnContentClick': false,
		/*'zoomSpeedIn': 500,
		'zoomSpeedOut': 500,*/
		'frameWidth': 425,
		'frameHeight': 344,
		'overlayOpacity': 0.8,
		'overlayColor': '#0A87BF'
	});
	$("a.videofancybox,a.lightbox").attr({
		title: function(arr) {
			if ($(this).attr("title").indexOf(" (opens in a new window)") >= 0) {
				$(this).attr("title", $(this).attr("title").replace(" (opens in a new window)", ""));
			}
			if ($(this).attr("title").indexOf("opens in a new window") >= 0) {
				$(this).attr("title", $(this).attr("title").replace("opens in a new window", ""));
			}
		}
	});

	$('.modalbackground').css("opacity", 0.6).css("filter", "alpha(opacity=60)");
	$('a[href^="http://www.youtube.com/"]').flash({
		height: 425,
		width: 344,
		allowFullScreen: true,
		wmode: "transparent"
	},
        { version: 8 },
        function(htmlOptions) {
        	$this = $(this);
        	htmlOptions.src = $this.attr('href');
        	htmlOptions.width = 425;
        	htmlOptions.height = 344;
        	$this.before($.fn.flash.transform(htmlOptions));
        	$this.replaceWith("");
        }
    );
});

$.firstchildamend = function() {
	$(".footnav li:first-child")
	.css("border", "0")
	.css("padding-top", "0")
}

$.externallinks = function() {
	$('a[href^="http://"],a[rel="external"]')
	.attr({
		target: "_blank",
		title: function(arr) {
			if ($(this).attr("title").length > 0) {
				$(this).attr("title", $(this).attr("title") + " (opens in a new window)");
			}
			else {
				$(this).attr("title", "opens in a new window");
			}
		}
	});
	$('a[href^="http://clients.islington.byteart.com/"]')
	.attr({
		target: "_self",
		title: function(arr) {
			$(this).attr("title", $(this).attr("title").replace(/ (opens in a new window)/, ""));
			$(this).attr("title", $(this).attr("title").replace(/(opens in a new window)/, ""));
		}
	});
}
