 //version1 
var fundnewwindow=false;


//version1 
var hifpSignin = "https://financialprofessional.hartfordinvestor.com/portal/HI_process_signin.jsp";
var hifpRegister="https://financialprofessional.hartfordinvestor.com/portal/user/register_user_internal_certify.jsp";

var myWindow;

//open window in the new browser
function openBrWindow(theURL,winName,features) { //v2.0

    if(myWindow!=null)
    {
        window.myWindow.close();
        myWindow = window.open(theURL,winName,features);

    }else
    {
        myWindow = window.open(theURL,winName,features);
        myWindow.focus();
        //alert("Event");
        //window.releaseEvents(Event.Focus);
        //releaseFocus(Event.Focus);


    }

}

function releaseFocus(e)
{
    if (e)
    {
        if (e.Focus)
        {
            window.releaseEvents(Event.Focus);
        }
    }
}

function checkForEnterhifp(e)
{
    if (e)
    {
        if ((e.which == "13") || (e.keyCode == "13"))
        {
            submitHIFP();
        }
    }
}


//this is for Hartford Hedge Funds
function gettime()
    {
        var d = new Date()
        d.toLocaleDateString
        s = (d.getMonth() + 1) + '/' + d.getDate() + "/" + d.getFullYear();
        s = s + ' ' + d.getHours() + ':';
        s = s + (d.getMinutes() + 5);
        document.forms.login_form_hifp.clienttime.value=s;
    }

//--------------------HIFP Login   ---------------


function checkIdpass()
{
    if ((document.login_form_hifp.tin_1.value == "") ||
        (document.login_form_hifp.pin_1.value == "" && document.login_form_hifp.pin_1.disabled == false))
    {
            alert("Please enter your User ID and Password to login");
            document.login_form_hifp.tin_1.focus();
             return false;
    }
    else if ((document.login_form_hifp.tin_1.value.toLowerCase() == "planco") &&
     (document.login_form_hifp.pin_1.value.toLowerCase() == "planco"))
        {
            alert("To all users of the Planco website:\n\n" +
                      "In order to access our new website, you will need to register.");
                    document.login_form_hifp.tin_1.focus();
                     return false;

        }

    else if ((document.login_form_hifp.tin_1.value.toLowerCase() == "leaders") &&
                (document.login_form_hifp.pin_1.value.toLowerCase() == "leaders"))
       {
           alert("To all users of The Hartford Leaders website:\n\n" +
                     "In order to access our new website, you will need to register.");
                    document.login_form_hifp.tin_1.focus();
                     return false;
       }

    else
    {
       return true;
    }

}

function submitHIFP()
{

    if(checkIdpass())
    {
     
        loginFormObject = document.forms.login_form_hifp;
        if(isCookie('remember_me'))
        {
           loginFormObject.hauser.value = "";
           loginFormObject.password.value = "";
        }
        else
        {
           loginFormObject.hauser.value = loginFormObject.tin_1.value;
           loginFormObject.password.value = loginFormObject.pin_1.value;
      
        }
 
        //loginFormObject.action= hifpSignin; 
        //openBrWindow('','formRedirect','location=1,resizable=yes,toolbar=yes,menubar=yes,scrollbars=yes,status=yes,width=790,height=600');
  
       
        loginFormObject.submit();
       setFields("");
        //loginFormObject.pin_1.value = "";
        //loginFormObject.tin_1.value = "";
        //loginFormObject.rememberMeBox.checked = false;
    }
    else{
      return false;
  }
}

