// JavaScript Documentvar shiftPromoLeft = null;
var shiftPromoRight = null;
(function(){
	var tmout = 0;
	var tmspeed = 10000;
	var mCount = 0;
	
	shiftPromoLeft = function() {
		clearTimeout(tmout);
		mCount++;
		updatePromo("left"); 
		tmout = setTimeout(shiftPromoLeft, tmspeed);
	} //end function shiftPromo()
	
	shiftPromoRight = function() {
		clearTimeout(tmout);
		mCount--;
		updatePromo("right"); 
		tmout = setTimeout(shiftPromoLeft, tmspeed);
	} //end function shiftPromo()
	
	function updatePromo(dir) {
		if (num_promos < 1) {
			return;
		}
		mCount = (mCount < 0) ? num_promos - 1 : ((mCount >= num_promos) ? 0 : mCount);
		if (dir == "left") {
			hideCount = (mCount - 1) < 0 ?  num_promos - 1 : mCount - 1;
			hide ="layerPromo" + hideCount;
			show = "layerPromo" + mCount;
		} else {
			hideCount = (mCount + 1) >= num_promos ?  0 : mCount + 1;
			hide ="layerPromo" + hideCount;
			show = "layerPromo" + mCount;
		} //end if
		document.getElementById(hide).style.display = "none";
		document.getElementById(show).style.display = "block";
	} //end function updatePromo()

	tmout = setTimeout(shiftPromoLeft, tmspeed);

	try {
		// list of field to be ammended
		var fieldNodeArr = new Array;
		var formNode = document.getElementById('LoginForm');
		fieldNodeArr.push(formNode.username);
		fieldNodeArr.push(formNode.password);

		var onFocus = function(e) {
			clearTimeout(tmout);
		}
		var onBlur = function(e) {
			clearTimeout(tmout);
			tmout = setTimeout(shiftPromoLeft, tmspeed);
		}
		
		var l = fieldNodeArr.length;
		for (var i = 0; i < l; i++) {
			var node = fieldNodeArr[i];
			node.onfocus = onFocus;
			node.onblur = onBlur;
		}
	} catch(err) {}
})()