﻿/// <reference path="ValueParser.js" />
/// <reference path="View.js" />

function Option(value, name)
{
	this._value = value;
	this._optionName = name;
	this._viewObject = null;
}

Option.prototype = {
	Execute : function()
	{
		var vp = new ValueParser();
		
		window.location = vp.Parse(this._value);
		
		return false;
	},
	get_OptionName : function()
	{
		return this._optionName;
	},
	get_Value : function()
	{
		return this._value;
	},
	get_View : function()
	{
		var search = document.getElementById('search');
		
		if (search)
		{
			var currentOption = this;
			search.onclick = function() { return currentOption.Execute(); };
		}
		
		search = null;
		
		return this.get_ViewObject().get_View(this._value);
	},
	get_ViewObject : function()
	{
		if (!this._viewObject)
		{
			this._viewObject = new View();
		}
		
		return this._viewObject;
	}
}