﻿function OpenPdfFactSheet(isin, classname, lang) {
  var w = window.open("/factsheet/" + isin.toString().toUpperCase() + "-" + lang.toString().substring(0, 2).toUpperCase() + ".pdf", "_blank", "left=5,top=5,status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=600,width=850");
}
function EmailCheck(elem, helperMsg) {
  var str = elem.value;
  var at = "@";
  var dot = ".";
  var lat = str.indexOf(at);
  var lstr = str.length;
  var ldot = str.indexOf(dot);

  // var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
  // if (str.match(emailExp)) { return true; }

  if (str.indexOf(at) == -1) {
    alert(helperMsg);
    elem.focus();
    return false
  }

  if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr) {
    alert(helperMsg);
    elem.focus();
    return false
  }

  if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr) {
    alert(helperMsg);
    elem.focus();
    return false
  }

  if (str.indexOf(at, (lat + 1)) != -1) {
    alert(helperMsg);
    elem.focus();
    return false
  }

  if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot) {
    alert(helperMsg);
    elem.focus();
    return false
  }

  if (str.indexOf(dot, (lat + 2)) == -1) {
    alert(helperMsg);
    elem.focus();
    return false
  }

  if (str.indexOf(" ") != -1) {
    alert(helperMsg);
    elem.focus();
    return false
  }

  return true
}

//function SubscribeNewsletter() {
//  if (EmailCheck(document.forms[0].newsletter_email.value) == false) {
//    alert('Please, specify a valid email address');
//  }
//  else {
//    alert('Thank you!\n\'' + document.forms[0].newsletter_email.value + '\' has been subscribed to Atomo Sicav\'s newsletter');
//    document.forms[0].newsletter_email.value = 'Enter your email...';
//  }
//}

function DisclaimerFormCheck(MyForm, TextMessage, WarningItalianResident) {
  if (MyForm.DisclaimerCheckBox.checked == false) {
    alert(TextMessage);
  }
  else {

    if (MyForm.ItalianResidentCheckBoxYes && MyForm.ItalianResidentCheckBoxNo) {
      if (MyForm.ItalianResidentCheckBoxYes.checked == false && MyForm.ItalianResidentCheckBoxNo.checked == false) {
        alert(WarningItalianResident);
        return void (0);
      }
      else if (MyForm.ItalianResidentCheckBoxYes.checked == true && window.location.href.indexOf("/it-it/") == -1) {
        window.location.href = window.location.protocol + "//" + window.location.host + "/it-it/index.aspx?reloaded=yes";
        return void (0);
      }
      else if (MyForm.ItalianResidentCheckBoxYes.checked == true && window.location.href.indexOf("/it-it/") != -1) {
        window.location.href = window.location.protocol + "//" + window.location.host + "/it-it/home.aspx";
        return void (0);
      }
      else if (MyForm.ItalianResidentCheckBoxNo.checked == true) {
        window.location.href = window.location.protocol + "//" + window.location.host + "/en-us/home.aspx";
        return void (0);
      }
    }

    if (window.location.pathname != "/")
      window.location.href = window.location.protocol + "//" + window.location.host + window.location.pathname.toLowerCase().replace("index.aspx", "home.aspx");
    else
      window.location.href = window.location.protocol + "//" + window.location.host + "/home.aspx";
  }
}