//register HIFP
function sendToRegister(regtype)
{

    var hifpRegister="https://financialprofessional.hartfordinvestor.com/portal/user/register_user_internal_certify.jsp";
  if(regtype=="mf"){
   var hifpRegister="https://financialprofessional.hartfordinvestor.com/portal/user/register_user_internal_certify.jsp?pageID=mf_main";
  
  }
 
  openBrWindow(hifpRegister,'','resizable=yes,toolbar=yes,menubar=yes,scrollbars=yes,width=640,height=420');
  
}
//Remember Me
function isOldBrowserVer()
{
      nn4=((parseInt(navigator.appVersion)>=4 && parseInt(navigator.appVersion)<5)&&(navigator.appName.indexOf("Netscape")!=-1))?1:0

       if(nn4)
       {
          return true;
       }
       else
       {
         return false;
       }
}
function askRemoveCookie(name)
{
    var removeCookie = confirm("Disable Remember Me?");
    if (removeCookie == true)
    {
                deleteCookie(name);
                document.login_form_hifp.tin_1.value ='';
                document.login_form_hifp.pin_1.value ='';
                document.login_form_hifp.tin_1.className='fieldEnabled';
                document.login_form_hifp.pin_1.className='fieldEnabled';
                document.login_form_hifp.tin_1.readOnly = false;
                document.login_form_hifp.pin_1.readOnly = false;
                document.login_form_hifp.remember.value = 'N';
    }else
    {
    document.login_form_hifp.rememberMeBox.checked = true;
    document.login_form_hifp.remember.value = 'Y';
    }
}
function setFields(value)
{
   var pin = "";
   document.login_form_hifp.tin_1.value = value;
   document.login_form_hifp.pin_1.value = pin;
   document.login_form_hifp.tin_1.readOnly = false;
   document.login_form_hifp.pin_1.readOnly = false;
   document.login_form_hifp.rememberMeBox.checked = false;
   //document.login_form_hifp.remember.value = 'N';
    if (value != '')
    {
        document.login_form_hifp.tin_1.value = value;
        document.login_form_hifp.pin_1.value = 'zzzzzzzzzz';
        document.login_form_hifp.tin_1.className='fieldDisabled';
        document.login_form_hifp.pin_1.className='fieldDisabled';
        document.login_form_hifp.tin_1.readOnly = true;
        document.login_form_hifp.pin_1.readOnly = true;
        document.login_form_hifp.rememberMeBox.checked = true;
        document.login_form_hifp.remember.value = 'Y';
    }
    else
    {
        document.login_form_hifp.tin_1.value ='';
        document.login_form_hifp.tin_1.className='fieldEnabled';
        document.login_form_hifp.pin_1.className='fieldEnabled';
        document.login_form_hifp.tin_1.readOnly = false;
        document.login_form_hifp.pin_1.readOnly = false;
        document.login_form_hifp.rememberMeBox.checked = false;
       // document.login_form_hifp.remember.value = 'N';
    }
}

function updateRememberMe(name)
{
  if (isOldBrowserVer())
  {
    alert("This option is not supported with this browser version.  To upgrade your browser go to www.netscape.com.");
    document.login_form_hifp.rememberMeBox.checked = false;
     document.login_form_hifp.remember.value = 'N';
  }
  else
  {
                if(document.login_form_hifp.rememberMeBox.checked == false && document.login_form_hifp.pin_1.readOnly == true)
                {
                    askRemoveCookie(name);
                     document.login_form_hifp.remember.value = 'N';
                }
                else
                {
      if(document.login_form_hifp.rememberMeBox.checked){
        document.login_form_hifp.remember.value = 'Y';
        }else{
         document.login_form_hifp.remember.value = 'N';
          }
                    ;
                   
                }
    }

}


function getHIFPCookie()
{
   
    var name="remember_me";
    var value = "";
    var aCookie ="";
    aCookie=document.cookie;
    //alert(aCookie);
    if (document.cookie.length > 0) 
    { 
      name=name+"=";
      begin = document.cookie.indexOf(name,0);
    
    if (begin != -1)   
    { 
      //begin += name.length+1; 
      begin = begin+name.length; 
      end = document.cookie.indexOf(";", begin);
      if (end == -1) 
      {
        end=document.cookie.length;
      }
      value = unescape(document.cookie.substring(begin, end)); 
      //default to fp tab on login
      financialprofessionaltabOn('true');
    }
    
    } 
  setFields(value);
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
  //alert("name="+name);
  //alert("value="+value);
  //alert("expires="+expires);
  
  //alert("passed-expire="+expires);
  // set time, it's in milliseconds
  var today = new Date();
  today.setTime( today.getTime() );

  /*
  if the expires variable is set, make the correct
  expires time, the current script below will set
  it for x number of days, to make it for hours,
  delete * 24, for minutes, delete * 60 * 24
  */
  
if ( expires )
{
  expires = expires * 1000 * 60 * 60 * 24;
}
  var expires_date = new Date( today.getTime() + (expires) );
  //alert("Testing Cookie expires="+ expires_date);
  document.cookie = name + "=" +escape( value ) +
  ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
  ( ( path ) ? ";path=" + path : "" ) +
  ( ( domain ) ? ";domain=" + domain : "" ) +
  ( ( secure ) ? ";secure" : "" );
}

function isCookie(name)
{
    var aCookie ="";
    var
    aCookie=document.cookie;
        if (document.cookie.length > 0)
        {
         name=name+"=";
         begin = document.cookie.indexOf(name,0);
                if (begin != -1)
                {
                    return true;
                }
                else
                {
                    return false;
                }
        }
}

