var pages = ['index.html', 'irs-solutions.html', 'payroll-tax.html', 'owing-the-irs.html', 'delinquent-returns.html', 'offer-in-compromise.html', 'bankruptcy.html', 'irs-audit.html', 'think-again.html', 'contact-me.html', 'irs-forms.html', 'payment.php', 'tax-relief-free.html'];

function option_clicked(opt, evnt)
{
	if (evnt == "click") {
		if (opt.id && document.getElementById(opt.id).getAttribute("goto"))
		{
			document.location = document.getElementById(opt.id).getAttribute("goto");
		}
		else if (pages[opt.getAttribute("optionIndex")] == 'payment.php')
		{
			document.location = "https://www.taxproblem.org/payment.php";
		}
		else if (pages[opt.getAttribute("optionIndex")] == 'index.html')
		{
			document.location = "http://www.irsadvisorchecklist.com/index.html";
		}
		else
		{
			document.location = "http://www.taxproblem.org/" + pages[opt.getAttribute("optionIndex")];
		}
	}
}

function bmeffect(objName, container_id, css_default, css_over, css_selected, option_type, callback_function, isSelected)
{
	this.objName = objName;
	this.container_id = container_id;
	
	this.option_type = option_type ? option_type : 'DIV';
	this.callback_function = callback_function;
	this.options_index = 0;
	this.isSelected = isSelected ? isSelected : 0;

	this.css = new Array();
	this.css['default'] = css_default;
	this.css['over'] = css_over;
	this.css['selected'] = css_selected;

	this.last_selected = null;
	this.last_hovered = null;
	this.last_hovered_class = null;
	
	this.options_container = document.getElementById(this.container_id);
	
	this.options_container.setAttribute("bmeObj", objName);

	this.event_over = function(el)
	{

		if(this.last_hovered)
		{
			this.last_hovered.className = this.last_hovered_class;
		}

		this.last_hovered_class = el.className;

		el.className = this.css['over'];

		this.last_hovered = el;
		
		if(callback_function)
		{
			callback_function(el, "over");
		}

	};

	this.event_out = function(el)
	{

		if(this.last_hovered)
		{
			this.last_hovered.className = this.last_hovered_class;
		}


		this.last_hovered = null;
		this.last_hovered_class = null;
		

		if(callback_function)
		{
			callback_function(el, "out");
		}
	};

	this.event_click = function(el)
	{

		if(this.last_selected)
		{
			this.last_selected.className = this.css['default'];
		}

		this.last_hovered_class = this.css['selected'];

		el.className = this.css['selected'];

		this.last_selected = el;

		if(callback_function)
		{
			callback_function(el, "click");
		}

	};
	
	for (node_index=0; node_index < this.options_container.childNodes.length; node_index++)
	{
		if (this.options_container.childNodes[node_index].nodeName == option_type)
		{	
			this.options_container.childNodes[node_index].setAttribute("optionIndex", this.options_index);
			
			this.options_container.childNodes[node_index].className = this.css['default'];
			
			this.options_container.childNodes[node_index].onmouseover = function()
			{
				eval(this.parentNode.getAttribute("bmeObj") + ".event_over(this);");
			};
			
			this.options_container.childNodes[node_index].onmouseout = function()
			{
				eval(this.parentNode.getAttribute("bmeObj") + ".event_out(this);");
			};
			
			this.options_container.childNodes[node_index].onclick = function()
			{
				eval(this.parentNode.getAttribute("bmeObj") + ".event_click(this);");
			};
			
			var goSelect = false;
			
			if (this.isSelected)
			{
				if (this.isSelected - 1 == this.options_index)
				{
					goSelect = true;
				}
			}
			else if (this.options_container.childNodes[node_index].getAttribute("isSelected") == "yes")
			{
				goSelect = true;
			}
			
			if (goSelect)
			{
				this.last_hovered_class = this.css['selected'];
				this.options_container.childNodes[node_index].className = this.css['selected'];
				this.last_selected = this.options_container.childNodes[node_index];	
			}
			
			this.options_index++;
		}
	}
}
