﻿ 
function setActiveTab(target)
{
    var tabNameClicked = target.id;
    var tabList = document.getElementById('ulTabList');
    var myTabs = new Array();
     
    myTabs = tabList.getElementsByTagName('li');
    
    for (var i = 0; i < myTabs.length; i++)
    {    
        var myNode;
        if (myTabs[i].firstChild.nodeType != 1)
            myNode = myTabs[i].childNodes[1];
        else
            myNode = myTabs[i].firstChild;
        
        var divId = 'd'+myNode.id.replace('tab','');
        var divDisplay = document.getElementById(divId); 
    
        if (myNode.id == tabNameClicked)
        {
            myNode.className = 'active'; 
            divDisplay.style.display = 'block';  
        }
        else
        {
            myNode.className = ''; 
            divDisplay.style.display = 'none';  
        }
    }
}

function findtime(h1,h2,days,m1,m2,am1,am2)
{
    var answer = "why";
    var mdiff = 1;
    var hdiff = 2;
    pdays = parseInt(days);
    ph1 = parseInt(h1);
    ph2 = parseInt(h2);
    pm1 = parseInt(m1);
    pm2 = parseInt(m2);
    if(am1 == 2 & ph1 < 12) ph1 = ph1 + 12;
    if(am2 == 2 & ph2 < 12) ph2 = ph2 + 12;
    if(am1 == 1 & ph1 == 12) ph1 = 24;
    if(am2 == 1 & ph2 == 12) ph2 = 24;
    if(am1 == 2 & am2 == 1 & ph2 < 24) ph2 = ph2 + 24;
    if(am1 == am2 & ph1 > ph2) ph2 = ph2 + 24;
    if(pm2 < pm1){
    pm2 = pm2 + 60;
    ph2 = ph2 - 1;
    }
    mdiff = pm2 - pm1;
    hdiff = (ph2 - ph1) + (pdays * 24);
    if(hdiff == 0) answer = mdiff + ' minutes';
    else if(hdiff == 1) answer = '1 hour and ' + mdiff + ' minutes'
    else answer = hdiff + ' hours and ' + mdiff + ' minutes'
    return answer
}


function toggle(obj)
{
    var el = document.getElementById(obj);
    el.style.display = (el.style.display != 'none' ? 'none' : '' );
    return false;
}

function toggleLayer(theshown,thehidden,thehidden2,signup,thestyle)
{
	var d = document;

	if (!thestyle)
	{
		thestyle = 'block';
	}
	
	if (theshown!='')
	{
		if (d.getElementById(theshown).style.display=='none' || (d.getElementById(theshown).style.display == '' && thestyle != 'table-row'))
		{
			if (thestyle == 'table-row')
			{
                d.getElementById(theshown).style.display = '';			    
			}
			else
			{
                d.getElementById(theshown).style.display = thestyle;   
			}
		}
		else
		{
			if (!signup)
			{
				d.getElementById(theshown).style.display = 'none';
			}
		}
	}
	
	if (thehidden)
	{
		d.getElementById(thehidden).style.display = 'none';
	}
	
	return false;

	if (thehidden2)
	{
		d.getElementById(thehidden2).style.display = 'none';
	}
}

function swapDashboard(target)
{
    var tab = (target.id).substring(1);
    var dC,dO,aC,aO,iC,iO;
    dC = document.getElementById("dClassic");
    dO = document.getElementById("dOverviewDash");
    aC = document.getElementById("aClassic");
    aO = document.getElementById("aOverviewDash");
    iC = document.getElementById("iClassic");
    iO = document.getElementById("iOverview");

    if (tab == "Classic")
    {
        if (dC) dC.style.display="block";
        if (dO) dO.style.display="none";
        if (aC) aC.className = "active";
        if (aO) aO.className = "";
        if (iC) iC.src = '/Images/ico_classic_on.gif';
        if (iO) iO.src = '/Images/ico_overview_off.gif';
    }
    else
    {
        if (dC) dC.style.display="none";
        if (dO) dO.style.display="block";
        if (aC) aC.className = "";
        if (aO) aO.className = "active";
        if (iC) iC.src = '/Images/ico_classic_off.gif';
        if (iO) iO.src = '/Images/ico_overview_on.gif';
        toggleOverview();
    }

}
function expandTipsList(target)
{
  document.getElementById("TipsNewTrader").className = "";
  document.getElementById("TipsNewTraderContent").style.display = "none";
  
  document.getElementById("TipsAdvancedTrading").className = "";
  document.getElementById("TipsAdvancedTradingContent").style.display = "none";
  
  document.getElementById("TipsTradingStrategies").className = "";
  document.getElementById("TipsTradingStrategiesContent").style.display = "none";
  
  document.getElementById("TipsTechnicalAnalysis").className = "";
  document.getElementById("TipsTechnicalAnalysisContent").style.display = "none";
  
  document.getElementById("TipsChartsStockResearch").className = "";
  document.getElementById("TipsChartsStockResearchContent").style.display = "none";
  
  document.getElementById("TipsManagingRisk").className = "";
  document.getElementById("TipsManagingRiskContent").style.display = "none";
  
  document.getElementById("TipsAssetAllocation").className = "";
  document.getElementById("TipsAssetAllocationContent").style.display = "none";
  
  document.getElementById("TipsStockMarketsSentiment").className = "";
  document.getElementById("TipsStockMarketsSentimentContent").style.display = "none";

  document.getElementById(target.id).className = "active";
  var ulContent = document.getElementById(target.id + 'Content');
  if (ulContent)
  {
    ulContent.style.display = "block";
  }
}

function Confirm(message)
{
    var OK = confirm(message);
    return OK ? true : false;
}

//Use the function below to add your function without replacing what is already in the window.onload
function addOnloadEvent(fnc){
  if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", fnc, false );
  else if ( typeof window.attachEvent != "undefined" ) {
    window.attachEvent( "onload", fnc );
  }
  else {
    if ( window.onload != null ) {
      var oldOnload = window.onload;
      window.onload = function ( e ) {
        oldOnload( e );
        window[fnc]();
      };
    }
    else 
      window.onload = fnc;
  }
}




