// common.js
//

/* =========================================
/*		Cross browser function to find an element by id
/* ========================================= */
function objById(id)
{ 
	if (document.getElementById) return document.getElementById(id); 
	else if (document.all) return document.all[id]; 
	else if (document.layers) return document.layers[id]; 
}

/* =========================================
/*		Textbox focus and blur events (change active css)
/* ========================================= */
function focusTxt(obj) { obj.className = obj.className.replace(" hl", "") + " sel"; }
function blurTxt(obj) { obj.className = obj.className.replace(" sel", "").replace(" sel", ""); }


/* =========================================
/*		Banner image rotation
/* ========================================= */
var bnrCnt = 0, currBnr = 0, timeOut = 5000;
$(document).ready(function ()
{
	$("#bnrRot").children().each(function ()
	{
		if ($(this).attr("src") != null)
		{
			if (bnrCnt == 0) $(this).show(); else $(this).hide();
			this.id = "bnrImg" + bnrCnt;
			$(this).css({ 'position': 'absolute', 'z-index': '0', 'top': '0px' });
			bnrCnt++;
		}
		else
		{
			this.id = "bnrP" + bnrCnt;
			$(this).css({ 'position': 'relative', 'z-index': '1' });
			if (bnrCnt == 0) $("#bnrP" + bnrCnt).css({ 'left': '0px' }); else $("#bnrP" + bnrCnt).css({ 'left': 0 - $("#bnrP" + bnrCnt).width() + 'px' });
		}
	});

	currBnr = 0;
	setInterval(function ()
	{
		var lastBnr = currBnr;
		if (currBnr == bnrCnt - 1) currBnr = 0; else currBnr++;
		$("#bnrImg" + lastBnr).fadeOut(500);
		$("#bnrImg" + currBnr).fadeIn(500);
		$("#bnrP" + lastBnr).animate({ 'left': 0 - $("#bnrP" + lastBnr).width() + 'px' }, 500);
		$("#bnrP" + currBnr).animate({ 'left': '0px' }, 500);
	}, timeOut);
});
