jQuery(function() {
	if (jQuery("#scroll #tools").children().size() >= 2) {
		jQuery("#scroll").scrollable({ items: '#tools', circular: true }).navigator().autoscroll({ interval: 8000 });
		
		var size = jQuery('#navdots a').size();
		if (size == 2) {
			jQuery("#navdots").css({ "margin-left": "440px" });
		} else if (size == 3) {
			jQuery("#navdots").css({ "margin-left": "399px" });
		} else if (size == 4) {
			jQuery("#navdots").css({ "margin-left": "350px" });
		}
	}
});

jQuery(function() {
	jQuery('.jcarousel').show().jcarousel();
});

if (typeof openChat == "undefined") {
	function openChat() {
		var docurl = location.href;
		if (docurl.indexOf("?") > 0) docurl = docurl.substring(0, docurl.indexOf("?"));
		//alert(docurl);
		var encodedURL = encodeURIComponent(docurl);
		if (typeof myScore == "undefined") var buildHREF = "http://cx.rightnow.com/app/chat/bdr_chat_launch" + "/source/" + encodedURL;
		else {
			alert(myScore);
			var buildHREF = "http://cx.rightnow.com/app/chat/bdr_chat_launch" + "/source/" + encodedURL + "/score/" + myScore;
		}
		//alert(buildHREF);    
		fb.start({
			href: buildHREF,
			rev: 'width:700 height:660 caption:`` scrolling:no'
		});
	}
}
//This javascript controls the contact us buttons on each page,
//  and sets some variables for use on the contact us page
var chat_enabled = false;
var today = new Date();
//Since we are only using whole hours at this time, no need to write special code.
//Times based on PST since the server is in CA
var chatOn = 7; // 07:00 PST = 8AM MST
var chatOff = 17; // 17:00 PST = 6PM MST
var chatOnAU = 13; // 13:00 PST = 08:00 SYDNEY
var chatOffAU = 22; // 22:00 PST or 17:00 SYDNEY
var chatOnUK = 0; // 00:00 PST = 08:00 LONDON
var chatOffUK = 10; // 10:00 PST = 18:00 LONDON
var allOff = 16; //"16:00 PST";
var hour = 21;
var today_srvr = 3;
// CHAT SECTION -- chat is turned off in JP & DE
var chatIOnSpan = document.getElementById('chatisOn');
var chatIOffSpan = document.getElementById('chatisOff');
if (chatIOnSpan != null) chatIOnSpan.style.display = 'none';
if (chatIOffSpan != null) chatIOffSpan.style.display = 'block';
chat_enabled = false;

if (chatIOnSpan != null) { //No chat on this page
	//Australia Rep Online Sunday - Thursday 13:00 - 22:00 Pacific (server) time, 8-5 M-F Sydney AU Time
	if (today_srvr != 6 && today_srvr != 5) {
		if (hour >= chatOnAU && hour < chatOffAU) {
			chatIOnSpan.style.display = 'block';
			chatIOffSpan.style.display = 'none';
			chat_enabled = true;
		}
	}
	//UK & US Available M - F
	if (today_srvr != 0 && today_srvr != 6) {
		//UK Rep Online Monday - Friday 00:00 - 10:00 Pacific (server) time, 8-6 M-F London UK Time
		if (hour >= chatOnUK && hour < chatOffUK) {
			chatIOnSpan.style.display = 'block';
			chatIOffSpan.style.display = 'none';
			chat_enabled = true;
		}
		//US Rep Online Monday - Friday 07:00 - 17:00 Pacific (server) time, 8-6 M-F Bozeman MT Time
		else if (hour >= chatOn && hour < chatOff) {
			chatIOnSpan.style.display = 'block';
			chatIOffSpan.style.display = 'none';
			chat_enabled = true;
		}
	}
}

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-24651238-3']);
_gaq.push(['_trackPageview']);
(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

