function openTickerPopup(ticker,market) {
  var url = "";
  url = "symbol_stat.jsp?ticker="+ticker.toUpperCase() + "&market="+market;
  parent.location = url;
}

function openTickerNewsBody(id, market,ticker) {
  //alert("In openTickerNewsBody" + ticker);
  if (screen) {
    url = 'newsbody.jsp?id='+id + '&market='+market + '&ticker='+ticker;
    parent.location = url;
  }
}
function openTickerFilingsBody(id, market,ticker) {
  //alert("In openTickerNewsBody" + ticker);
  if (screen) {
    url = 'filingsbody.jsp?id='+id + '&market='+market + '&ticker='+ticker;
    parent.location = url;
  }
}

function openLink(linkU) {
   if (screen) {
     url = linkU;
     sHeight = screen.height;
     sWidth = screen.width;
     wHeight = 530;    //new window height 730
     wWidth = 650;     //new window width
     wLeft = (sWidth - wWidth) / 2;  //left position
     wTop = (sHeight - wHeight) / 2; //top position
     //var win = window.open(url, "", "left=" + wLeft + ",top=" + wTop + ",width=" + wWidth + ",height=" + wHeight + ",scrollbars=yes,resizeable=yes");
     var win = window.open(url);
     win.focus();
   }
}

function openLinkSmWin(linkU) {
   if (screen) {
    url = linkU;
    sHeight = screen.height;
    sWidth = screen.width;
    wHeight = 530;    //new window height 730
    wWidth = 650;     //new window width
    wLeft = (sWidth - wWidth) / 2;  //left position
    wTop = (sHeight - wHeight) / 2; //top position
    var win = window.open(url, "", "left=" + wLeft + ",top=" + wTop + ",width=" + wWidth + ",height=" + wHeight + ",scrollbars=yes,resizable=yes");
    win.focus();
   }
}

function openLinkSmWin(linkU,market) {
  if (screen) {
   url = linkU + '&market='+market;
   sHeight = screen.height;
   sWidth = screen.width;
   wHeight = 530;    //new window height 730
   wWidth = 650;     //new window width
   wLeft = (sWidth - wWidth) / 2;  //left position
   wTop = (sHeight - wHeight) / 2; //top position
   var win = window.open(url, "", "left=" + wLeft + ",top=" + wTop + ",width=" + wWidth + ",height=" + wHeight + ",scrollbars=yes,resizable=yes");
   win.focus();
  }
}

function ClipBoard(){
  document.forms.form1.text_area.focus();
  document.forms.form1.text_area.select();
  Copied = document.forms.form1.text_area.createTextRange();
  Copied.execCommand("Copy");
}

function validateInputDate() {
  //alert("validateInputDate");
  var f = true;

  var text = /\w+/;
  var form = document.form1;

  if(form.date.value == "" || form.date.value.match(text) == null){
    //alert("Please enter date as YYYYMMDD");
    form.name.focus();
  }
  else
    form.submit();
}
function openLinkWin(linkU,form) {
  var url;
  var selectType = form.selectType.value;
  var ticker = form.ticker.value;
   if (screen) {
    url = linkU + '?ticker='+ticker+'&popType='+selectType;
    sHeight = screen.height;
    sWidth = screen.width;
    wHeight = 530;    //new window height 730
    wWidth = 650;     //new window width
    wLeft = (sWidth - wWidth) / 2;  //left position
    wTop = (sHeight - wHeight) / 2; //top position
    var win = window.open(url, "", "left=" + wLeft + ",top=" + wTop + ",width=" + wWidth + ",height=" + wHeight + ",scrollbars=1,resizable=1,toolbar=1,menubar=0,status=1,titlebar=1");
    win.focus();
   }
}
function openTickerOnGo(form) {
  //alert("openTickerOnGo");
  var ticker = form.ticker.value;
  if(ticker == '') {alert("Insert symbol value"); return false;}
  url = "symbol_market_redirect.jsp?ticker="+ticker.toUpperCase();
  parent.location = url;
  return true;
}

function regNewsLetterUser(form) {
  //alert("regNewsLetterUser");
  var string=form.email.value;
  if(!isEmail(string)) return;
  else{

  }
  url = "recap_reg/reg.jsp?email="+string;
  parent.location = url;

//  if (screen) {
//    url = "html_main_nav.jsp?email="+string;
//    sHeight = screen.height;
//    sWidth = screen.width;
//    wHeight = 530;    //new window height 730
//    wWidth = 650;     //new window width
//    wLeft = (sWidth - wWidth) / 2;  //left position
//    wTop = (sHeight - wHeight) / 2; //top position
//    var win = window.open(url, "", "left=" + wLeft + ",top=" + wTop + ",width=" + wWidth + ",height=" + wHeight + ",scrollbars=1,resizable=1,toolbar=1,menubar=0,status=1,titlebar=1");
//    win.focus();
//  }

  return true;
}
function isEmail(string) {

  if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
    return true;
  else {
    alert("Please input a valid email address!")
    return false;
  }
}