function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}



/////////////////////
// Newsletter scripts
//
function alphaChars(value) {
  var rvalue='';
  var c='';
  var n=0;
  var error;
  for (i=0; i<value.length; i++) {
    c = value.substring(i,i+1);
    if ('-_.'.indexOf(c)>=0) { rvalue+=c; }
    else {
      n = c.charCodeAt(0);
      // c in [a-z] [A-Z] [0-9]
      if (((n>=97)&&(n<=136))||(((n>=65)&&(n<=90))||((n>=48)&&(n<=57)))){
	rvalue+=c;
      }
    }
  }
  return rvalue;
}

LASTREQUEST=0;

function newsaction() {

  var thetime = new Date();
  var nowtime = thetime.getTime();
  //  var uniq = nowtime + Math.random();

  var email = document.getElementById("newsLetterAddress").value;

  // control email
  var emr = email.split('@');
  try{
    if (emr.length != 2) { stop; }
    var account = alphaChars(emr[0]);
    if (account != emr[0]) { stop; }
    var host = alphaChars(emr[1]);
    if (host != emr[1])  { stop; }
    if (host.indexOf('.')<0) { stop; }
  }
  catch(e) {
   alert('Adresse email non valide');
   return false;
  }

  // Server request
  var action;

  //if (formobj.insert[0].checked) {
	//  action='insert';
  //} else {
	//  action='remove';
  //}

  action='insert';
  var httpSendAddress = getHTTPObject();

  var newsSend = 'newsletter.php?action='+action;
  var param = '&email='+email+'&time='+nowtime;

  if (httpSendAddress.readyState == 4 || httpSendAddress.readyState == 0) {
	  httpSendAddress.open("POST", newsSend, true);
	  httpSendAddress.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    httpSendAddress.send(param);

      httpSendAddress.onreadystatechange = function () {
        if (httpSendAddress.readyState == 4) {
            results  = httpSendAddress.responseText;
            alert(results);
            email = '';
            return false;
        }
      }
  }
 return false;
}


//initiates the XMLHttpRequest object
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}