function deleteCookie(name)
{
document.cookie = name + "=; path=/; domain=hartfordinvestor.com; expires=Thu, 01-Jan-70 00:00:01 UTC";
}
//End Remember Me


//check for defaultab cookie
function setdefaulttab(passedtab){
var mytab = Get_Cookie('InvestorTabDefault');
//alert("MyTab"+mytab);
  if(mytab!=passedtab){
    Set_Cookie( 'InvestorTabDefault', passedtab, 1000, '/', '', '' );
  }
}

function setdefaultclientoption(clientloginoption){
  var clientdefault = Get_Cookie('InvestorClientLogin');
  //alert(clientloginoption);
  if(clientdefault!=clientloginoption){
    Set_Cookie( 'InvestorClientLogin', clientloginoption, 1000, '/', '', '' );
    }
  
}



function checkclientlogin(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {
        //alert(btn[i].value);
        setdefaultclientoption(btn[i].value);
        cnt = i; i = -1;
        //
       
        }
        
    }
   //alert(cnt)
    if (cnt > -1) {
     return true;
     }
    else{
      alert("Please select an option");
       return false;
    }
}

function onClickFund(fundName) {

  split = fundName.indexOf("_");
  prod = fundName.substring("0", split);
  //fundsplit = fundName.indexOf(".");
  fundbegin = (split + 1);
  fundend = fundName.indexOf(".");
  fund = fundName.substring(fundbegin, fundend);
//alert(fund);
//alert(prod);
//alert(currpage);
fundurl = "/servlet/Satellite?pagename=Investor/Page/HLI_RedirectFund&site=HI&fund=" + fund + "&prod=" + prod + "&currpage=" + currpage;

//alert(fundurl);
if(fundnewwindow==false){
  window.location=fundurl;
}else{  
  openBWindow(fundurl, "pf", "true", "610", "500", "10", "10");
}

}


function removeChars(p_string, p_delim) {
  var v_retString = ""; 
  var v_splitString = p_string.split(p_delim);
  for(var i=0; i < v_splitString.length; i++) {
    v_retString += v_splitString[i];
  }
  return v_retString;
  }

function submitFund() {
  var v_fs = removeChars(document.Form_FundLookup.FundSymbol.value, " ");
  v_fs = removeChars(v_fs, ",");
  if (v_fs == "") {
    alert("Enter Fund Symbol.");
    document.Form_FundLookup.FundSymbol.value = "";
    document.Form_FundLookup.FundSymbol.focus();
    return false;
  }
  else {
    var v_countMatches = 0; 
    var v_fundDetailsURL = 0;
    //if one match exactly, go to fund
    for (var k=0; k<v_FundsSymbols.length; k++) {
      if (v_FundsSymbols[k].toUpperCase().indexOf(v_fs.toUpperCase()) >= 0) {       
        v_fundInfo = v_FundsArray[k].split("|");              
        v_fundDetailsURL = v_fundURL+v_fundInfo[0];   
        if (++v_countMatches > 1) break;    
      }
    }
    if (v_countMatches == 1) {
      window.location = v_fundDetailsURL;
      return false;
    }
  }
  return true;
}


var dropdownopen= false;
function dropdownoptions(){
  document.body.onclick = function(){
    if(dropdownopen==true){
      changeDisplayClass('drop-down-options', 'block');
      dropdownopen=false;
    }else{
      changeDisplayClass('drop-down-options', 'none');
    }
  }
}

 function salesOrderMaterialPopup(srchtype,srchtxt)
 {
  var url = "https://financialprofessional.hartfordinvestor.com/portal/index.jsp?pageID=sales_order_material&searchType="+srchtype+"&searchText="+srchtxt;
  window.open(url,'SalesOrderMaterial',"width=530,height=440,scrollbars=yes,resizable=yes");
 }

function onClickFundSymbol(symbol) {
  prod = "mutualfund";
  fundurl = "/servlet/Satellite?pagename=HI/Page/RedirectFund&site=HLI&asymbol=" + symbol + "&prod=" + prod + "&currpage=" + currpage;
  if(fundnewwindow==false){
    window.location=fundurl; 
  }
  else{ 
    openBWindow(fundurl, "pf", "true", "610", "500", "10", "10");
  }

}

currlocation = new String(window.location);
function rateMVA(fileName)
{
  if(fileName!=""){
    if(currlocation.indexOf("&mva")>=0){
      currlocation = currlocation.substring(0,currlocation.indexOf("&mva"));
    }
    window.location = currlocation + "&mva=" + fileName;
  }
}

//-->

