// FEC Resources, Inc Javascript for site - designed by www.fwoss.com
var menuoff = false; // default setting that determines whether the menu is visible at the start.
var debug = false;

//var RootPath = "http://localhost/clients/FEC Resources/Public/";
//var RootPath = "http://preview.fwoss.com/fecr/";
var RootPath = "http://www.fecresources.com/";

function Postautoform()
{
	var form = document.getElementById("mainform");
	addToForm(form,"ContactForm:posted","1");
	form.submit();
}

var currentOrg = "org1";

function ShowNews(year)
{
	var form = document.getElementById("mainform");
	addToForm(form,"year",year);
	form.submit();
}

function changeOrgansiation(id)
{
	try
	{
		var organisationoff = document.getElementById(currentOrg);
		var organisationon = document.getElementById(id);
				
		organisationon.className = "organisation";
		organisationoff.className = "invisible";
		
		currentOrg = id;
	}
	catch(err)
	{
		if(debug)
		{
			alert(err.message);
		}		
	}
}

function imageOn(id)
{
	try
	{
		var image = document.getElementById(id);
		image.src = RootPath + "images/buttonon.gif";
	}
	catch(err)
	{
		if(debug)
		{
			alert(err.message);
		}
	}
}

function imageOff(id)
{
	try
	{
		var image = document.getElementById(id);
		image.src = RootPath + "images/buttonoff.gif";
	}
	catch(err)
	{
		if(debug)
		{
			alert(err.message);
		}
	}
}

function changeImage(id)
{
	var Id = String(id).replace("menuitem","");
	
	try
	{
		var button;
		var pic;
		
		var image = document.getElementById("menuitem" + Id);
		var pic = document.getElementById("menupic" + Id);
		
	
		if(String(image.src).indexOf("on.")==-1)
		{
			image.src = RootPath + "images/menu/button" + Id + "on.gif";
			pic.src = RootPath + "images/menu/pic" + Id + "on.jpg";
		}
		else
		{
			image.src = RootPath + "images/menu/button" + Id + ".gif";
			pic.src =  RootPath + "images/menu/pic" + Id + ".jpg";
		}
	}
	catch(err)
	{
		if(debug)
		{
			alert(err.message);
		}		
	}
}

function Showsubmenu()
{
	var submenu = document.getElementById("Corporatesub");
	
	if(menuoff)
	{
		submenu.className = "Menulevel2";
		menuoff = false;
	}
	else
	{
		submenu.className = "invisible";
		menuoff = true;
	}
	
}

function setTarget(e, target)
{
	//Get source element...
	var eSrc;
     if( !e )
     {
         eSrc = window.event.srcElement;
     }
     else
     {
         eSrc = e.srcElement;
         if( !eSrc )
             eSrc = e.target;
     }
	
	//Walk up tree until we get to an A. 
	while(eSrc.tagName != "A" && String(eSrc) != "undefined" )
	{
		if(eSrc.parentElement)
			eSrc = eSrc.parentElement;
		else
			eSrc = eSrc.parentNode;
	}
	
	//Set the target.
	eSrc.target=target;
	
	return false;
}

var ie = (document.all)?true:false;
var nn = (document.layers)?true:false;

function showKey(e)
{
	var icode,ncode,key;
	try
	{
		if(ie)
		{
			icode = event.keyCode; ncode = 0;
			key=String.fromCharCode(event.keyCode);
		}
		if(nn)
		{
			icode = 0; ncode = e.which; key=String.fromCharCode(e.which);
		}
		if(icode == 13 || ncode == 13)
		{
			// Logs in the user if the enter key is pressed.
			LoginUser();
		}
	}
	catch(err){}
}

function ShowForumPopUp()
{
	// Opens up the welcome popup.
	//OpenInWindow("welcome.aspx",550,600);
}

function ShowFinancePopUp()
{
	// var path = "http://finance.yahoo.com/q?s=FECOF.OB";
	var path = "http://finance.yahoo.com/q?s=FECOF.OB";
	OpenInScrollingWindow(path,750,600);
}

function ShowResearchPopUp()
{
	var path = RootPath + "investors/research.aspx";
	OpenInWindow(path,400,250);	
}

function LoginUser()
{
	// Resubmitting the form triggers the login attempt.
	var form = GetForm();
	
	// Enables the login component.
	EnableComponent(form,"FWOSS:LoginControl:Enabled");
		
	form.submit();
}