﻿document.observe("dom:loaded", function () {
	$$('a', 'i').each(function (s, index) {
		if (s.innerHTML.indexOf('<img') == -1) s.setAttribute('title', s.innerHTML.unescapeHTML());
	});
	loadBb();
});
function loadBb() {
	$$('.bb_img').each(function (i) {
		$(i).setStyle({
			width: '0px'
		});
	});
	$('bbH1').setStyle({
		'border-left-width': '1px'
	});
	/*
	*/
	startBb();
}
var bbPrev = 0;
var bbX = 0;
var bbTimer;
function openBb(strX, intDelay) {
	window.clearTimeout(bbTimer);
	if (strX != null) bbX = parseInt(strX);
	if (intDelay == null) intDelay = 12000;
	if (bbX > 0) { // not first time
		//alert(bbX + '~' + bbPrev);
		if (bbX != bbPrev) {
			new Effect.Parallel([
				new Effect.Morph('bbImg' + bbX, { sync: true, style: 'border-right-width:1px; width:892px;', duration: 0.5 }),
				new Effect.Morph('bbImg' + bbPrev, { sync: true, style: 'border-right-width:0px; width:0px;', duration: 0.5 })
			], {
				duration: 0.5
			});
		}
		/*
		$('bbH' + bbPrev).setStyle({
			'border-right-width': '0px'
		});
		*/
		bbPrev = bbX;
		bbX = parseInt(bbX) == 4 ? 1 : parseInt(bbX) + 1;
	}
	else { // first time
		new Effect.Morph('bbImg1', {
			style: 'border-right-width:1px; width:892px;', // CSS Properties
			duration: 0.5 // Core Effect properties
		});
		bbPrev = 1;
		bbX = 2;
	}
	/*
	$('bbH' + bbPrev).setStyle({
		'border-right-width': '1px'
	});
	*/
	//alert(strId + '~' + bbX);
	//bbX = bbX == 6 ? 1 : bbX + 1;
	if (strX == null) bbTimer = window.setTimeout("openBb()", intDelay);
}
function pauseBb() {
	window.clearTimeout(bbTimer);
}
function startBb() {
	bbTimer = window.setTimeout("openBb()", 0);
}
function showHdr(strArea, strMedia) {
	//strMedia = 'txt';
	$('imgHdr' + strArea).setStyle({ 'display': 'none' });
	$('txtHdr' + strArea).setStyle({ 'display': 'none' });
	$(strMedia + 'Hdr' + strArea).setStyle({ 'display': 'block' });
}
var icnId = '1'; // default to first icon
function selIcon(strId) {
	if (strId != icnId) { // this is a different icon
		$('img' + icnId).addClassName("icnNoSel");
		$('img' + icnId).removeClassName("icnSel");
		$('img' + strId).addClassName("icnSel");
		$('img' + strId).removeClassName("icnNoSel");
		icnId = strId;
	}
}
function flowTo(strId, intOffset) {
	_gat._getTrackerByName()._trackEvent('Site Nav', strId);
	if (intOffset == null) intOffset = -100;
	new Effect.ScrollTo('a_' + strId, { duration: '0.5', offset: intOffset });
}
var intCurrFolioId = 1;
function folio(strId) {
	if (strId == 'n') {
		// next folio
		strId = intCurrFolioId + 1;
		if (strId > $('folio_portal').immediateDescendants().length) {
			strId = 1;
		}
	}
	new Effect.ScrollTo('folio_' + strId);
}

