// JavaScript Document

	var HeavyRide =
	{
		
		Initialize: function ()
		{
			this.Navigation();
			this.Inputs();
			this.Cache();
			this.Extern();
			this.Boxes();
			this.InitializeFacebook();
		},
		Extern: function ()
		{
			var Links = document.getElementsByClassName('a', 'Extern');
			for(var i in Links)
			{
				Links[i].onclick = function ()
				{
					try
					{
						window.open(this.href);
					}
					catch(e) { }
					return(false);
				};
			}
		},
		Cache: function ()
		{
			var HoverImages = document.getElementsByClassName('img', 'Hover');
			for(var i in HoverImages)
			{
				var Cache = new Image();
				try
				{
					Cache.src = HoverImages[i].src.replace(/\.png/, '-hover.png');
				}
				catch(e) { }
			}
		},
		Navigation: function ()
		{
			var Navigation = document.getElementById('Navigation');
			for(var i in Navigation.childNodes)
			{
				if(typeof(Navigation.childNodes[i]) == 'object')
				{
					if(typeof(Navigation.childNodes[i].childNodes[0]) == 'object')
					{
						try
						{
							Navigation.childNodes[i].childNodes[0].onmouseover = this.Hover;
						}
						catch(e) { }
					}
				}
			}
		},
		Inputs: function ()
		{			
			var Inputs = document.getElementsByTagName('input');
			for(var i in Inputs)
			{
				if(Inputs[i].type == 'text')
				{
					Inputs[i].onclick = function ()
					{
						this.value = '';
					};
				}
			}
		},
		Hover: function ()
		{
			if(this.src.search('-hover') == -1)
			{
				this.src = this.src.replace(/\.png/, '-hover.png');
				this.onmouseout = function ()
				{				
					this.src = this.src.replace(/-hover\.png/, '.png');
				};
			}
		},
		SetHover: function (Sender)
		{
			Sender.onmouseover = this.Hover;
			Sender.onmouseover();
		},
		Boxes: function ()
		{
			$(ActiveBox).setStyle('display', 'block');
		},
		ShowBox: function (Box)
		{
			if(Box != ActiveBox)
			{
				$(ActiveBox).setStyle('display', 'none');
				$(ActiveBox + '-Header').className = '';
				$(Box).setStyle('display', 'block');
				$(Box + '-Header').className = 'Active';
				ActiveBox = Box;
			}
		},
		InitializeFacebook: function ()
		{
			$('Facebook-Fans').innerHTML = '<fb:fan profile_id="272742922233" stream="1" connections="21" width="220" height="910"></fb:fan>';
			FB.init("243ff53675a1e0d12193004075acae24");
		}
		
	}

	document.getElementsByClassName = function (Tag, Class)
	{
		var Matches  = new Array();
		var Elements = document.getElementsByTagName(Tag);
		for(var i in Elements)
		{
			if(typeof(Elements[i].className) != 'undefined')
			{
				if(Elements[i].className.search(Class) != -1)
				{
					Matches.push(Elements[i]);
				}
			}
		}
		return(Matches);
	}
