﻿$(document).ready(function() {
	if ($.externallinks) {
		$.externallinks();
	}
	if ($.firstchildamend) {
		$.firstchildamend();
	}
	if ($.hint) {
		$('input[title!=""]').hint();
		$('textarea[title!=""]').hint();
	}
//	if ($.jcarousel) {
//		$('#banners').jcarousel({
//			scroll: 1
//		});
//	}
	$(".banner li span").css("display", "block");
	if ($.ColorPicker) {
		$('input.cpicker').ColorPicker({
			onSubmit: function(hsb, hex, rgb, el) {
				$(el).val("#" + hex);
				$(el).ColorPickerHide();
			},
			onBeforeShow: function() {
				$(this).ColorPickerSetColor(this.value);
			}
		}).bind('keyup', function() {
			$(this).ColorPickerSetColor(this.value);
		});
	}
	if ($.isFunction($.fn.nivoSlider)) { $('#banners2').nivoSlider({ animSpeed: 500, pauseTime: 5000, directionNavHide: false, controlNav: false, slices: 20 }); }
});

$.firstchildamend = function() {
	$(".footnav li:first-child,.testimonials li:first-child,.tasks li:first-child,.copyright li:first-child")
	.css("border", "0")
	.css("padding", "0")
	.css("margin", "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.phoros.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)/, ""));
		}
	});
}
