function construct(a) {
alert(a);
}



function login(interface_type){
  var host = "193.104.224.24:81";
  var cgi = "/cgi-bin/cqcgi/@eutelsat_com.env";
  var dc = new Date();
  var url = cgi + '?CQ_SAVE[CGI]=' + escape(cgi) + '&CQ_EUTELSAT_COM_PROCESS_LOGIN=YES&CQ_LOGIN=YES';
  url += '&CQDC=' + escape(dc) + '&CQ_SAVE[Cache_Counter]=0&CQ_SAVE[Summary_Type]=3&CQ_ACTIVATE_DOC_SUMMARY=YES';
  url += '&CQ_USER_NAME=simple_query&CQ_PASSWORD=anonymous&CQ_QUERY_TYPE=2&CQ_EXPANSION_LEVEL=3';
  url += '&CQ_QUERY_STRING=' + document.eutelsat_com_queryform.CQ_QUERY_STRING.value;
  url += '&CQ_SAVE[Expert_Mode]=NO&CQ_SAVE[Field_Language]=EN&CQ_SAVE[Refine_Query]=0&CQ_SAVE[Body_Bool]=NO';
  url += '&CQ_SAVE[Interface_Type]=' + interface_type;
  url += '&CQ_SAVE[Actual_Host]=' + escape(host);
  SearchWinID = launchWindow(url, "Search", "menubar=yes,scrollbars=yes", 740, 600);
  return(false);
}

function stripSpaces(value) {
  var start = 0;
  while (value.charAt(start) == " ") {
    start++;
  }
  var stop = value.length;
  while (value.charAt(stop - 1) == " ") {
    if ((stop - 1) < 0) {
      break;
    }
    stop--;
  }
  if (stop > start) {
    value = value.substring(start, stop);
  }
  else {
    value = "";
  }
  return(value);
}

function stripQuotes(value) {
  var newS = value;
  newS = newS.replace(/'/g, " ");
  return(newS);
}

function simpleQueryOLD() {
  var q = stripQuotes(document.eutelsat_com_queryform.CQ_QUERY_STRING.value);
  q = stripSpaces(q);

  if (q != "") {
    document.eutelsat_com_queryform.CQ_QUERY_STRING.value = q;
    login('simple');
  }
  else {
    alert("Please enter a query before searching.");
    document.eutelsat_com_queryform.CQ_QUERY_STRING.focus();
  }
}

function advancedQuery() {
  var q = stripQuotes(document.eutelsat_com_queryform.CQ_QUERY_STRING.value);
  q = stripSpaces(q);

  document.eutelsat_com_queryform.CQ_QUERY_STRING.value = q;

  login('advanced');
}

function simpleQuery() {
  var q = stripQuotes(document.eutelsat_com_queryform.CQ_QUERY_STRING.value);
  q = stripSpaces(q);

  document.eutelsat_com_queryform.CQ_QUERY_STRING.value = q;

  login('simple');
}

function launchWindow(theURL, winName, features, wi, he) {
  var w = 480, h = 340;

  if (document.all || document.layers) {
     w = screen.availWidth;
     h = screen.availHeight;
  }

  var popW = wi, popH = he;

  var leftPos = (w - popW) / 2, topPos = (h - popH) / 2;

  window.open(theURL, winName, features + ',width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
}


