// Copyright 2009 by Frederick Manligas Nacino.  Some rights reserved.

// This program is free software: you can redistribute it and/or modify
// it under the terms of the Lesser GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// Lesser GNU General Public License for more details.

// See http://www.gnu.org/licenses/.
		
// Visit the project page at http://www.celledoor.com/cpdv-ebe/.
// Legal usage requires this notice always remain in place. Do not remove.

var anchorHiliter =
{
	addHilites : function(idNumArray)
	{
		for (var i = 0; i < idNumArray.length; i++)
		{
			var s = idNumArray[i];
			var elem;
			elem = document.getElementById(s);
			if (elem)
			{
				this.addClass(elem, 'hilite');
			}
			elem = document.getElementById('_'+s);
			if (elem)
			{
				this.addClass(elem, 'hilite');
			}
		}
	},

	parseArgumentString : function(s)
	{
		var retVal = new Array();
		var argArray = s.split(',');
		for (var i = 0; i < argArray.length; i++)
		{
			retVal = retVal.concat(this.getRange(argArray[i]));
		}
		return retVal;
	},

	getRange : function(s)
	{
		if ( this.isInteger(s))
		{
			return [s];
		}

		var rangeArray = s.split('-');
		if (rangeArray.length < 1)
		{
			return [];
		}

		var first = rangeArray.shift();
		if (!this.isInteger(first))
		{
			return [];
		}

		first = parseInt(first);

		if (rangeArray.length < 1)
		{
			if (this.isInteger(first))
			{
				return [first];
			}
			else {
				return [];
			}
		}

		var second = rangeArray.shift();
		if (!this.isInteger(second))
		{
			return [first];
		}

		second = parseInt(second);

		if (first >= second)
		{
			return [first];
		}

		var countdown = 1000;
		var retVal = new Array();

		for (var i = first; i <= second && countdown >= 0; i++, countdown--)
		{
			retVal.push(i);
		}

		return retVal;
	},

	isInteger : function(i)
	{
		var asInt = parseInt(i);
		if (i == asInt.toString())
		{
			return true;
		}

		return false;
	},

	hasClass : function(object, className)
	{
		if (!object.className) return false;
		return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1);
	},

	addClass : function(object,className)
	{
		if (!object || this.hasClass(object, className)) return;
		if (object.className)
		{
			object.className += ' '+className;
		}
		else
		{
			object.className = className;
		}
	}
}

var queryString = window.location.search;

if (queryString)
{
	queryString = queryString.substring(1);
	var argArray = anchorHiliter.parseArgumentString(queryString);
	anchorHiliter.addHilites(argArray);
}
// Copyright 2009 by Frederick Manligas Nacino.  Some rights reserved.

// This program is free software: you can redistribute it and/or modify
// it under the terms of the Lesser GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// Lesser GNU General Public License for more details.

// See http://www.gnu.org/licenses/.
		
// Visit the project page at http://www.celledoor.com/cpdv-ebe/.
// Legal usage requires this notice always remain in place. Do not remove.
