function popupFile( _url, _width, _height) {
  if( !_width ) {
    _width = 680;
  }
  if( !_height ) {
    _height = 500;
  }
  window.open( _url, "", "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width="+_width+",height="+_height+"");
}

function popupFileFull( _url, _width, _height, _left, _top, _x, _y) {
  if( !_width ) {
    _width = 680;
  }
  if( !_height ) {
    _height = 500;
  }

  if( !_left){
    _left = 100;
  }

  if( !_top){
    _top = 100 ;
  }

  if( !_x){
    _x = 100;
  }

  if( !_y){
    _y = 100;
  }

 
  window.open( _url, "", "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width="+_width
      +",height="+_height
      +",left="+_left
      +",top="+_top
      +",screenX="+_x
      +",screenY="+_y+"");
}

function popupFile( _url, _width, _height, _menubar) {
  if( !_width ) {
    _width = 680;
  }
  if( !_height ) {
    _height = 500;
  }
  if( !_menubar ) {
    _menubar = 0;
  }
  window.open( _url, "", "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar="+_menubar+",resizable=1,width="+_width+",height="+_height+"");
}


function submitEnterFunction(myfield, e, functionName){
  var keycode;
  if (window.event) {
    keycode = window.event.keyCode;
  }
  else {
    if (e) {
      keycode = e.which;
    } else {
      return true;
    }
  }

  if (keycode == 13) {
    functionName(myfield.value);
    return false;
  } else {
    return true;
  }
}


function submitenter(myfield, e) {
  var keycode;
  if (window.event) {
    keycode = window.event.keyCode;
  }
  else {
    if (e) {
      keycode = e.which;
    } else {
      return true;
    }
  }

  if (keycode == 13) {
    myfield.form.submit();
    return false;
  } else {
    return true;
  }
}

function submitGo( _id, _field, e) {
  var keycode;
  if (window.event) {
    keycode = window.event.keyCode;
  }
  else {
    if (e) {
      keycode = e.which;
    } else {
      return true;
    }
  }

  if (keycode == 13) {
    var result = _field.value;
    var moveTo = form.action;
    if(_uri.indexOf("?") == -1){
       moveTo += "?";
    }else{
       moveTo += "&";
    }
    moveTo += _id + "=";
    moveTo += result;
    _field.form.action = moveTo;
    _field.form.submit();

    return false;
  } else {
    return true;
  }
}



function openURI(_control, _target) {
  var control = _control;
  if (control.options[control.selectedIndex].value != '0') {
    if (_target != '_blank') {
      location.href = control.options[control.selectedIndex].value;
    } else {
      window.open(control.options[control.selectedIndex].value);
    }
  }
}

// copy the values from all the fields in the opening form
// to the current form based on equality of id values
// take the 'to' fields as the basis
function copyFieldsFromOpenerForm( _from, _to ) {
  var _fromForm = window.opener.document.getElementById( _from );
  var _toElements = document.getElementById( _to).elements;
  for(var i = 0; i < _toElements.length ; i++){
    var _toElement = _toElements[i];
    var _id = _toElement.id;
    var _fromElement = _fromForm.elements[ _id];
    if(_fromElement != null){
         _toElement.value = _fromElement.value;
    }
  }
}

// copy the values from all the fields in the current form
// to the opening form based on equality of id values
// take the 'to' fields as the basis
function copyFieldsToOpenerForm( _from, _to) {
  var _fromForm = document.getElementById( _from);
  var _toElements = window.opener.document.getElementById( _to );
  for(var i = 0; i < _toElements.length ; i++){
    var _toElement = _toElements[i];
    var _id = _toElement.id;
    var _fromElement = _fromForm.elements[ _id];
    if(_fromElement != null){
         _toElement.value = _fromElement.value;
    }
  }
}

// the print function
function getPrintURL() {
   var newUrl = location.href;
   if (newUrl.indexOf("?") < 0) {
      newUrl += '?print=yes';
   } else {
      newUrl += '&'+'print=yes';
   }
      return newUrl;
}

function popPrint() {
   var url = getPrintURL();
   popupFile(url, 723, 600);
}
