var homepagelinks = [
	"/ftg/freetrial.html", 
	"/html/regform.html", 
	"/html/trading.html", 
	"/html/regform.html", 
	"/html/trading.html",
	"/html/regform-1m.html",  
	"/ftg/freetrial.html",
	"/html/regform.html", 
	"/html/regform-1m.html", 
	"/html/regform.html"];

function rnd_image()
{
   var now = new Date();
   var sec_divide = now.getSeconds();
   rnd_number = Math.floor(sec_divide/6);
   document.write('<a href="'+homepagelinks[rnd_number]+'"><img border="0" src="/images/home' + rnd_number +'.jpg" alt="Click here for One Week Free Trial"></a>');
}


function getExp(nodays)
{
	var UTCstring;Today = new Date();
	diff=Date.parse(Today);
	Today.setTime(diff+nodays*24*60*60*1000);
	UTCstring = Today.toUTCString();return UTCstring;
}
function getCookie(cookiename)
{	
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf(cookiename);
	if (index1==-1 || cookiename=="") return ""; 
	var index2=cookiestring.indexOf(';',index1);
	if (index2==-1) index2=cookiestring.length;	
	return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}
function setGhomeCookie (locale, country, cust_type)
{
	var LOC,CONTENTS,cookiestring;CONTENTS=cust_type+":"+locale+":"+country;
	cookiestring="ghome="+CONTENTS+";DOMAIN=.etrade.com;PATH=/;EXPIRES="+getExp(12000);document.cookie=cookiestring;
	setCountryLocaleCookie(locale, country);
}
function setCountryLocaleCookie(locale, country)
{
	var cookiestring;cookiestring=country+"_locale="+locale+";DOMAIN=.etrade.com;PATH=/;EXPIRES="+getExp(12000);
	document.cookie=cookiestring;
}  
function cookieThenRedirect(x)
{
	switch (x)
	{
	case "us_english":setGhomeCookie("en_US","US","visitor");this.location.href = "https://us.etrade.com/";break;
	case "us_german":setGhomeCookie("de_US","US","visitor");this.location.href = "http://deutsch-us.etrade.com/";break;
	case "us_chinese":setGhomeCookie("zh_TW","US","visitor");this.location.href = "https://us.etrade.com/";break;
	case "au":this.location.href = "http://www.etrade.com.au/";break;
	case "ca_french":setGhomeCookie("fr_CA","CA","visitor");this.location.href = "http://www.canada.etrade.com/french/index.shtml";break;
	case "ca_english":setGhomeCookie("en_CA","CA","visitor");this.location.href = "http://www.canada.etrade.com/";break;
	case "dk":this.location.href = "http://www.etrade.dk/";break;
	case "de_german":setGhomeCookie("de_DE","DE");this.location.href = "https://de.etrade.com";break;
	case "de_english":setGhomeCookie("en_DE","DE");this.location.href = "https://de.etrade.com/cgi-bin/gx.cgi/AppLogic+Home?locale=en_DE";break;
	case "hk_chinese":setGhomeCookie("zh_HK","HK","visitor");this.location.href = "https://hk.etrade.com/";break;
	case "hk_english":setGhomeCookie("en_HK","HK","visitor");this.location.href = "https://hk.etrade.com/";break;
	case "il":this.location.href = "http://www.etrade.co.il/";break;
	case "jp":this.location.href = "http://www.etrade.ne.jp/";break;
	case "ko_korean":this.location.href = "http://www.etrade.co.kr/index_ex.html";break;
	case "ko_english":this.location.href = "http://www.etrade.co.kr/en/index.html";break;
	case "se":setGhomeCookie("sv_SE","SE","visitor");this.location.href = "https://se.etrade.com/";break;
	case "uk":setGhomeCookie("en_GB","GB","visitor");this.location.href = "https://uk.etrade.com/";break;
	}
}
function checkValue(fname,fobj,fval)
{
	eval("document."+fname+"."+fobj+".value='"+fval+"'");
}
	
function setValue(fname,fobj,fval)
{
var val = eval("document."+fname+"."+fobj+".value");
	if(val=="")
	{
	eval("document."+fname+"."+fobj+".value='"+fval+"'");
	}
}


var secondlevel = new Array();
secondlevel[0] = new melem('/html/subscribe.html','Subscribe',1,1);
secondlevel[1] = new melem('/html/login.html','Member&nbsp;Login',91,86);
secondlevel[2] = new melem('/html/services.html','Services',206,191);
secondlevel[3] = new melem('/html/past-history.html','Historical&nbsp;Perfomance',286,266);
secondlevel[4] = new melem('/html/helpcenter.html','Help&nbsp;Center',288,421);

var a1 = new Array();
a1[0] = new elem('/html/register.html','Paying&nbsp;Subscription');
a1[1] = new elem('/ftg/freetrial.html','Free&nbsp;Trial');

var a2 = new Array();
a2[0] = new elem('','');

var a3 = new Array();
a3[0] = new elem('/html/aboutus.html','Overview');
a3[1] = new elem('/html/trading.html','Trading&nbsp;Made&nbsp;Simple');
a3[2] = new elem('/html/requirements.html','Requirements');

var a4 = new Array(); 
a4[0] = new elem('/html/aggregate3.html','Yearly');
a4[1] = new elem('/srvl/SignalsServlet','Monthly');
a4[2] = new elem('/html/traders.html','Daily');


var a5 = new Array();                              
a5[0] = new elem('/html/faq_categories.html','FAQ');
a5[1] = new elem('/ftg/freetrial.html','Online Tour');
a5[2] = new elem('/html/live_support.html','Live&nbsp;Support');
a5[3] = new elem('/html/resources.html','Resources');
a5[4] = new elem('/html/contact.html','Contact&nbsp;Us');
a5[5] = new elem('/html/sitemap.html','Site&nbsp;Map');

function getScreenWidth()
{

  var width = new String();
  
  if(window.innerWidth)
  {
    width = window.innerWidth;
  }else{
    width = document.body.clientWidth;
  }

  return width;	
}

function getScreenHeight()
{

  var height = new String();
  
  if(window.innerHeight)
  {
    height = window.innerHeight;
  }else{
    height = document.body.clientHeight;
  }

  return height;	
}

function popup()
{
  link="/ftg/tour.html";
  
  if(getScreenWidth() >= 800)
  {
    posX = (getScreenWidth() / 2) - 400;
    posY = (getScreenHeight() / 2) - 300;
  }
  else
  {
    posY = 0;
    posX = 0;
  }
  
  window.open(link, "_blank", 'width=800,height=600,toolbar=no,scrollbar=no,screenX='+posX+',screenY='+posY+',top='+posY+',left='+posX);
}

function flashTourPopup()
{
  link="tour.html";
  var param="toolbar=no, scrollbar=no, width=800, height=600, left=0, top=0)";
  window.open(link,"_blank",param);
}
