// JavaScript Document
function roll(o) {
	var src, ftype, newsrc;
	src = o.src;
 	ftype = src.substring(src.lastIndexOf('.'), src.length);
 	if(/_a/.test(src)) {
		newsrc = src.replace('_a','');
 	} else {
		newsrc = src.replace(ftype,'_a'+ftype);
 	}
	o.src = newsrc;
}

function toggleList(idName) {

	var seeMoreId = idName + "_m";
	
	var seeMore = document.getElementById(seeMoreId); 
	if (seeMore) {
	  if (seeMore.innerHTML == "read more \&gt\;\&gt\;") seeMore.innerHTML = "close &lt\;\&lt\;";
	  else seeMore.innerHTML = "read more \&gt\;\&gt\;";
	}
	$j(idName).css({"opacity": "0"});
	$j(idName).slideToggle('fast', function() { 
		$j(idName).animate({opacity:"1"}, function() {
			if(jQuery.browser.msie) {
				this.style.removeAttribute('filter');
				$j("#main-body").css("height","auto");
			}
		}); 
		
	});

}

function align() {
	var a_id = "#maincontent-block";
	var offset = $j("#topBanner").offset();
	var newX = offset.left;
	var currentX = $j(a_id).offset().left;
	var currentY = $j(a_id).offset().top;
	var diffX = newX - currentX;
	
	//$j(id).width(938);
	$j(a_id).css("position","relative");
	$j(a_id).css("max-width","944px");
	if (diffX < 1) {
		$j(a_id).css("padding-right","10px");
		$j(a_id).css("left", diffX+19);
		diffX = 19;
	}
	$j(a_id).animate({opacity: "1", left: diffX}, 1000);
	return false;
	
}

var fadeCounter = 0;
var msgArray;
var fadeID="";

function alertText(txtArray,id) {
	msgArray = txtArray
	fadeID = id;
	executeFade();
	window.setInterval('executeFade()',14000);
}

function executeFade() {
	var openSpanTag = '<span id="textID" style="text-align:center; font-weight:bold; display:none">';
	var closeSpanTag = '</span>';
	if (fadeCounter == msgArray.length) fadeCounter = 0;
	document.getElementById(fadeID).innerHTML= "&nbsp;" + openSpanTag + msgArray[fadeCounter] + closeSpanTag;
	$j("#textID").fadeIn(2000).delay(10000).fadeOut(1500);
	fadeCounter++;
	
	
}

function displayDiv(id,h)  {
	id = "#"+id;
	closeHeight = h + 10;
	var display = $j(id).css('display');
	if (display == "block") 
		$j(id).animate({height: '+=10'},600).animate({height: '-='+closeHeight, opacity: 'hide'},500);
		
	else 
		$j(id).animate({height: ['+='+h,'swing'], opacity: 'toggle'},600).animate({height: ['-=15','swing']},200).animate({height: ['+=15','swing']},500);
	
}



function LinkedList() {}
LinkedList.prototype = {
  length: 0,
  first: null,
  last: null,
  cursor: null
};
LinkedList.Circular = function() {};
LinkedList.Circular.prototype = new LinkedList();

LinkedList.Circular.prototype.append = function(node) {
  if (this.first === null) {
	node.prev = node;
    node.next = node;
    this.first = node;
    this.last = node;
	this.cursor = node;
  } else {
    node.prev = this.last;
    node.next = this.first;
    this.first.prev = node;
    this.last.next = node;
    this.last = node;
  }
  this.length++;
};

LinkedList.Node = function(data) {
  this.prev = null; 
  this.next = null;
  this.data = data;
};

LinkedList.Circular.prototype.getData = function() {
	return this.cursor.data;
}

LinkedList.Circular.prototype.next = function() {
	this.cursor = this.cursor.next;
}

LinkedList.Circular.prototype.previous = function() {
	this.cursor = this.cursor.prev;
}

LinkedList.Circular.prototype.size = function() {
	return this.length;
}



