Bind("KASH_Order", Order);
Bind("KASH_Galois", Galois);
Bind("KASH_Lcm", LCM);
Bind("KASH_Size", Length);

if not(IsBound(__GAP_IN_PATH_P)) then
  LIBNAME:=LIBNAME+"/../gap/lib/"+";"+LIBNAME;
  __GAP_IN_PATH_P := true;
fi;

TRANSDEGREES:=22;

##IsString(LIBNAME);
##KASHLEVEL("KASH_OVERWRITE_INTERNAL_FXNS", 2);

Print("\nGAP-Emulation-Mode\n");
Print("not all functions available, and NO DOCUMENTATION\n\n"); 
if BANNER then
  Print("SOME OF THE NATIVE GAP FUNCTIONS HAVE BEEN MODIFIED.\n");
fi;


#ShallowCopy := Copy;
Bind("QuoInt", Div);
Bind("GcdInt", GCD);
Bind("RemInt",
  function(a,b)
    return a mod b;
  end);
Bind("RemoveSet", SetRemove_);
Bind("IsSubsetSet", SetIsSubset);
Bind("AddSet", SetAdd_);
Bind("SubtractSet", SetDifference);
Bind("IntersectSet", SetIntersection_);
Bind("IsEqualSet", SetIsEqual);
Bind("UniteSet", SetUnion_);

IsFFE := x->false;
IsCyc := x->false;
#IsAgWord := x->false;
IsCycInt := x->false;
IsMat := x->false;
Runtime := x->0;

IsRat := x->Is(Type(x),elt-ord^rat);


IntFFE               := function(arg)
                          Error("IntFFE");
                        end;
COEFFSCYC            := function(arg)
                          Error("COEFFSCYC");
                        end;
ExponentsAgWord      := function(arg)
                          Error("ExponentsAgWord");
                        end;
LogFFE               := function(arg)
                          Error("LogFFE");
                        end;
CharFFE              := function(arg)
                          Error("CharFFE");
                        end;
GaloisCyc            := function(arg)
                          Error("GaloisCyc");
                        end;
NofCyc               := function(arg)
                          Error("NofCyc");
                        end;
NormalizeCoeffs      := function(arg)
                          Error("NormalizeCoeffs");
                        end;
ShiftedCoeffs        := function(arg)
                          Error("ShiftedCoeffs");
                        end;
ApplyFunc            := function(arg)
                          Error("ApplyFunc");
                        end;
DegreeFFE            := function(arg)
                          Error("DegreeFFE");
                        end;
IntVecFFE            := function(arg)
                          Error("IntVecFFE");
                        end;
MakeVecFFE           := function(arg)
                          Error("MakeVecFFE");
                        end;
AgFpGroupTailDepthAgWord := function(arg)
                          Error("AgFpGroupTailDepthAgWord");
                        end;
CoefficientsInt      := function(arg)
                          Error("CoefficientsInt");
                        end;
LogVecFFE            := function(arg)
                          Error("LogVecFFE");
                        end;
NumberVecFFE         := function(arg)
                          Error("NumberVecFFE");
                        end;

Read("initgap.g");
#Order; # erzwinge Laden von GAP's 'Order'
#Order := function ( G, g )
#    return G.operations.Order( G, g );
#end;

#Order:=KASH_Order;
##
##JK: The Order command is defined in a way such that gap and kash
##    are able to use it
##
Order:=function(arg)
  if IsGroup(arg[1]) then
    return arg[1].operations.Order( arg[1], arg[2] );
  fi;
  if Length(arg) =1 then
     return KASH_Order(arg[1]);
  elif Length(arg)=2 then
     return KASH_Order(arg[1],arg[2]);
  elif Length(arg)=3 then
     return KASH_Order(arg[1],arg[2],arg[3]);
  else
     Error("Order: wrong arguments\n");
  fi;
    
  end;

_ProductCoeffs_Internal:=
  function(lis1,len1,lis2,len2)
    return ;
  end;
ProductCoeffs:=
  function(arg)
    local lis1,len1,lis2,len2,tmp;
    if Length(arg)=2 then
      lis1:=_GetEntry_list_eor(arg,1,rec(Fail:=[]));
      if IsList(lis1) then
        len1:=Length(lis1);
      else
        return Error("<list1> must be a list");
      fi;
      lis2:=_GetEntry_list_eor(arg,2,rec(Fail:=[]));
      if IsList(lis2) then
        len2:=Length(lis2);
      else
        return Error("<list2> must be a list");
      fi;
    elif Length(arg)=3 then
      lis1:=_GetEntry_list_eor(arg,1,rec(Fail:=[]));
      if IsList(lis1) then
        len1:=Length(lis1);
      else
        return Error("<list1> must be a list");
      fi;
      lis2:=_GetEntry_list_eor(arg,2,rec(Fail:=[]));
      if IsList(lis2) then
        len2:=Length(lis2);
      elif IsInt(lis2) then
        len1:=lis2;
      else
        return Error("<list2> must be a list");
      fi;
      tmp:=_GetEntry_list_eor(arg,3,rec(Fail:=[]));
      if IsList(tmp) then
        lis2:=tmp;
      elif IsInt(tmp) then
        len2:=tmp;
      else
        return Error("<list2> must be a list");
      fi;
    elif Length(arg)=4 then
      lis1:=arg[1];
      len1:=arg[2];
      lis2:=arg[3];
      len2:=arg[4];
    else
      return Error("Usage: ProductCoeffs(<list>,<elt-ord^rat>,<list>,<elt-ord^rat>");
    fi;
    return _ProductCoeffs_Internal(lis1,len1,lis2,len2);
  end;

if not(IsBound(gap)) then
  NewType("gap",2);
fi;
